- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# cVBOMesh Class Reference

This class is a replacement for cMesh that uses vertex buffers for rendering. It allows for much faster rendering, but requires hardware support for VBO's and does not allow vertices to be moved around without re-initializing the VBO. More...

`#include <CVBOMesh.h>`

Inheritance diagram for cVBOMesh:

List of all members.

## Public Member Functions
| cVBOMesh (cWorld *a_world, const bool a_useVertexBuffers=true)
| Constructor of cVBOMesh.
virtual | ~cVBOMesh ()
| Destructor of cVBOMesh.
virtual void | onDisplayReset (const bool a_affectChildren=true)
| Called when the context is deleted, allows this class to re-build VBO's.
virtual void | finalize (const bool a_affectChildren=true)
| Called to transfer all mesh data to a vertex buffer.
virtual void | unfinalize (const bool a_affectChildren=true)
| Called to disable the vertex buffer.
virtual cMesh * | createMesh () const
| This lets me act as a "mesh factory", producing new meshes like myself.
virtual void | renderMesh (const int a_renderMode=0)
| Actually draws the mesh.
virtual void | renderFrom (cMesh *a_share)
| Used to initialize "rendering by proxy"; from now on I'll use a_share to draw my mesh.
virtual cMesh * | getRenderingProxy ()
| Requests the mesh object I'm currently using for rendering; returns 0 if I'm rendering my own mesh.
virtual void | setBackgroundBlend (bool enable, bool includeChildren=false)
| Enables "background blend" mode.
## Public Attributes
bool | m_usePolygonOffset
| Should GL polygon offset be used for this mesh?
## Protected Member Functions
void | clean_vertex_buffers ()
| Clean up.
## Protected Attributes
bool | m_backgroundBlend
| Enables a custom blend-with-background rendering mode.
cMesh * | m_renderingProxy
| If I'm using another mesh for rendering, this is him...
bool | m_renderFromVBO
| Should we _try_ to render from vertex buffers (we may still fail if this is true)?
GLuint | m_vertexBuffers [NUM_VBO_FLAGS]
| The actual vertex buffers.
unsigned int | m_numTriangles
| How many triangles are stored in our vertex buffers.
int | m_useLongIndices
| Are we using int*'s (rather than short*'s) for our indices?
int | m_maxVertex
| What is the maximum vertex index we might have to render?

## Detailed Description

This class is a replacement for cMesh that uses vertex buffers for rendering. It allows for much faster rendering, but requires hardware support for VBO's and does not allow vertices to be moved around without re-initializing the VBO.

This class also supports "rendering by proxy", i.e. using another mesh object to actually do the rendering. This is useful if you have multiple objects represented by the same mesh and want to maintain separate transforms for them without having separate vertex arrays/buffers loaded, and without reading them in from disk separately.

This class also allows a couple of other OpenGL effects, including "background blending", in which an object can be rendered through other opaque objects as if they were partially transparent, and polygon offsetting.

## Constructor & Destructor Documentation

cVBOMesh::cVBOMesh | ( | cWorld * | a_world,
|  | const bool | a_useVertexBuffers = `true` |
| ) |  |  |

Constructor of cVBOMesh.

Constructor of cVBOMesh

Parameters:

  | a_world | The parent CHAI world
  | a_useVertexBuffers | Pass 'false' to create a cVBOMesh that does not initially use vertex buffers. An explicit call to "finalize" will re-enable VBO's.

cVBOMesh::~cVBOMesh | ( |  | ) | `[virtual]`

Destructor of cVBOMesh.

Destructor of cVBOMesh

## Member Function Documentation

void cVBOMesh::onDisplayReset | ( | const bool | a_affectChildren = `true` | ) | `[virtual]`

Called when the context is deleted, allows this class to re-build VBO's.

Called when the context is deleted, allows this class to re-build VBO's. See cGenericObject::onDisplayReset

Parameters:

  | a_affectChildren | Should this call be passed recursively to my children?

Reimplemented from cMesh.

void cVBOMesh::finalize | ( | const bool | a_affectChildren = `true` | ) | `[virtual]`

Called to transfer all mesh data to a vertex buffer.

Finalize this mesh (indicates that vertices will not move around after this) (see cGenericObject::finalize). This is where all the vbo-related structures get created, and data is copied from the cMesh vertex and triangle arrays.

Parameters:

  | a_affectChildren | Should this call be passed recursively to my children?

Reimplemented from cGenericObject.

void cVBOMesh::unfinalize | ( | const bool | a_affectChildren = `true` | ) | `[virtual]`

Called to disable the vertex buffer.

Disable vertex buffers and behave like a typical cMesh.

Parameters:

  | a_affectChildren | Should this call be passed recursively to my children?

Reimplemented from cGenericObject.

void cVBOMesh::setBackgroundBlend | ( | bool | enable,
|  | bool | includeChildren = `false` |
| ) |  |  | `[virtual]`

Enables "background blend" mode.

Called to enable or disable "background blend mode", in which an object can be rendered through other opaque objects as if they were partially transparent.

Parameters:

  | enable | Should background-blend mode be enabled?
  | includeChildren | Should this call be passed recursively to my children?

void cVBOMesh::clean_vertex_buffers | ( |  | ) | `[protected]`

Clean up.

Clean up vertex buffer data.

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

- chai3d/src/scenegraph/CVBOMesh.h
- chai3d/src/scenegraph/CVBOMesh.cpp