[ < ] [ Up ] [ > ]               [Top] [Contents] [Index] [ ? ]

5.7.1 The IndexData class

This class summarises the information required to use a set of indexes to render geometry. It's members are as follows:
indexStart
The first index used by this piece of geometry; this can be useful for sharing a single index buffer among several geometry pieces.
indexCount
The number of indexes used by this particular renderable.
indexBuffer
The index buffer which is used to source the indexes.

Creating an Index Buffer

Index buffers are created using See section 5.1 The Hardware Buffer Manager just like vertex buffers, here's how:
 
HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().
	createIndexBuffer(
		HardwareIndexBuffer::IT_16BIT, // type of index
		numIndexes, // number of indexes
		HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage
		false); // no shadow buffer	
Once again, notice that the return type is a class rather than a pointer; this is reference counted so that the buffer is automatically destroyed when no more references are made to it. The parameters to the index buffer creation are:
indexType
There are 2 types of index; 16-bit and 32-bit. They both perform the same way, except that the latter can address larger vertex buffers. If your buffer includes more than 65526 vertices, then you will need to use 32-bit indexes. Note that you should only use 32-bit indexes when you need to, since they incur more overhead than 16-bit vertices, and are not supported on some older hardware.
numIndexes
The number of indexes in the buffer. As with vertex buffers, you should consider whether you can use a shared index buffer which is used by multiple pieces of geometry, since there can be performance advantages to switching index buffers less often.
usage
This tells the system how you intend to use the buffer. See section 5.2 Buffer Usage
useShadowBuffer
Tells the system whether you want this buffer backed by a system-memory copy. See section 5.3 Shadow Buffers


[ < ] [ Up ] [ > ]               [Top] [Contents] [Index] [ ? ]

This document was generated by Steve Streeting on , 12 2006 using texi2html