Class IntIndexArray
java.lang.Object
gaiasky.util.gdx.mesh.IntIndexArray
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, IntIndexData
-
Constructor Summary
ConstructorsConstructorDescriptionIntIndexArray(int maxIndices) Creates a new IntIndexArray to be used with vertex arrays. -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()Binds this IntIndexArray for rendering with glDrawElements.voiddispose()Disposes this IntIndexArray and all its associated OpenGL resources.Returns the underlying IntBuffer.intintvoidInvalidates the IntIndexArray so a new OpenGL buffer handle is created.voidsetIndices(int[] indices, int offset, int count) Sets the indices of this IntIndexArray, discarding the old indices.voidsetIndices(IntBuffer indices) Copies the specified indices to the indices of this IntIndexBufferObject, discarding the old indices.voidunbind()Unbinds this IntIndexArray.voidupdateIndices(int targetOffset, int[] indices, int offset, int count) Update (a portion of) the indices.
-
Constructor Details
-
IntIndexArray
public IntIndexArray(int maxIndices) Creates a new IntIndexArray to be used with vertex arrays.- Parameters:
maxIndices- the maximum number of indices this buffer can hold
-
-
Method Details
-
getNumIndices
public int getNumIndices()- Specified by:
getNumIndicesin interfaceIntIndexData- Returns:
- the number of indices currently stored in this buffer
-
getNumMaxIndices
public int getNumMaxIndices()- Specified by:
getNumMaxIndicesin interfaceIntIndexData- Returns:
- the maximum number of indices this IntIndexArray can store.
-
setIndices
public void setIndices(int[] indices, int offset, int count) Sets the indices of this IntIndexArray, discarding the old indices. The count must equal the number of indices to be copied to this IntIndexArray.
This can be called in between calls to
bind()andunbind(). The index data will be updated instantly.- Specified by:
setIndicesin interfaceIntIndexData- Parameters:
indices- the vertex dataoffset- the offset to start copying the data fromcount- the number of ints to copy
-
setIndices
Description copied from interface:IntIndexDataCopies 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:
setIndicesin interfaceIntIndexData- Parameters:
indices- the index data to copy
-
updateIndices
public void updateIndices(int targetOffset, int[] indices, int offset, int count) Description copied from interface:IntIndexDataUpdate (a portion of) the indices.- Specified by:
updateIndicesin 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
Returns the underlying IntBuffer. If you modify the buffer contents they will be uploaded on the call to
bind(). If you need immediate uploading usesetIndices(int[], int, int).- Specified by:
getBufferin interfaceIntIndexData- Returns:
- the underlying int buffer.
-
bind
public void bind()Binds this IntIndexArray for rendering with glDrawElements.- Specified by:
bindin interfaceIntIndexData
-
unbind
-
invalidate
public void invalidate()Invalidates the IntIndexArray so a new OpenGL buffer handle is created. Use this in case of a context loss.- Specified by:
invalidatein interfaceIntIndexData
-
dispose
public void dispose()Disposes this IntIndexArray and all its associated OpenGL resources.- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Specified by:
disposein interfaceIntIndexData
-