pc.IndexBuffer
An index buffer is the mechanism via which the application specifies primitive index data to the graphics hardware.
// Create an index buffer holding 3 16-bit indices
// The buffer is marked as static, hinting that the buffer will never be modified
var indexBuffer = new pc.IndexBuffer(graphicsDevice, pc.INDEXFORMAT_UINT16, 3, pc.BUFFER_STATIC);
Summary
Methods
| destroy | Frees resources associated with this index buffer. |
| getFormat | Returns the data format of the specified index buffer. |
| getNumIndices | Returns the number of indices stored in the specified index buffer. |
| lock | Gives access to the block of memory that stores the buffer's indices. |
| unlock | Signals that the block of memory returned by a call to the lock function is ready to be given to the graphics hardware. |
Details
Constructor
IndexBuffer(graphicsDevice, format, numIndices, [usage], [initialData])
Creates a new index buffer.
// Create an index buffer holding 3 16-bit indices
// The buffer is marked as static, hinting that the buffer will never be modified
var indexBuffer = new pc.IndexBuffer(graphicsDevice, pc.INDEXFORMAT_UINT16, 3, pc.BUFFER_STATIC);
Parameters
| graphicsDevice | pc.GraphicsDevice | The graphics device used to manage this index buffer. |
| format | number | The type of each index to be stored in the index buffer (see pc.INDEXFORMAT_*). |
| numIndices | number | The number of indices to be stored in the index buffer. |
| usage | number | The usage type of the vertex buffer (see pc.BUFFER_*). |
| initialData | ArrayBuffer | Initial data. |
Methods
destroy()
Frees resources associated with this index buffer.
getFormat()
Returns the data format of the specified index buffer.
Returns
numberThe data format of the specified index buffer (see pc.INDEXFORMAT_*).
getNumIndices()
Returns the number of indices stored in the specified index buffer.
Returns
numberThe number of indices stored in the specified index buffer.
lock()
Gives access to the block of memory that stores the buffer's indices.
Returns
ArrayBufferA contiguous block of memory where index data can be written to.
unlock()
Signals that the block of memory returned by a call to the lock function is ready to be given to the graphics hardware. Only unlocked index buffers can be set on the currently active device.