CCRenderer Class Reference
Inherits from | NSObject |
---|---|
Declared in | CCRenderer.h |
Overview
Implements a rendering queue. All drawing commands in Cocos2D must be sequenced using a CCRenderer, including native OpenGL and Metal rendering commands.
Thread Safety
threadsafe
Whether the renderer contains only threadsafe rendering commands.
@property (nonatomic, readonly) BOOL threadsafe
Declared In
CCRenderer.h
Invalidating the Render State
– invalidateState
Mark the renderer’s cached GL state as invalid executing custom OpenGL code. You only need to call this if you change the shader, texture or blending mode states.
- (void)invalidateState
Declared In
CCRenderer.h
Enqueuing a Clear Buffer Command
– enqueueClear:color:depth:stencil:globalSortOrder:
Enqueue a OpenGL clear operation for the given buffers and the given values. Enqueued commands are sorted by their globalSortOrder value before rendering. Currently this value is 0 for everything except custom draw methods.
- (void)enqueueClear:(GLbitfield)mask color:(GLKVector4)color4 depth:(GLclampf)depth stencil:(GLint)stencil globalSortOrder:(NSInteger)globalSortOrder
Parameters
mask |
clear bitmask |
---|---|
color4 |
RGBA color |
depth |
clamp depth |
stencil |
stencil |
globalSortOrder |
rendering sort order |
Declared In
CCRenderer.h
Enqueuing Rendering Commands
– enqueueBlock:globalSortOrder:debugLabel:threadSafe:
Enqueue a block that performs GL commands. The debugLabel is optional and will show up in in the GLES frame debugger. Enqueued commands are sorted by their globalSortOrder value before rendering. Currently this value is 0 for everything except custom draw methods.
- (void)enqueueBlock:(void ( ^ ) ( ))block globalSortOrder:(NSInteger)globalSortOrder debugLabel:(NSString *)debugLabel threadSafe:(BOOL)threadSafe
Parameters
block |
block with GL commands to enqueue |
---|---|
globalSortOrder |
rendering sort order |
debugLabel |
debugging label |
threadSafe |
whether to ensure thread safety |
Declared In
CCRenderer.h
– enqueueMethod:target:
Enqueue a method that performs GL commands. Enqueued commands are sorted by their globalSortOrder value before rendering. Currently this value is 0 for everything except custom draw methods.
- (void)enqueueMethod:(SEL)selector target:(id)target
Parameters
selector |
the selector to run |
---|---|
target |
the target object receiving the selector message |
Declared In
CCRenderer.h
Rendering Groups
– pushGroup
Begin a rendering group. Must be matched with a call to popGroup:. Can be nested. Commands in the group are sorted relative to each other.
- (void)pushGroup
Declared In
CCRenderer.h
– popGroupWithDebugLabel:globalSortOrder:
End the most recent group started using pushGroup. The grouped commands are sorted together using the gives sorting order.
- (void)popGroupWithDebugLabel:(NSString *)debugLabel globalSortOrder:(NSInteger)globalSortOrder
Parameters
debugLabel |
debugging label |
---|---|
globalSortOrder |
rendering sort order |
Declared In
CCRenderer.h
NoARC Methods
– enqueueTriangles:andVertexes:withState:globalSortOrder:
Enqueue a drawing command for some triangles.
Returns a CCRendereBuffer that you should fill using CCRenderBufferSetVertex()
and CCRenderBufferSetTriangle()
.
Enqueued commands are sorted by their globalSortOrder value before rendering. Currently this value is 0 for everything except custom draw methods.
- (CCRenderBuffer)enqueueTriangles:(NSUInteger)triangleCount andVertexes:(NSUInteger)vertexCount withState:(CCRenderState *)renderState globalSortOrder:(NSInteger)globalSortOrder
Parameters
triangleCount |
number of triangles to enqueue |
---|---|
vertexCount |
number of vertexes to enqueue |
renderState |
renderState to use |
globalSortOrder |
rendering sort order |
Declared In
CCRenderer.h
– enqueueLines:andVertexes:withState:globalSortOrder:
Enqueue a drawing command for some lines.
Returns a CCRendereBuffer that you should fill using CCRenderBufferSetVertex()
and CCRenderBufferSetLine()
.
Note: These are primitive OpenGL lines that you’ll only want to use for debug rendering. They are not batched.
Enqueued commands are sorted by their globalSortOrder value before rendering. Currently this value is 0 for everything except custom draw methods.
- (CCRenderBuffer)enqueueLines:(NSUInteger)lineCount andVertexes:(NSUInteger)vertexCount withState:(CCRenderState *)renderState globalSortOrder:(NSInteger)globalSortOrder
Parameters
lineCount |
number of lines to enqueue |
---|---|
vertexCount |
number of vertexes to enqueue |
renderState |
renderState to use |
globalSortOrder |
rendering sort order |
Declared In
CCRenderer.h