Class IntIndexBufferObjectSubData
- java.lang.Object
-
- gaia.cu9.ari.gaiaorbit.util.gdx.mesh.IntIndexBufferObjectSubData
-
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,IntIndexData
public class IntIndexBufferObjectSubData extends java.lang.Object implements IntIndexData
This implementation uses 32-bit integer indices instead of 16-bit shorts
IntIndexBufferObject 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()
orunbind()
in this case but rather usegetBuffer()
to use the buffer directly with glDrawElements. You must also create the IntIndexBufferObject 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
Constructors Constructor Description IntIndexBufferObjectSubData(boolean isStatic, int maxIndices)
Creates a new IntIndexBufferObject.IntIndexBufferObjectSubData(int maxIndices)
Creates a new IntIndexBufferObject to be used with vertex arrays.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind()
Binds this IntIndexBufferObject for rendering with glDrawElements.void
dispose()
Disposes this IntIndexBufferObject and all its associated OpenGL resources.java.nio.IntBuffer
getBuffer()
Returns the underlying IntBuffer.int
getNumIndices()
int
getNumMaxIndices()
void
invalidate()
Invalidates the IntIndexBufferObject so a new OpenGL buffer handle is created.void
setIndices(int[] indices, int offset, int count)
Sets the indices of this IntIndexBufferObject, discarding the old indices.void
setIndices(java.nio.IntBuffer indices)
Copies the specified indices to the indices of this IntIndexBufferObject, discarding the old indices.void
unbind()
Unbinds this IntIndexBufferObject.void
updateIndices(int targetOffset, int[] indices, int offset, int count)
Update (a portion of) the indices.
-
-
-
Constructor Detail
-
IntIndexBufferObjectSubData
public IntIndexBufferObjectSubData(boolean isStatic, int maxIndices)
Creates a new IntIndexBufferObject.- Parameters:
isStatic
- whether the index buffer is staticmaxIndices
- the maximum number of indices this buffer can hold
-
IntIndexBufferObjectSubData
public IntIndexBufferObjectSubData(int maxIndices)
Creates a new IntIndexBufferObject to be used with vertex arrays.- Parameters:
maxIndices
- the maximum number of indices this buffer can hold
-
-
Method Detail
-
getNumIndices
public int getNumIndices()
- Specified by:
getNumIndices
in interfaceIntIndexData
- Returns:
- the number of indices currently stored in this buffer
-
getNumMaxIndices
public int getNumMaxIndices()
- Specified by:
getNumMaxIndices
in interfaceIntIndexData
- Returns:
- the maximum number of indices this IntIndexBufferObject can store.
-
setIndices
public void setIndices(int[] indices, int offset, int count)
Sets the indices of this IntIndexBufferObject, discarding the old indices. The count must equal the number of indices to be copied to this IntIndexBufferObject.
This can be called in between calls to
bind()
andunbind()
. The index data will be updated instantly.- Specified by:
setIndices
in interfaceIntIndexData
- Parameters:
indices
- the vertex dataoffset
- the offset to start copying the data fromcount
- the number of floats to copy
-
setIndices
public void setIndices(java.nio.IntBuffer indices)
Description copied from interface:IntIndexData
Copies the specified indices to the indices of this IntIndexBufferObject, 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 toIntIndexData.bind()
andIntIndexData.unbind()
. The index data will be updated instantly.- Specified by:
setIndices
in interfaceIntIndexData
- Parameters:
indices
- the index data to copy
-
updateIndices
public void updateIndices(int targetOffset, int[] indices, int offset, int count)
Description copied from interface:IntIndexData
Update (a portion of) the indices.- Specified by:
updateIndices
in interfaceIntIndexData
- Parameters:
targetOffset
- offset in indices bufferindices
- the index dataoffset
- the offset to start copying the data fromcount
- the number of ints to copy
-
getBuffer
public java.nio.IntBuffer getBuffer()
Returns the underlying IntBuffer. If you modify the buffer contents they wil be uploaded on the call to
bind()
. If you need immediate uploading usesetIndices(int[], int, int)
.- Specified by:
getBuffer
in interfaceIntIndexData
- Returns:
- the underlying int buffer.
-
bind
public void bind()
Binds this IntIndexBufferObject for rendering with glDrawElements.- Specified by:
bind
in interfaceIntIndexData
-
unbind
public void unbind()
Unbinds this IntIndexBufferObject.- Specified by:
unbind
in interfaceIntIndexData
-
invalidate
public void invalidate()
Invalidates the IntIndexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss.- Specified by:
invalidate
in interfaceIntIndexData
-
dispose
public void dispose()
Disposes this IntIndexBufferObject and all its associated OpenGL resources.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Specified by:
dispose
in interfaceIntIndexData
-
-