APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics.glutils

public Class IndexBufferObjectSubData

extends Object
implements IndexData
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.graphics.glutils.IndexData, com.badlogic.gdx.utils.Disposable
Imports
java.nio.Buffer, .ByteBuffer, .ShortBuffer, com.badlogic.gdx.Gdx, com.badlogic.gdx.graphics.GL20, com.badlogic.gdx.utils.BufferUtils, .GdxRuntimeException

IndexBufferObject 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() or unbind() in this case but rather use getBuffer() 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

Author
mzechner

Field Summary

Modifier and TypeField and Description
pack-priv final ShortBuffer
pack-priv int
pack-priv final ByteBuffer
pack-priv boolean
pack-priv final boolean
pack-priv boolean
pack-priv final int

Constructor Summary

AccessConstructor and Description
public
IndexBufferObjectSubData(boolean
whether the index buffer is static
isStatic
,
int
the maximum number of indices this buffer can hold
maxIndices
)

Creates a new IndexBufferObject.

public
IndexBufferObjectSubData(int
the maximum number of indices this buffer can hold
maxIndices
)

Creates a new IndexBufferObject to be used with vertex arrays.

Method Summary

Modifier and TypeMethod and Description
public void
bind()

Implements com.badlogic.gdx.graphics.glutils.IndexData.bind.

Binds this IndexBufferObject for rendering with glDrawElements.

private int
public void
dispose()

Implements com.badlogic.gdx.graphics.glutils.IndexData.dispose.

Disposes this IndexBufferObject and all its associated OpenGL resources.

public ShortBuffer
getBuffer()

Implements com.badlogic.gdx.graphics.glutils.IndexData.getBuffer.

Deprecated use getBuffer(boolean) instead

Returns the underlying ShortBuffer.

public ShortBuffer
getBuffer(boolean forWriting)

Implements com.badlogic.gdx.graphics.glutils.IndexData.getBuffer.

Returns the underlying ShortBuffer for reading or writing.

public int
getNumIndices()

Implements com.badlogic.gdx.graphics.glutils.IndexData.getNumIndices.

Returns: the number of indices currently stored in this buffer

public int
getNumMaxIndices()

Implements com.badlogic.gdx.graphics.glutils.IndexData.getNumMaxIndices.

Returns: the maximum number of indices this IndexBufferObject can store.

public void
invalidate()

Implements com.badlogic.gdx.graphics.glutils.IndexData.invalidate.

Invalidates the IndexBufferObject so a new OpenGL buffer handle is created.

public void
setIndices(short[]
the vertex data
indices
,
int
the offset to start copying the data from
offset
,
int
the number of floats to copy
count
)

Implements com.badlogic.gdx.graphics.glutils.IndexData.setIndices.

Sets the indices of this IndexBufferObject, discarding the old indices.

public void
setIndices(ShortBuffer indices)

Implements com.badlogic.gdx.graphics.glutils.IndexData.setIndices.

Copies the specified indices to the indices of this IndexBufferObject, discarding the old indices.

public void
unbind()

Implements com.badlogic.gdx.graphics.glutils.IndexData.unbind.

Unbinds this IndexBufferObject.

public void
updateIndices(int targetOffset, short[] indices, int offset, int count)

Implements com.badlogic.gdx.graphics.glutils.IndexData.updateIndices.

Update (a portion of) the indices.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
pack-priv final ShortBuffer buffer
bufferHandleback to summary
pack-priv int bufferHandle
byteBufferback to summary
pack-priv final ByteBuffer byteBuffer
isBoundback to summary
pack-priv boolean isBound
isDirectback to summary
pack-priv final boolean isDirect
isDirtyback to summary
pack-priv boolean isDirty
usageback to summary
pack-priv final int usage

Constructor Detail

IndexBufferObjectSubDataback to summary
public IndexBufferObjectSubData(boolean isStatic, int maxIndices)

Creates a new IndexBufferObject.

Parameters
isStatic:boolean

whether the index buffer is static

maxIndices:int

the maximum number of indices this buffer can hold

IndexBufferObjectSubDataback to summary
public IndexBufferObjectSubData(int maxIndices)

Creates a new IndexBufferObject to be used with vertex arrays.

Parameters
maxIndices:int

the maximum number of indices this buffer can hold

Method Detail

bindback to summary
public void bind()

Implements com.badlogic.gdx.graphics.glutils.IndexData.bind.

Binds this IndexBufferObject for rendering with glDrawElements.

createBufferObjectback to summary
private int createBufferObject()
disposeback to summary
public void dispose()

Implements com.badlogic.gdx.graphics.glutils.IndexData.dispose.

Disposes this IndexBufferObject and all its associated OpenGL resources.

getBufferback to summary
public ShortBuffer getBuffer()

Implements com.badlogic.gdx.graphics.glutils.IndexData.getBuffer.

Doc from com.badlogic.gdx.graphics.glutils.IndexData.getBuffer.

Deprecated

use getBuffer(boolean) instead

Returns the underlying ShortBuffer. If you modify the buffer contents they will be uploaded on the next call to bind(). If you need immediate uploading use setIndices(short[], int, int).

Annotations
@Override
@Deprecated
getBufferback to summary
public ShortBuffer getBuffer(boolean forWriting)

Implements com.badlogic.gdx.graphics.glutils.IndexData.getBuffer.

Doc from com.badlogic.gdx.graphics.glutils.IndexData.getBuffer.

Returns the underlying ShortBuffer for reading or writing.

Annotations
@Override
getNumIndicesback to summary
public int getNumIndices()

Implements com.badlogic.gdx.graphics.glutils.IndexData.getNumIndices.

Returns:int

the number of indices currently stored in this buffer

getNumMaxIndicesback to summary
public int getNumMaxIndices()

Implements com.badlogic.gdx.graphics.glutils.IndexData.getNumMaxIndices.

Returns:int

the maximum number of indices this IndexBufferObject can store.

invalidateback to summary
public void invalidate()

Implements com.badlogic.gdx.graphics.glutils.IndexData.invalidate.

Invalidates the IndexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss.

setIndicesback to summary
public void setIndices(short[] indices, int offset, int count)

Implements com.badlogic.gdx.graphics.glutils.IndexData.setIndices.

Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be copied to this IndexBufferObject.

This can be called in between calls to bind() and unbind(). The index data will be updated instantly.

Parameters
indices:short[]

the vertex data

offset:int

the offset to start copying the data from

count:int

the number of floats to copy

setIndicesback to summary
public void setIndices(ShortBuffer indices)

Implements com.badlogic.gdx.graphics.glutils.IndexData.setIndices.

Doc from com.badlogic.gdx.graphics.glutils.IndexData.setIndices.

Copies the specified indices to the indices of this IndexBufferObject, discarding the old indices. Copying start at the current ShortBuffer#position() of the specified buffer and copied the ShortBuffer#remaining() amount of indices. This can be called in between calls to bind() and unbind(). The index data will be updated instantly.

unbindback to summary
public void unbind()

Implements com.badlogic.gdx.graphics.glutils.IndexData.unbind.

Unbinds this IndexBufferObject.

updateIndicesback to summary
public void updateIndices(int targetOffset, short[] indices, int offset, int count)

Implements com.badlogic.gdx.graphics.glutils.IndexData.updateIndices.

Doc from com.badlogic.gdx.graphics.glutils.IndexData.updateIndices.

Update (a portion of) the indices.

Annotations
@Override