Class IndexBufferObject
- All Implemented Interfaces:
IndexData
,Disposable
In IndexBufferObject wraps OpenGL's index buffer functionality to be used in conjunction with VBOs. This class can be seamlessly used with OpenGL ES 1.x and 2.0.
Uses indirect Buffers on Android 1.5/1.6 to fix GC invocation due to leaking PlatformAddress instances.
You can also use this to store indices for vertex arrays. Do not call bind()
or unbind()
in this case but
rather use buffer()
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 Summary
ConstructorDescriptionIndexBufferObject
(boolean isStatic, int maxIndices) Creates a new IndexBufferObject.IndexBufferObject
(int maxIndices) Creates a new static IndexBufferObject to be used with vertex arrays. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind()
Binds this IndexBufferObject for rendering with glDrawElements.buffer()
Returns the underlying ShortBuffer.void
dispose()
Disposes this IndexBufferObject and all its associated OpenGL resources.int
max()
void
set
(short[] indices, int offset, int count) Sets the indices of this IndexBufferObject, discarding the old indices.void
set
(ShortBuffer indices) Copies the specified indices to the indices of this IndexBufferObject, discarding the old indices.int
size()
void
unbind()
Unbinds this IndexBufferObject.void
update
(int targetOffset, short[] indices, int offset, int count) Update (a portion of) the indices.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface arc.util.Disposable
isDisposed
-
Constructor Details
-
IndexBufferObject
public IndexBufferObject(int maxIndices) Creates a new static IndexBufferObject to be used with vertex arrays.- Parameters:
maxIndices
- the maximum number of indices this buffer can hold
-
IndexBufferObject
public IndexBufferObject(boolean isStatic, int maxIndices) Creates a new IndexBufferObject.- Parameters:
isStatic
- whether the index buffer is staticmaxIndices
- the maximum number of indices this buffer can hold
-
-
Method Details
-
size
public int size() -
max
public int max() -
set
public void set(short[] indices, int offset, int count) -
set
Description copied from interface:IndexData
Copies the specified indices to the indices of this IndexBufferObject, discarding the old indices. Copying start at the currentBuffer.position()
of the specified buffer and copied theBuffer.remaining()
amount of indices. This can be called in between calls toIndexData.bind()
andIndexData.unbind()
. The index data will be updated instantly. -
update
public void update(int targetOffset, short[] indices, int offset, int count) Description copied from interface:IndexData
Update (a portion of) the indices. -
buffer
Returns the underlying ShortBuffer. If you modify the buffer contents they wil be uploaded on the call to
bind()
. If you need immediate uploading useset(short[], int, int)
. -
bind
public void bind()Binds this IndexBufferObject for rendering with glDrawElements. -
unbind
public void unbind()Unbinds this IndexBufferObject. -
dispose
public void dispose()Disposes this IndexBufferObject and all its associated OpenGL resources.- Specified by:
dispose
in interfaceDisposable
- Specified by:
dispose
in interfaceIndexData
-