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

VertexBuffer is an abstraction of low level openGL Vertex Buffer Object. More...

#include <CCVertexIndexBuffer.h>

Inheritance diagram for VertexBuffer:
Ref

Public Member Functions

int getSizePerVertex () const
 Get the size in bytes of one vertex. More...
 
int getVertexNumber () const
 Get the number of vertices. More...
 
bool updateVertices (const void *verts, int count, int begin)
 Update all or part of vertice data, if the range specified exceeds the vertex buffer, it will be clipped. More...
 
local updateVertices ( local verts, local count, local begin)
 Update all or part of vertice data, if the range specified exceeds the vertex buffer, it will be clipped. More...
 
int getSize () const
 Get the size of the vertex array in bytes, equals getSizePerVertex() * getVertexNumber(). More...
 
GLuint getVBO () const
 Get the internal openGL handle. 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 VertexBuffercreate (int sizePerVertex, int vertexNumber, GLenum usage=GL_STATIC_DRAW)
 Create an instance of VertexBuffer. More...
 
local create ( local sizePerVertex, local vertexNumber, local GL_STATIC_DRAW)
 Create an instance of VertexBuffer. 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

 VertexBuffer ()
 Constructor. More...
 
virtual ~VertexBuffer ()
 Destructor. More...
 
bool init (int sizePerVertex, int vertexNumber, GLenum usage=GL_STATIC_DRAW)
 Init the storage of vertex buffer. More...
 
void recreateVBO () const
 Event handler for foreground. More...
 
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 
 Ref ()
 Constructor. More...
 

Protected Attributes

EventListenerCustom_recreateVBOEventListener
 Event listener for foreground. More...
 
GLuint _vbo
 Internal handle for openGL. More...
 
int _sizePerVertex
 Size in bytes for one vertex. More...
 
int _vertexNumber
 Number of vertices. More...
 
std::vector< unsigned char > _shadowCopy
 Buffer used for shadow copy. More...
 
local _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

VertexBuffer is an abstraction of low level openGL Vertex Buffer Object.

It is used to save an array of vertices.

Constructor & Destructor Documentation

VertexBuffer ( )
protected

Constructor.

local VertexBuffer ( )
protected

Constructor.

virtual ~VertexBuffer ( )
protectedvirtual

Destructor.

local ~VertexBuffer ( )
protectedvirtual

Destructor.

Member Function Documentation

static VertexBuffer* create ( int  sizePerVertex,
int  vertexNumber,
GLenum  usage = GL_STATIC_DRAW 
)
static

Create an instance of VertexBuffer.

Parameters
sizePerVertexSize in bytes of one vertex.
vertexNumberThe number of vertex.
usageA hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
local create ( local  sizePerVertex,
local  vertexNumber,
local  usage = GL_STATIC_DRAW 
)
static

Create an instance of VertexBuffer.

Parameters
sizePerVertexSize in bytes of one vertex.
vertexNumberThe number of vertex.
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 getSize ( ) const

Get the size of the vertex array in bytes, equals getSizePerVertex() * getVertexNumber().

local getSize ( )

Get the size of the vertex array in bytes, equals getSizePerVertex() * getVertexNumber().

int getSizePerVertex ( ) const

Get the size in bytes of one vertex.

local getSizePerVertex ( )

Get the size in bytes of one vertex.

GLuint getVBO ( ) const

Get the internal openGL handle.

local getVBO ( )

Get the internal openGL handle.

int getVertexNumber ( ) const

Get the number of vertices.

local getVertexNumber ( )

Get the number of vertices.

bool init ( int  sizePerVertex,
int  vertexNumber,
GLenum  usage = GL_STATIC_DRAW 
)
protected

Init the storage of vertex buffer.

Parameters
sizePerVertexSize in bytes of one vertex.
vertexNumberThe number of vertex.
usageA hint to indicate whether the vertexBuffer are updated frequently or not to let GL optimise it.
local init ( local  sizePerVertex,
local  vertexNumber,
local  usage = GL_STATIC_DRAW 
)
protected

Init the storage of vertex buffer.

Parameters
sizePerVertexSize in bytes of one vertex.
vertexNumberThe number of vertex.
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 updateVertices ( const void *  verts,
int  count,
int  begin 
)

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

Parameters
vertsThe pointer of the vertex data.
countThe number of vertices to update.
beginThe first vertex to update.
local updateVertices ( local  verts,
local  count,
local  begin 
)

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

Parameters
vertsThe pointer of the vertex data.
countThe number of vertices to update.
beginThe first vertex 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.

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.

int _sizePerVertex
protected

Size in bytes for one vertex.

local _sizePerVertex
protected

Size in bytes for one vertex.

GLenum _usage
protected

Hint for optimisation in GL.

local _usage
protected

Hint for optimisation in GL.

GLuint _vbo
mutableprotected

Internal handle for openGL.

local _vbo
mutableprotected

Internal handle for openGL.

int _vertexNumber
protected

Number of vertices.

local _vertexNumber
protected

Number of vertices.


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