CCRenderTexture Class Reference
| Inherits from | CCNode : CCResponder : 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
-
spriteproperty -
clearFlagsproperty -
clearColorproperty -
clearDepthproperty -
clearStencilproperty -
autoDrawproperty
Create CCRenderTexture.
-
+ renderTextureWithWidth:height:pixelFormat:depthStencilFormat: -
+ renderTextureWithWidth:height:pixelFormat: -
+ renderTextureWithWidth:height: -
– initWithWidth:height:pixelFormat: -
– initWithWidth:height:pixelFormat:depthStencilFormat: -
– begin -
– beginWithClear:g:b:a: -
– beginWithClear:g:b:a:depth: -
– beginWithClear:g:b:a:depth:stencil: -
– end -
– clear:g:b:a: -
– clearDepth: -
– clearStencil: -
– saveToFile: -
– saveToFile:format: -
– saveToFilePath: -
– saveToFilePath:format: -
– getUIImage
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, strong) CCColor *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.hClass Methods
renderTextureWithWidth:height:
Creates a RenderTexture object with width and height in Points, pixel format is RGBA8888
+ (id)renderTextureWithWidth:(int)w height:(int)hParameters
- w
Width of render target.
- h
Height of render target.
Return Value
An initialized CCRenderTarget object.
Declared 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:(CCTexturePixelFormat)formatParameters
- w
Width of render target.
- h
Height of render target.
- format
Pixel format of render target.
Return Value
An initialized CCRenderTarget object.
Declared 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:(CCTexturePixelFormat)format depthStencilFormat:(GLuint)depthStencilFormatParameters
- w
Width of render target.
- h
Height of render target.
- format
Pixel format of render target.
- depthStencilFormat
Stencil format of render target.
Return Value
An initialized CCRenderTarget object.
Declared In
CCRenderTexture.hInstance Methods
begin
Starts rendering to the texture whitout clearing the texture first.
- (void)beginDeclared In
CCRenderTexture.hbeginWithClear: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)aParameters
- r
Red color.
- g
Green color.
- b
Blue color.
- a
Alpha.
Declared 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)depthValueParameters
- r
Red color.
- g
Green color.
- b
Blue color.
- a
Alpha.
- depthValue
Depth value.
Declared 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)stencilValueParameters
- r
Red color.
- g
Green color.
- b
Blue color.
- a
Alpha.
- depthValue
Depth value.
- stencilValue
Stencil value.
Declared In
CCRenderTexture.hclear:g:b:a:
Clears the texture with a color
- (void)clear:(float)r g:(float)g b:(float)b a:(float)aParameters
- r
Red color.
- g
Green color.
- b
Blue color.
- a
Alpha.
Declared In
CCRenderTexture.hclearDepth:
Clears the texture with a specified depth value.
- (void)clearDepth:(float)depthValueParameters
- depthValue
Depth value.
Declared In
CCRenderTexture.hclearStencil:
Clears the texture with a specified stencil value.
- (void)clearStencil:(int)stencilValueParameters
- stencilValue
Stencil value.
Declared In
CCRenderTexture.hgetUIImage
Returns an autoreleased UIImage from the texture
- (UIImage *)getUIImageDeclared 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:(CCTexturePixelFormat)formatParameters
- w
Width of render target.
- h
Height of render target.
- format
Pixel format of render target.
Return Value
An initialized CCRenderTarget object.
Declared 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:(CCTexturePixelFormat)format depthStencilFormat:(GLuint)depthStencilFormatParameters
- w
Width of render target.
- h
Height of render target.
- format
Pixel format of render target.
- depthStencilFormat
Stencil format of render target.
Return Value
An initialized CCRenderTarget object.
Declared In
CCRenderTexture.hsaveToFile:
Saves the texture into a file using JPEG format. The file will be saved in the Documents folder.
- (BOOL)saveToFile:(NSString *)nameParameters
- name
Filename to save image to.
Return Value
YES if the operation is successful.
Declared In
CCRenderTexture.hsaveToFile:format:
Saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder.
- (BOOL)saveToFile:(NSString *)name format:(CCRenderTextureImageFormat)formatParameters
- name
Filename to save image to.
- format
File format.
Return Value
YES if the operation is successful.
Declared In
CCRenderTexture.hsaveToFilePath:
Saves the texture into a file using JPEG format.
- (BOOL)saveToFilePath:(NSString *)filePathParameters
- filePath
File path to save image to.
Return Value
YES if the operation was successful.
Declared In
CCRenderTexture.hsaveToFilePath:format:
Saves the texture into a file. The format could be JPG or PNG.
- (BOOL)saveToFilePath:(NSString *)filePath format:(CCRenderTextureImageFormat)formatParameters
- filePath
File path to save image to.
- format
File format.
Return Value
YES if the operation was successful.
Declared In
CCRenderTexture.h