API Reference

Class List

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

destroyFrees resources associated with this index buffer.
getFormatReturns the data format of the specified index buffer.
getNumIndicesReturns the number of indices stored in the specified index buffer.
lockGives access to the block of memory that stores the buffer's indices.
unlockSignals 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])

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

graphicsDevicepc.GraphicsDeviceThe graphics device used to manage this index buffer.
formatNumberThe type of each index to be stored in the index buffer (see pc.INDEXFORMAT_*).
numIndicesNumberThe number of indices to be stored in the index buffer.
usageNumberThe usage type of the vertex buffer (see pc.BUFFER_*).

Methods

destroy()

Frees resources associated with this index buffer.

getFormat()

Returns the data format of the specified index buffer.

Returns

Number The data format of the specified index buffer (see pc.INDEXFORMAT_*).

getNumIndices()

Returns the number of indices stored in the specified index buffer.

Returns

Number The number of indices stored in the specified index buffer.

lock()

Gives access to the block of memory that stores the buffer's indices.

Returns

ArrayBuffer A 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.