CCRenderTexture Class Reference
| Inherits from | CCNode : NSObject |
| Declared in | CCRenderTexture.h |
Overview
CCRenderTexture is a generic rendering target. To render things into it, simply construct a render target, call begin on it, call visit on any cocos2d scenes or objects to render them, and call end. For convenience, render texture adds a sprite as its display child with the results, so you can simply add the render texture to your scene and treat it like any other CCNode. There are also functions for saving the render texture to disk in PNG or JPG format.
Tasks
Other Methods
-
spriteThe 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:
property- [[renderTexture sprite] setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; -
clearFlagsValid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when “autoDraw is YES.
property -
clearColorClear color value. Valid only when “autoDraw” is YES.
property -
clearDepthValue for clearDepth. Valid only when autoDraw is YES.
property -
clearStencilValue for clear Stencil. Valid only when autoDraw is YES
property -
autoDrawWhen enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future.
property -
+ renderTextureWithWidth:height:pixelFormat:depthStencilFormat:initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
-
+ renderTextureWithWidth:height:pixelFormat:creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
-
+ renderTextureWithWidth:height:creates a RenderTexture object with width and height in Points, pixel format is RGBA8888
-
– initWithWidth:height:pixelFormat:initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
-
– initWithWidth:height:pixelFormat:depthStencilFormat:initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
-
– beginstarts grabbing
-
– beginWithClear:g:b:a:starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
-
– beginWithClear:g:b:a:depth:starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
-
– beginWithClear:g:b:a:depth:stencil:starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
-
– endends grabbing
-
– clear:g:b:a:clears the texture with a color
-
– clearDepth:clears the texture with a specified depth value
-
– clearStencil:clears the texture with a specified stencil value
-
– newCGImage -
– saveToFile: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.
-
– saveToFile:format: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.
-
– getUIImage
Other Methods
-
– initWithWidth:height:initializes a RenderTexture object with width and height
-
– getUIImageFromBuffer -
– saveBuffer:saves the texture into a file
-
– saveBuffer:format:saves the texture into a file. The format can be JPG or PNG
Deprecated Methods
Properties
autoDraw
When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future.
@property (nonatomic, readwrite) BOOL autoDrawDeclared In
CCRenderTexture.hclearColor
Clear color value. Valid only when “autoDraw” is YES.
@property (nonatomic, readwrite) ccColor4F clearColorDeclared In
CCRenderTexture.hclearDepth
Value for clearDepth. Valid only when autoDraw is YES.
@property (nonatomic, readwrite) GLclampf clearDepthDeclared In
CCRenderTexture.hclearFlags
Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when “autoDraw is YES.
@property (nonatomic, readwrite) GLbitfield clearFlagsDeclared In
CCRenderTexture.hclearStencil
Value for clear Stencil. Valid only when autoDraw is YES
@property (nonatomic, readwrite) GLint clearStencilDeclared In
CCRenderTexture.hsprite
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}];
@property (nonatomic, readwrite, retain) CCSprite *spriteDeclared In
CCRenderTexture.hClass Methods
renderTextureWithWidth:height:
creates a RenderTexture object with width and height in Points, pixel format is RGBA8888
+ (id)renderTextureWithWidth:(int)w height:(int)hDeclared In
CCRenderTexture.hrenderTextureWithWidth:height:pixelFormat:
creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
+ (id)renderTextureWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)formatDeclared In
CCRenderTexture.hrenderTextureWithWidth:height:pixelFormat:depthStencilFormat:
initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
+ (id)renderTextureWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format depthStencilFormat:(GLuint)depthStencilFormatDeclared In
CCRenderTexture.hInstance Methods
beginWithClear:g:b:a:
starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
- (void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)aDeclared In
CCRenderTexture.hbeginWithClear:g:b:a:depth:
starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
- (void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a depth:(float)depthValueDeclared In
CCRenderTexture.hbeginWithClear:g:b:a:depth:stencil:
starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin
- (void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a depth:(float)depthValue stencil:(int)stencilValueDeclared In
CCRenderTexture.hclear:g:b:a:
clears the texture with a color
- (void)clear:(float)r g:(float)g b:(float)b a:(float)aDeclared In
CCRenderTexture.hclearDepth:
clears the texture with a specified depth value
- (void)clearDepth:(float)depthValueDeclared In
CCRenderTexture.hclearStencil:
clears the texture with a specified stencil value
- (void)clearStencil:(int)stencilValueDeclared In
CCRenderTexture.hinitWithWidth:height:
initializes a RenderTexture object with width and height
- (id)initWithWidth:(int)width height:(int)heightDeclared In
CCRenderTexture.hinitWithWidth:height:pixelFormat:
initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
- (id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)formatDeclared In
CCRenderTexture.hinitWithWidth:height:pixelFormat:depthStencilFormat:
initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
- (id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format depthStencilFormat:(GLuint)depthStencilFormatDeclared In
CCRenderTexture.hsaveBuffer:
saves the texture into a file
- (BOOL)saveBuffer:(NSString *)nameDeclared In
CCRenderTexture.hsaveBuffer:format:
saves the texture into a file. The format can be JPG or PNG
- (BOOL)saveBuffer:(NSString *)name format:(int)formatDeclared In
CCRenderTexture.h