cocos2d-iphone  2.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
CCRenderTexture Class Reference

#import <CCRenderTexture.h>

+ Inheritance diagram for CCRenderTexture:
+ Collaboration diagram for CCRenderTexture:

List of all members.

Public Member Functions

(id) - initWithWidth:height:pixelFormat:
(id) - initWithWidth:height:pixelFormat:depthStencilFormat:
(void) - begin
(void) - beginWithClear:g:b:a:
(void) - beginWithClear:g:b:a:depth:
(void) - beginWithClear:g:b:a:depth:stencil:
(void) - end
(void) - clear:g:b:a:
(void) - clearDepth:
(void) - clearStencil:
(CGImageRef) - newCGImage
(BOOL) - saveToFile:
(BOOL) - saveToFile:format:
(UIImage *) - getUIImage
(BOOL) - saveBuffer:
(BOOL) - saveBuffer:format:
(NSData *) - getUIImageAsDataFromBuffer:
(UIImage *) - DEPRECATED_ATTRIBUTE

Static Public Member Functions

(id) + renderTextureWithWidth:height:pixelFormat:depthStencilFormat:
(id) + renderTextureWithWidth:height:pixelFormat:
(id) + renderTextureWithWidth:height:

Protected Attributes

GLuint _FBO
GLuint _depthRenderBufffer
GLint _oldFBO
CCTexture2D_texture
CCSprite_sprite
GLenum _pixelFormat
GLbitfield _clearFlags
ccColor4F _clearColor
GLclampf _clearDepth
GLint _clearStencil
BOOL _autoDraw

Properties

CCSpritesprite
GLbitfield clearFlags
ccColor4F clearColor
GLclampf clearDepth
GLint clearStencil
BOOL autoDraw

Detailed Description

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.

Since:
v0.8.1

Member Function Documentation

- (void) begin

starts grabbing

- (void) beginWithClear: (float)  r
g: (float)  g
b: (float)  b
a: (float)  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
depth: (float)  depthValue 

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 

starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin

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

clears the texture with a color

- (void) clearDepth: (float)  depthValue

clears the texture with a specified depth value

- (void) clearStencil: (int)  stencilValue

clears the texture with a specified stencil value

- (void) end

ends grabbing

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

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
depthStencilFormat: (GLuint)  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 

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

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

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
depthStencilFormat: (GLuint)  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

- (BOOL) saveToFile: (NSString *)  name

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
format: (tCCImageFormat)  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.


Property Documentation

- (BOOL) autoDraw [read, write, assign]

When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future.

- (ccColor4F) clearColor [read, write, assign]

Clear color value. Valid only when "autoDraw" is YES.

- (GLclampf) clearDepth [read, write, assign]

Value for clearDepth. Valid only when autoDraw is YES.

- (GLbitfield) clearFlags [read, write, assign]

Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw is YES.

- (GLint) clearStencil [read, write, assign]

Value for clear Stencil. Valid only when autoDraw is YES

- (CCSprite*) sprite [read, write, retain]

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}];

The documentation for this class was generated from the following file: