cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IndexBuffer Class Reference

IndexBuffer is an abstraction of low level openGL Buffer Object. More...

#include <CCVertexIndexBuffer.h>

Inheritance diagram for IndexBuffer:
Ref

Public Types

enum  IndexType { INDEX_TYPE_SHORT_16, INDEX_TYPE_UINT_32 }
 Enum for the type of index, short indices and int indices could be used. More...
 

Public Member Functions

IndexType getType () const
 Getter for type of indices. More...
 
int getSizePerIndex () const
 Get the size in bytes for one index, will be 2 for INDEX_TYPE_SHORT_16 and 4 for INDEX_TYPE_UINT_32. More...
 
int getIndexNumber () const
 Get the number of indices. More...
 
bool updateIndices (const void *indices, int count, int begin)
 Update all or part of indices data, if the range specified exceeds the vertex buffer, it will be clipped. More...
 
local updateIndices ( local indices, local count, local begin)
 Update all or part of indices data, if the range specified exceeds the vertex buffer, it will be clipped. More...
 
int getSize () const
 Get the size in bytes of the array of indices. More...
 
GLuint getVBO () const
 Get the openGL handle for index buffer. More...
 
- 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...
 

Static Public Member Functions

static IndexBuffercreate (IndexType type, int number, GLenum usage=GL_STATIC_DRAW)
 Create an instance of IndexBuffer. More...
 
static bool isShadowCopyEnabled ()
 Static getter for shadowCopy. More...
 
local isShadowCopyEnabled ()
 Static getter for shadowCopy. More...
 
static void enableShadowCopy (bool enabled)
 Static setter for shadowCopy. More...
 
local enableShadowCopy ( local enabled)
 Static setter for shadowCopy. More...
 

Protected Member Functions

 IndexBuffer ()
 Constructor. More...
 
virtual ~IndexBuffer ()
 Destructor. More...
 
local ~IndexBuffer ()
 Destructor. More...
 
bool init (IndexType type, int number, GLenum usage=GL_STATIC_DRAW)
 Init the storageof IndexBuffer. More...
 
local init ( local type, local number, local GL_STATIC_DRAW)
 Init the storageof IndexBuffer. More...
 
void recreateVBO () const
 Event handler for foreground. More...
 
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 
 Ref ()
 Constructor. More...
 

Protected Attributes

GLuint _vbo
 Handle for openGL. More...
 
IndexType _type
 Type for index. More...
 
int _indexNumber
 Number of indices. More...
 
EventListenerCustom_recreateVBOEventListener
 Event listener for foreground. More...
 
local _recreateVBOEventListener
 Event listener for foreground. More...
 
std::vector< unsigned char > _shadowCopy
 Buffer used for shadow copy. More...
 
GLenum _usage
 Hint for optimisation in GL. More...
 
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 
local _referenceCount
 count of references More...
 

Static Protected Attributes

static bool _enableShadowCopy
 Static member to indicate that use _shadowCopy or not. More...
 
local _enableShadowCopy
 Static member to indicate that use _shadowCopy or not. More...
 

Detailed Description

IndexBuffer is an abstraction of low level openGL Buffer Object.

It used to save an array of indices.

Member Enumeration Documentation

enum IndexType
strong

Enum for the type of index, short indices and int indices could be used.

Enumerator
INDEX_TYPE_SHORT_16 

Short index will be used.

INDEX_TYPE_UINT_32 

Int index will be used.

local IndexType
strong

Enum for the type of index, short indices and int indices could be used.

Enumerator
INDEX_TYPE_SHORT_16 

Short index will be used.

INDEX_TYPE_UINT_32 

Int index will be used.

Constructor & Destructor Documentation

IndexBuffer ( )
protected

Constructor.

local IndexBuffer ( )
protected

Constructor.

virtual ~IndexBuffer ( )
protectedvirtual

Destructor.

local ~IndexBuffer ( )
protectedvirtual

Destructor.

Member Function Documentation

static IndexBuffer* create ( IndexType  type,
int  number,
GLenum  usage = GL_STATIC_DRAW 
)
static

Create an instance of IndexBuffer.

Parameters
typetype of index.
numberThe number of indices.
usageA hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
local create ( local  type,
local  number,
local  usage = GL_STATIC_DRAW 
)
static

Create an instance of IndexBuffer.

Parameters
typetype of index.
numberThe number of indices.
usageA hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
static void enableShadowCopy ( bool  enabled)
inlinestatic

Static setter for shadowCopy.

local enableShadowCopy ( local  enabled)
inlinestatic

Static setter for shadowCopy.

int getIndexNumber ( ) const

Get the number of indices.

local getIndexNumber ( )

Get the number of indices.

int getSize ( ) const

Get the size in bytes of the array of indices.

local getSize ( )

Get the size in bytes of the array of indices.

int getSizePerIndex ( ) const

Get the size in bytes for one index, will be 2 for INDEX_TYPE_SHORT_16 and 4 for INDEX_TYPE_UINT_32.

local getSizePerIndex ( )

Get the size in bytes for one index, will be 2 for INDEX_TYPE_SHORT_16 and 4 for INDEX_TYPE_UINT_32.

IndexType getType ( ) const

Getter for type of indices.

local getType ( )

Getter for type of indices.

GLuint getVBO ( ) const

Get the openGL handle for index buffer.

local getVBO ( )

Get the openGL handle for index buffer.

bool init ( IndexType  type,
int  number,
GLenum  usage = GL_STATIC_DRAW 
)
protected

Init the storageof IndexBuffer.

Parameters
typetype of index.
numberThe number of indices.
usageA hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
local init ( local  type,
local  number,
local  usage = GL_STATIC_DRAW 
)
protected

Init the storageof IndexBuffer.

Parameters
typetype of index.
numberThe number of indices.
usageA hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
static bool isShadowCopyEnabled ( )
inlinestatic

Static getter for shadowCopy.

local isShadowCopyEnabled ( )
inlinestatic

Static getter for shadowCopy.

void recreateVBO ( ) const
protected

Event handler for foreground.

local recreateVBO ( )
protected

Event handler for foreground.

bool updateIndices ( const void *  indices,
int  count,
int  begin 
)

Update all or part of indices data, if the range specified exceeds the vertex buffer, it will be clipped.

Parameters
indicesThe pointer of the index data.
countThe number of indices to update.
beginThe start index to update.
local updateIndices ( local  indices,
local  count,
local  begin 
)

Update all or part of indices data, if the range specified exceeds the vertex buffer, it will be clipped.

Parameters
indicesThe pointer of the index data.
countThe number of indices to update.
beginThe start index to update.

Member Data Documentation

bool _enableShadowCopy
staticprotected

Static member to indicate that use _shadowCopy or not.

local _enableShadowCopy
staticprotected

Static member to indicate that use _shadowCopy or not.

int _indexNumber
protected

Number of indices.

local _indexNumber
protected

Number of indices.

EventListenerCustom*
_recreateVBOEventListener
protected

Event listener for foreground.

local _recreateVBOEventListener
protected

Event listener for foreground.

std::vector<unsigned char>
_shadowCopy
protected

Buffer used for shadow copy.

local _shadowCopy
protected

Buffer used for shadow copy.

IndexType _type
protected

Type for index.

local _type
protected

Type for index.

GLenum _usage
protected

Hint for optimisation in GL.

local _usage
protected

Hint for optimisation in GL.

GLuint _vbo
mutableprotected

Handle for openGL.

local _vbo
mutableprotected

Handle for openGL.


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