public class IndexBufferObjectSubData extends java.lang.Object implements IndexData
IndexBufferObject wraps OpenGL's index buffer functionality to be used in conjunction with VBOs.
You can also use this to store indices for vertex arrays. Do not call bind() or unbind() in this case but
rather use getBuffer() to use the buffer directly with glDrawElements. You must also create the IndexBufferObject with
the second constructor and specify isDirect as true as glDrawElements in conjunction with vertex arrays needs direct buffers.
VertexBufferObjects must be disposed via the dispose() method when no longer needed
| Constructor and Description |
|---|
IndexBufferObjectSubData(boolean isStatic,
int maxIndices)
Creates a new IndexBufferObject.
|
IndexBufferObjectSubData(int maxIndices)
Creates a new IndexBufferObject to be used with vertex arrays.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bind()
Binds this IndexBufferObject for rendering with glDrawElements.
|
void |
dispose()
Disposes this IndexBufferObject and all its associated OpenGL resources.
|
java.nio.ShortBuffer |
getBuffer()
Returns the underlying ShortBuffer.
|
int |
getNumIndices() |
int |
getNumMaxIndices() |
void |
invalidate()
Invalidates the IndexBufferObject so a new OpenGL buffer handle is created.
|
void |
setIndices(short[] indices,
int offset,
int count)
Sets the indices of this IndexBufferObject, discarding the old indices.
|
void |
setIndices(java.nio.ShortBuffer indices)
Copies the specified indices to the indices of this IndexBufferObject, discarding the old indices.
|
void |
unbind()
Unbinds this IndexBufferObject.
|
void |
updateIndices(int targetOffset,
short[] indices,
int offset,
int count)
Update (a portion of) the indices.
|
public IndexBufferObjectSubData(boolean isStatic,
int maxIndices)
isStatic - whether the index buffer is staticmaxIndices - the maximum number of indices this buffer can holdpublic IndexBufferObjectSubData(int maxIndices)
maxIndices - the maximum number of indices this buffer can holdpublic int getNumIndices()
getNumIndices in interface IndexDatapublic int getNumMaxIndices()
getNumMaxIndices in interface IndexDatapublic void setIndices(short[] indices,
int offset,
int count)
Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be copied to this IndexBufferObject.
This can be called in between calls to bind() and unbind(). The index data will be updated instantly.
setIndices in interface IndexDataindices - the vertex dataoffset - the offset to start copying the data fromcount - the number of floats to copypublic void setIndices(java.nio.ShortBuffer indices)
IndexDataBuffer.position() of the specified buffer and copied the Buffer.remaining() amount of
indices. This can be called in between calls to IndexData.bind() and IndexData.unbind(). The index data will be updated
instantly.setIndices in interface IndexDataindices - the index data to copypublic void updateIndices(int targetOffset,
short[] indices,
int offset,
int count)
IndexDataupdateIndices in interface IndexDatatargetOffset - offset in indices bufferindices - the index dataoffset - the offset to start copying the data fromcount - the number of shorts to copypublic java.nio.ShortBuffer getBuffer()
Returns the underlying ShortBuffer. If you modify the buffer contents they wil be uploaded on the call to bind().
If you need immediate uploading use setIndices(short[], int, int).
public void bind()
public void unbind()
public void invalidate()
invalidate in interface IndexDatapublic void dispose()
dispose in interface IndexDatadispose in interface Disposable