Cocos2d-x  v4
CommandBuffer Class Referenceabstract

Store encoded commands for the GPU to execute. More...

Inherits Ref.

Inherited by CommandBufferGL, and CommandBufferMTL.

Setters & Getters

virtual void beginFrame ()=0
 Indicate the begining of a frame.
 
virtual void beginRenderPass (const RenderPassDescriptor &descriptor)=0
 Begin a render pass, initial color, depth and stencil attachment. More...
 
virtual void setRenderPipeline (RenderPipeline *renderPipeline)=0
 Sets the current render pipeline state object. More...
 
virtual void setViewport (int x, int y, unsigned int w, unsigned int h)=0
 Fixed-function state. More...
 
virtual void setCullMode (CullMode mode)=0
 Fixed-function state. More...
 
virtual void setWinding (Winding winding)=0
 Fixed-function state. More...
 
virtual void setVertexBuffer (Buffer *buffer)=0
 Set a global buffer for all vertex shaders at the given bind point index 0. More...
 
virtual void setProgramState (ProgramState *programState)=0
 Set unifroms and textures. More...
 
virtual void setIndexBuffer (Buffer *buffer)=0
 Set indexes when drawing primitives with index list @ buffer A buffer object that the device will read indexes from. More...
 
virtual void drawArrays (PrimitiveType primitiveType, std::size_t start, std::size_t count)=0
 Draw primitives without an index list. More...
 
virtual void drawElements (PrimitiveType primitiveType, IndexFormat indexType, std::size_t count, std::size_t offset)=0
 Draw primitives with an index list. More...
 
virtual void endRenderPass ()=0
 Do some resources release.
 
virtual void endFrame ()=0
 Present a drawable and commit a command buffer so it can be executed as soon as possible.
 
virtual void setLineWidth (float lineWidth)=0
 Fixed-function state. More...
 
virtual void setScissorRect (bool isEnabled, float x, float y, float width, float height)=0
 Fixed-function state. More...
 
virtual void setDepthStencilState (DepthStencilState *depthStencilState)=0
 Set depthStencil status. More...
 
virtual void captureScreen (std::function< void(const unsigned char *, int, int)> callback)=0
 Get a screen snapshot. More...
 
void setStencilReferenceValue (unsigned int value)
 Update both front and back stencil reference value. More...
 
void setStencilReferenceValue (unsigned int frontRef, unsigned int backRef)
 Update stencil reference value. More...
 

Additional Inherited Members

- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 
- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

Store encoded commands for the GPU to execute.

A command buffer stores encoded commands until the buffer is committed for execution by the GPU

Member Function Documentation

◆ beginRenderPass()

virtual void beginRenderPass ( const RenderPassDescriptor descriptor)
pure virtual

Begin a render pass, initial color, depth and stencil attachment.

Parameters
descriptorSpecifies a group of render targets that hold the results of a render pass.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setRenderPipeline()

virtual void setRenderPipeline ( RenderPipeline renderPipeline)
pure virtual

Sets the current render pipeline state object.

Parameters
renderPipelineAn object that contains the graphics functions and configuration state used in a render pass.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setViewport()

virtual void setViewport ( int  x,
int  y,
unsigned int  w,
unsigned int  h 
)
pure virtual

Fixed-function state.

Parameters
xThe x coordinate of the upper-left corner of the viewport.
yThe y coordinate of the upper-left corner of the viewport.
wThe width of the viewport, in pixels.
hThe height of the viewport, in pixels.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setCullMode()

virtual void setCullMode ( CullMode  mode)
pure virtual

Fixed-function state.

Parameters
modeControls if primitives are culled when front facing, back facing, or not culled at all.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setWinding()

virtual void setWinding ( Winding  winding)
pure virtual

Fixed-function state.

Parameters
windingThe winding order of front-facing primitives.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setVertexBuffer()

virtual void setVertexBuffer ( Buffer buffer)
pure virtual

Set a global buffer for all vertex shaders at the given bind point index 0.

Parameters
bufferThe vertex buffer to be setted in the buffer argument table.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setProgramState()

virtual void setProgramState ( ProgramState programState)
pure virtual

Set unifroms and textures.

Parameters
programStateA programState object that hold the uniform and texture data.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setIndexBuffer()

virtual void setIndexBuffer ( Buffer buffer)
pure virtual

Set indexes when drawing primitives with index list @ buffer A buffer object that the device will read indexes from.

@ see drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ drawArrays()

virtual void drawArrays ( PrimitiveType  primitiveType,
std::size_t  start,
std::size_t  count 
)
pure virtual

Draw primitives without an index list.

Parameters
primitiveTypeThe type of primitives that elements are assembled into.
startFor each instance, the first index to draw
countFor each instance, the number of indexes to draw
See also
drawElements(PrimitiveType primitiveType, IndexFormat indexType, unsigned int count, unsigned int offset)

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ drawElements()

virtual void drawElements ( PrimitiveType  primitiveType,
IndexFormat  indexType,
std::size_t  count,
std::size_t  offset 
)
pure virtual

Draw primitives with an index list.

Parameters
primitiveTypeThe type of primitives that elements are assembled into.
indexTypeThe type if indexes, either 16 bit integer or 32 bit integer.
countThe number of indexes to read from the index buffer for each instance.
offsetByte offset within indexBuffer to start reading indexes from.
See also
setIndexBuffer(Buffer* buffer)
drawArrays(PrimitiveType primitiveType, unsigned int start, unsigned int count)

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setLineWidth()

virtual void setLineWidth ( float  lineWidth)
pure virtual

Fixed-function state.

Parameters
lineWidthSpecifies the width of rasterized lines.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setScissorRect()

virtual void setScissorRect ( bool  isEnabled,
float  x,
float  y,
float  width,
float  height 
)
pure virtual

Fixed-function state.

Parameters
x,ySpecifies the lower left corner of the scissor box
wdithSpecifies the width of the scissor box
heightSpecifies the height of the scissor box

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setDepthStencilState()

virtual void setDepthStencilState ( DepthStencilState depthStencilState)
pure virtual

Set depthStencil status.

Parameters
depthStencilStateSpecifies the depth and stencil status

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ captureScreen()

virtual void captureScreen ( std::function< void(const unsigned char *, int, int)>  callback)
pure virtual

Get a screen snapshot.

Parameters
callbackA callback to deal with screen snapshot image.

Implemented in CommandBufferMTL, and CommandBufferGL.

◆ setStencilReferenceValue() [1/2]

void setStencilReferenceValue ( unsigned int  value)

Update both front and back stencil reference value.

Parameters
valueSpecifies stencil reference value.

◆ setStencilReferenceValue() [2/2]

void setStencilReferenceValue ( unsigned int  frontRef,
unsigned int  backRef 
)

Update stencil reference value.

Parameters
frontRefSpecifies front stencil reference value.
backRefSpecifies back stencil reference value.

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