public final class IndexBuffer

  1. Object
  2. IndexBuffer
Holds the element indices used to assemble primitives from a VertexBuffer. Indices are stored as 16 bit unsigned values (short) which is the portable baseline supported on every backend including WebGL 1. A buffer therefore addresses at most 65536 distinct vertices.

Constructors

public IndexBuffer(int indexCount)Allocates an index buffer with room for indexCount indices.

Methods

public int getIndexCount()Returns the number of indices this buffer holds.
public short[] getData()Returns the backing short array.
public void setData(int[] src)Copies src into the backing array and marks the buffer dirty.
public void setDirty()Marks the buffer as needing re-upload to the GPU before the next draw.
public boolean isDirty()Returns true if the buffer has pending changes.
public void clearDirty()Clears the dirty flag.
public Object getHandle()Returns the opaque backend GPU handle, or null if not yet uploaded.
public void setHandle(Object handle)Stores the opaque backend GPU handle.

Inherited methods

Constructor details

IndexBuffer

public IndexBuffer(int indexCount)
Allocates an index buffer with room for indexCount indices. Prefer creating buffers through GraphicsDevice.createIndexBuffer(int) so the GPU handle is tracked by the device.

Parameters

indexCount int
the number of indices the buffer can hold

Method details

getIndexCount

public int getIndexCount()
Returns the number of indices this buffer holds.

getData

public short[] getData()
Returns the backing short array. Index values are treated as unsigned.

setData

public void setData(int[] src)
Copies src into the backing array and marks the buffer dirty. Each int must fit in an unsigned 16 bit range.

Parameters

src int[]
the index values to store

setDirty

public void setDirty()
Marks the buffer as needing re-upload to the GPU before the next draw.

isDirty

public boolean isDirty()
Returns true if the buffer has pending changes. Intended for backend use.

clearDirty

public void clearDirty()
Clears the dirty flag. Intended for backend use after an upload.

getHandle

public Object getHandle()
Returns the opaque backend GPU handle, or null if not yet uploaded. Intended for backend use.

setHandle

public void setHandle(Object handle)
Stores the opaque backend GPU handle. Intended for backend use.

Parameters

handle Object
the backend specific GPU resource handle