# CCRenderer Class Reference

Inherits from | NSObject
Declared in | CCRenderer.h

## Overview

A rendering queue. All drawing commands in Cocos2D must be sequenced using a CCRenderer.

## Tasks

### Other Methods

- `– invalidateState`
- `– enqueueClear:color:depth:stencil:globalSortOrder:`
- `– enqueueBlock:globalSortOrder:debugLabel:threadSafe:`
- `– enqueueMethod:target:`
- `– pushGroup`
- `– popGroupWithDebugLabel:globalSortOrder:`

### NoARC Methods

- `– enqueueTriangles:andVertexes:withState:globalSortOrder:`
- `– enqueueLines:andVertexes:withState:globalSortOrder:`

### Extension Methods

- `globalShaderUniforms` property
- `+ currentRenderer`
- `+ bindRenderer:`
- `– enqueueRenderCommand:`
- `– flush`
- `– bindVAO:`
- `– resizeBuffer:capacity:`

## Properties

### globalShaderUniforms

Current global shader uniform values.

`@property (nonatomic, copy) NSDictionary *globalShaderUniforms`

#### Declared In

`CCRenderer_private.h`

## Class Methods

### bindRenderer:

Set the current renderer for the current thread.

`+ (void)bindRenderer:(CCRenderer *)renderer`

#### Declared In

`CCRenderer_private.h`

### currentRenderer

Retrieve the current renderer for the current thread.

`+ (instancetype)currentRenderer`

#### Declared In

`CCRenderer_private.h`

## Instance Methods

### bindVAO:

Bind the renderer’s VAO if it is not currently bound.

`- (void)bindVAO:(BOOL)bind`

#### Declared In

`CCRenderer_private.h`

### 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`

#### Declared In

`CCRenderer.h`

### 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`

#### 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`

#### 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`

#### Declared In

`CCRenderer.h`

### enqueueRenderCommand:

Enqueue a general or custom render command.

`- (void)enqueueRenderCommand:(id<CCRenderCommand>)renderCommand`

#### Declared In

`CCRenderer_private.h`

### 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`

#### Declared In

`CCRenderer.h`

### flush

Render any currently queued commands.

`- (void)flush`

#### Declared In

`CCRenderer_private.h`

### 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`

### 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`

#### Declared In

`CCRenderer.h`

### 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`

### resizeBuffer:capacity:

Resize the capacity of a graphics buffer.

`- (void)resizeBuffer:(struct CCGraphicsBuffer *)buffer capacity:(size_t)capacity`

#### Declared In

`CCRenderer_private.h`