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

  •   sprite

    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
  •   clearFlags

    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
  •   clearColor

    Clear color value. Valid only when “autoDraw” is YES.

    property
  •   clearDepth

    Value for clearDepth. Valid only when autoDraw is YES.

    property
  •   clearStencil

    Value for clear Stencil. Valid only when autoDraw is YES

    property
  •   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
  • + 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

  • – begin

    starts 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

  • – end

    ends 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

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 autoDraw

Declared In

CCRenderTexture.h

clearColor

Clear color value. Valid only when “autoDraw” is YES.

@property (nonatomic, readwrite) ccColor4F clearColor

Declared In

CCRenderTexture.h

clearDepth

Value for clearDepth. Valid only when autoDraw is YES.

@property (nonatomic, readwrite) GLclampf clearDepth

Declared In

CCRenderTexture.h

clearFlags

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 clearFlags

Declared In

CCRenderTexture.h

clearStencil

Value for clear Stencil. Valid only when autoDraw is YES

@property (nonatomic, readwrite) GLint clearStencil

Declared In

CCRenderTexture.h

sprite

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 *sprite

Declared In

CCRenderTexture.h

Class Methods

renderTextureWithWidth:height:

creates a RenderTexture object with width and height in Points, pixel format is RGBA8888

+ (id)renderTextureWithWidth:(int)w height:(int)h

Declared In

CCRenderTexture.h

renderTextureWithWidth: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)format

Declared In

CCRenderTexture.h

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

+ (id)renderTextureWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat

Declared In

CCRenderTexture.h

Instance Methods

begin

starts grabbing

- (void)begin

Declared In

CCRenderTexture.h

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)a

Declared In

CCRenderTexture.h

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

- (void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a depth:(float)depthValue

Declared In

CCRenderTexture.h

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

- (void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a depth:(float)depthValue stencil:(int)stencilValue

Declared In

CCRenderTexture.h

clear:g:b:a:

clears the texture with a color

- (void)clear:(float)r g:(float)g b:(float)b a:(float)a

Declared In

CCRenderTexture.h

clearDepth:

clears the texture with a specified depth value

- (void)clearDepth:(float)depthValue

Declared In

CCRenderTexture.h

clearStencil:

clears the texture with a specified stencil value

- (void)clearStencil:(int)stencilValue

Declared In

CCRenderTexture.h

end

ends grabbing

- (void)end

Declared In

CCRenderTexture.h

getUIImage

getUIImageAsDataFromBuffer:

getUIImageFromBuffer

initWithWidth:height:

initializes a RenderTexture object with width and height

- (id)initWithWidth:(int)width height:(int)height

Declared In

CCRenderTexture.h

initWithWidth: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)format

Declared In

CCRenderTexture.h

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

- (id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat

Declared In

CCRenderTexture.h

newCGImage

saveBuffer:

saves the texture into a file

- (BOOL)saveBuffer:(NSString *)name

Declared In

CCRenderTexture.h

saveBuffer:format:

saves the texture into a file. The format can be JPG or PNG

- (BOOL)saveBuffer:(NSString *)name format:(int)format

Declared In

CCRenderTexture.h

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.

- (BOOL)saveToFile:(NSString *)name

Declared In

CCRenderTexture.h

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.

- (BOOL)saveToFile:(NSString *)name format:(tCCImageFormat)format

Declared In

CCRenderTexture.h