MVertexBuffer Class Reference


Detailed Description

Vertex buffer for use with MGeometry.

This class represents a vertex buffer with attributes described by the descriptor member.

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

When creating a vertex 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

const MVertexBufferDescriptor descriptor () const
  Get the the buffer descriptor.
void *  resourceHandle () const
  Gets a graphics device dependent handle to a vertex buffer.
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

Member Function Documentation

const MVertexBufferDescriptor & descriptor ( ) const

Get the the buffer descriptor.

Returns:
The buffer descriptor
Examples:
cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.
void * resourceHandle ( ) const

Gets a graphics device dependent handle to a vertex buffer.

For OpenGL the return value is a pointer to an OpenGL identifier (GLuint) to an vertex buffer containing the data. Buffers can be set via the OpenGL API for drawing purposes. (e.g. using glBindBuffer).

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 vertex data
Examples:
cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.
void * acquire ( unsigned int  size )

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 * descriptor.dataTypeSize() * descriptor.dimension()) bytes. The memory for the buffer is managed internally.

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 )

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]

Returns the name of this class.

Returns:
The name of this class.

MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer
MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer MVertexBuffer