RenderTarget.new: Difference between revisions
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 50: | Line 50: | ||
'''format''': (string) specify the wanted pixel format for this render target. Use ones of the [[TextureBase]] format constants, or leave nil for default ('''default = [[TextureBase.RGBA8888]]''')<br/> | '''format''': (string) specify the wanted pixel format for this render target. Use ones of the [[TextureBase]] format constants, or leave nil for default ('''default = [[TextureBase.RGBA8888]]''')<br/> | ||
'''extend''': (boolean) extend the texture to a power of two size internally '''since Gideros 2022.5.1''' ('''default = true''')<br/> | '''extend''': (boolean) extend the texture to a power of two size internally '''since Gideros 2022.5.1''' ('''default = true''')<br/> | ||
=== Example === | |||
'''Turn a rendered target output into a Bitmap''' | |||
<syntaxhighlight lang="lua"> | |||
-- Your existing complex sprite container | |||
local mySprite = Sprite.new() | |||
-- (add children to mySprite here) | |||
-- Create a RenderTarget with specific width and height | |||
local rt = RenderTarget.new(256, 256) | |||
rt:draw(mySprite) | |||
-- Turn the rendered target output into a Bitmap | |||
local bitmapFromSprite = Bitmap.new(rt) | |||
stage:addChild(bitmapFromSprite) | |||
</syntaxhighlight> | |||
=== See also === | |||
'''[[Buffer.new]]''' | |||
{{RenderTarget}} | {{RenderTarget}} | ||
Latest revision as of 19:44, 9 October 2026
Available since: Gideros 2024.3
Class: RenderTarget
Description
Creates a new RenderTarget object (Gideros 2024.3+).
RenderTarget.new(width,height,filtering,options)
Parameters
width: (number) width of rendered texture
height: (number) height of rendered texture
filtering: (boolean) set texture filtering, that is smoothing the image (default = false)
options: now you can pass various options as a table:
- wrap: (string) either "clamp" or "repeat" (default = "clamp")
- format: (string) the wanted pixel format for this render target. Use one of the TextureBase format constants, or leave nil for default (default = TextureBase.RGBA8888)
- extend: (boolean) extend the texture to a power of two size internally (default = true)
- mipmap: (boolean) set texture mipmaping (default = false)
Example
Gideros 2024.3+
local rt = RenderTarget.new(bmp:getWidth(), bmp:getHeight(), false, { extend=false })
Reference
https://github.com/gideros/gideros/blob/master/luabinding/rendertargetbinder.cpp
Available since: Gideros 2013.06
Class: RenderTarget
Description
Creates a new RenderTarget object.
RenderTarget.new(width,height,filtering,repeating,autoscale,depth,format,extend)
Parameters
width: (number) width of rendered texture
height: (number) height of rendered texture
filtering: (boolean) set texture filtering, that is smoothing the image (default = false)
repeating: (boolean) set texture repeating (default = false)
autoscale: (boolean) whether the actual texture size should be scaled to match display resolution (default = false)
depth: (boolean) indicate this rendertarget will hold depth component. Setting this to true creates a render target suitable for shadow mapping (default = false)
format: (string) specify the wanted pixel format for this render target. Use ones of the TextureBase format constants, or leave nil for default (default = TextureBase.RGBA8888)
extend: (boolean) extend the texture to a power of two size internally since Gideros 2022.5.1 (default = true)
Example
Turn a rendered target output into a Bitmap
-- Your existing complex sprite container
local mySprite = Sprite.new()
-- (add children to mySprite here)
-- Create a RenderTarget with specific width and height
local rt = RenderTarget.new(256, 256)
rt:draw(mySprite)
-- Turn the rendered target output into a Bitmap
local bitmapFromSprite = Bitmap.new(rt)
stage:addChild(bitmapFromSprite)
See also