Class IndexBuffer
java.lang.Object
com.codename1.gpu.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.-
Constructor Summary
ConstructorsConstructorDescriptionIndexBuffer(int indexCount) Allocates an index buffer with room forindexCountindices. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the dirty flag.short[]getData()Returns the backing short array.Returns the opaque backend GPU handle, or null if not yet uploaded.intReturns the number of indices this buffer holds.booleanisDirty()Returns true if the buffer has pending changes.voidsetData(int[] src) Copiessrcinto the backing array and marks the buffer dirty.voidsetDirty()Marks the buffer as needing re-upload to the GPU before the next draw.voidStores the opaque backend GPU handle.
-
Constructor Details
-
IndexBuffer
public IndexBuffer(int indexCount) Allocates an index buffer with room for
indexCountindices. Prefer creating buffers throughGraphicsDevice.createIndexBuffer(int)so the GPU handle is tracked by the device.Parameters
indexCount: 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
srcinto the backing array and marks the buffer dirty. Each int must fit in an unsigned 16 bit range.Parameters
src: 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
Returns the opaque backend GPU handle, or null if not yet uploaded. Intended for backend use. -
setHandle
Stores the opaque backend GPU handle. Intended for backend use.
Parameters
handle: the backend specific GPU resource handle
-