com.badlogic.gdx.graphics.glutils
Class IndexArray

java.lang.Object
  extended by com.badlogic.gdx.graphics.glutils.IndexArray
All Implemented Interfaces:
IndexData, Disposable

public class IndexArray
extends Object
implements IndexData


Constructor Summary
IndexArray(int maxIndices)
          Creates a new IndexArray to be used with vertex arrays.
 
Method Summary
 void bind()
          Binds this IndexArray for rendering with glDrawElements.
 void dispose()
          Disposes this IndexArray and all its associated OpenGL resources.
 ShortBuffer getBuffer()
           Returns the underlying ShortBuffer.
 int getNumIndices()
           
 int getNumMaxIndices()
           
 void invalidate()
          Invalidates the IndexArray so a new OpenGL buffer handle is created.
 void setIndices(short[] indices, int offset, int count)
           Sets the indices of this IndexArray, discarding the old indices.
 void unbind()
          Unbinds this IndexArray.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexArray

public IndexArray(int maxIndices)
Creates a new IndexArray 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 interface IndexData
Returns:
the number of indices currently stored in this buffer

getNumMaxIndices

public int getNumMaxIndices()
Specified by:
getNumMaxIndices in interface IndexData
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() and unbind(). The index data will be updated instantly.

Specified by:
setIndices in interface IndexData
Parameters:
indices - the vertex data
offset - the offset to start copying the data from
count - the number of shorts to copy

getBuffer

public 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).

Specified by:
getBuffer in interface IndexData
Returns:
the underlying short buffer.

bind

public void bind()
Binds this IndexArray for rendering with glDrawElements.

Specified by:
bind in interface IndexData

unbind

public void unbind()
Unbinds this IndexArray.

Specified by:
unbind in interface IndexData

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:
invalidate in interface IndexData

dispose

public void dispose()
Disposes this IndexArray and all its associated OpenGL resources.

Specified by:
dispose in interface IndexData
Specified by:
dispose in interface Disposable


Copyright © 2013. All Rights Reserved.