Class IndexArray
- java.lang.Object
-
- com.badlogic.gdx.graphics.glutils.IndexArray
-
- All Implemented Interfaces:
IndexData,Disposable
public class IndexArray extends java.lang.Object implements IndexData
-
-
Constructor Summary
Constructors Constructor Description IndexArray(int maxIndices)Creates a new IndexArray to be used with vertex arrays.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidbind()Binds this IndexArray for rendering with glDrawElements.voiddispose()Disposes this IndexArray and all its associated OpenGL resources.java.nio.ShortBuffergetBuffer()Deprecated.usegetBuffer(boolean)insteadjava.nio.ShortBuffergetBuffer(boolean forWriting)Returns the underlying ShortBuffer for reading or writing.intgetNumIndices()intgetNumMaxIndices()voidinvalidate()Invalidates the IndexArray so a new OpenGL buffer handle is created.voidsetIndices(short[] indices, int offset, int count)Sets the indices of this IndexArray, discarding the old indices.voidsetIndices(java.nio.ShortBuffer indices)Copies the specified indices to the indices of this IndexBufferObject, discarding the old indices.voidunbind()Unbinds this IndexArray.voidupdateIndices(int targetOffset, short[] indices, int offset, int count)Update (a portion of) the indices.
-
-
-
Method Detail
-
getNumIndices
public int getNumIndices()
- Specified by:
getNumIndicesin interfaceIndexData- Returns:
- the number of indices currently stored in this buffer
-
getNumMaxIndices
public int getNumMaxIndices()
- Specified by:
getNumMaxIndicesin interfaceIndexData- Returns:
- the maximum number of indices this IndexArray can store.
-
setIndices
public void setIndices(short[] indices, int offset, int count)Sets the indices of this IndexArray, discarding the old indices. The count must equal the number of indices to be copied to this IndexArray.
This can be called in between calls to
bind()andunbind(). The index data will be updated instantly.- Specified by:
setIndicesin interfaceIndexData- Parameters:
indices- the vertex dataoffset- the offset to start copying the data fromcount- the number of shorts to copy
-
setIndices
public void setIndices(java.nio.ShortBuffer indices)
Description copied from interface:IndexDataCopies 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.- Specified by:
setIndicesin interfaceIndexData- Parameters:
indices- the index data to copy
-
updateIndices
public void updateIndices(int targetOffset, short[] indices, int offset, int count)Description copied from interface:IndexDataUpdate (a portion of) the indices.- Specified by:
updateIndicesin interfaceIndexData- Parameters:
targetOffset- offset in indices bufferindices- the index dataoffset- the offset to start copying the data fromcount- the number of shorts to copy
-
getBuffer
@Deprecated public java.nio.ShortBuffer getBuffer()
Deprecated.usegetBuffer(boolean)insteadDescription copied from interface:IndexDataReturns the underlying ShortBuffer. If you modify the buffer contents they will be uploaded on the next call to
IndexData.bind(). If you need immediate uploading useIndexData.setIndices(short[], int, int).
-
getBuffer
public java.nio.ShortBuffer getBuffer(boolean forWriting)
Description copied from interface:IndexDataReturns the underlying ShortBuffer for reading or writing.- Specified by:
getBufferin interfaceIndexData- Parameters:
forWriting- when true, the underlying buffer will be uploaded on the next call toIndexData.bind(). If you need immediate uploading useIndexData.setIndices(short[], int, int).- Returns:
- the underlying short buffer.
-
bind
public void bind()
Binds this IndexArray for rendering with glDrawElements.
-
invalidate
public void invalidate()
Invalidates the IndexArray so a new OpenGL buffer handle is created. Use this in case of a context loss.- Specified by:
invalidatein interfaceIndexData
-
dispose
public void dispose()
Disposes this IndexArray and all its associated OpenGL resources.- Specified by:
disposein interfaceDisposable- Specified by:
disposein interfaceIndexData
-
-