- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Friends

# MIndexBuffer Class Reference
OpenMayaRender - API module for rendering

This reference page is linked to from the following overview topics: データ クラス(Data Classes).

Search for all occurrences

## Detailed Description

Index buffer for use with MGeometry.

This class represents an index buffer with a specific data type.

When retrieving an index buffer for binding to custom shaders (MPxShaderOverride), resourceHandle() may be called to get the device dependent handle to the index buffer on the GPU.

When creating an index buffer to supply geometric data to Maya (MPxGeometryOverride), acquire() may be called to get a pointer to a block of memory to fill with said data. Once filled, commit() must be called to apply the data to the buffer.

Examples:

  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

`#include <MHWGeometry.h>`

List of all members.

## Public Member Functions
| MIndexBuffer (MGeometry::DataType type)
| Constructor.
| ~MIndexBuffer ()
| Destructor.
MGeometry::DataType | dataType () const
| Get the data type of the buffer.
unsigned int | size () const
| Get the size of the buffer in units of dataType().
void * | resourceHandle () const
| Gets a graphics device dependent handle to the vertex indexing data.
void * | acquire (unsigned int size)
| Get a pointer to memory for the buffer.
void | commit (void *buffer)
| Commit the data stored in the memory given by acquire() to the buffer.
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.
## Friends
class | MGeometry Search for all occurrences

## Constructor & Destructor Documentation

MIndexBuffer | ( | MGeometry::DataType | type | ) |

Constructor.

Parameters:

  [in] | type | The data type for the index buffer

~MIndexBuffer | ( |  | ) |

Destructor.

Note that it is an error to delete MIndexBuffer objects that are owned by or in use by an MGeometry object. Such actions may cause instability.

## Member Function Documentation

MGeometry::DataType dataType | ( |  | ) | const

Search for all occurrences

Get the data type of the buffer.

Returns:
  The data type of the buffer

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

unsigned int size | ( |  | ) | const

Search for all occurrences

Get the size of the buffer in units of dataType().

Returns 0 if unallocated.

Returns:
  Size of the buffer

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

void * resourceHandle | ( |  | ) | const

Search for all occurrences

Gets a graphics device dependent handle to the vertex indexing data.

For OpenGL the return value is a pointer to an OpenGL identifier (GLuint) for a vertex buffer containing the indexing data. (e.g. using glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handle)).

The index buffer identifier can be used to perform drawing of vertex buffer data identified by handles returned from MVertexBuffer::hwBuffer().

An example setup could be:

1. For each vertex buffer query the handle.
2. For each data handle set it up using the vertex buffer information (mapped to the draw API).
3. Query the index handle.
4. Use the index handle and index buffer information (mapped to the draw API) to perform drawing.

A NULL pointer will be returned if the graphics device dependent handle is not yet available.

If the pointer is not NULL, the value is only guaranteed to exist during the current draw. The value should never be cached or modified.

Returns:
  A pointer to device dependent indexing data.

Examples:
  cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

void * acquire | ( | unsigned int | size | ) |

Search for all occurrences

Get a pointer to memory for the buffer.

This method is meant to be used in MPxGeometryOverride::populateGeometry() in order to provide data to Maya for drawing the associated object. The size of the buffer returned will be (size * sizeof(dataType())) bytes. The memory for the buffer is managed internally.

Note that not all data types are currently supported for index buffers. If the data type for this buffer is not supported this method will return NULL.

Parameters:

  [in] | size | The size of the buffer to acquire

Returns:
  A pointer to memory for the buffer, or NULL on failure

void commit | ( | void * | buffer | ) |

Search for all occurrences

Commit the data stored in the memory given by acquire() to the buffer.

If this method is not called, the acquired buffer will not be used in drawing. The pointer must be the same pointer returned from acquire().

Parameters:

  [in] | buffer | A pointer to the data.

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer
MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer MIndexBuffer