CCRenderTexture is a generic rendering target. To render things into it, simply construct a render target, call begin on it, call visit on any cocos scenes or objects to render them, and call end. For convenience, render texture adds a sprite as it’s display child with the results, so you can simply add the render texture to your scene and treat it like any other CocosNode. There are also functions for saving the render texture to disk in PNG or JPG format.
Class CCRenderTexture
#include <Geode/cocos/misc_nodes/CCRenderTexture.h>
Examples0
Public static methods3
staticcocos2d::CCRenderTexture*create(intw,inth,,_::GLuintuDepthStencilFormat)
initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
staticcocos2d::CCRenderTexture*create(intw,inth,)
creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
staticcocos2d::CCRenderTexture*create(intw,inth)
creates a RenderTexture object with width and height in Points, pixel format is RGBA8888
Public member functions31
virtualcocos2d::CCSprite*getSprite()
The CCSprite being used. The sprite, by default, will use the following blending function: GL_ONE, GL_ONE_MINUS_SRC_ALPHA. The blending function can be changed in runtime by calling:
- [[renderTexture sprite] setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
virtualvoidsetSprite()
The CCSprite being used. The sprite, by default, will use the following blending function: GL_ONE, GL_ONE_MINUS_SRC_ALPHA. The blending function can be changed in runtime by calling:
- [[renderTexture sprite] setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
virtualvoidvisit()
virtualvoiddraw()
boolinitWithWidthAndHeight(intw,inth,)
initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
boolinitWithWidthAndHeight(intw,inth,,_::GLuintuDepthStencilFormat)
initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
voidbegin()
starts grabbing
voidbeginWithClear(,,,)
starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
voidbeginWithClear(,,,,floatdepthValue)
starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
voidbeginWithClear(,,,,floatdepthValue,intstencilValue)
starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
voidendToLua()
end is key word of lua, use other name to export to lua.
voidend()
ends grabbing
cocos2d::CCImage*newCCImage(boolflipImage)
boolsaveToFile(charconst*szFilePath)
saves the texture into a file using JPEG format. The file will be saved in the Documents folder. Returns YES if the operation is successful.
boolsaveToFile(charconst*name,cocos2d::tCCImageFormatformat)
saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder. Returns YES if the operation is successful.
voidlistenToBackground()
Listen “come to background” message, and save render texture. It only has effect on Android.
voidlistenToForeground()
Listen “come to foreground” message and restore the frame buffer object It only has effect on Android.
uintgetClearFlags()const
Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR’ed. Valid when “autoDraw is YES.
cocos2d::ccColor4Fconst&getClearColor()const
Clear color value. Valid only when “autoDraw” is true.
voidsetClearColor(cocos2d::ccColor4Fconst&clearColor)
floatgetClearDepth()const
Value for clearDepth. Valid only when autoDraw is true.
intgetClearStencil()const
Value for clear Stencil. Valid only when autoDraw is true
boolisAutoDraw()const
When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future.
Fields0
Protected member functions0
Protected fields13
cocos2d::CCSprite*m_pSprite;
The CCSprite being used. The sprite, by default, will use the following blending function: GL_ONE, GL_ONE_MINUS_SRC_ALPHA. The blending function can be changed in runtime by calling:
- [[renderTexture sprite] setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];