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

public Class InstanceBufferObjectSubData

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

Modification of the VertexBufferObjectSubData class. Sets the glVertexAttribDivisor for every VertexAttribute automatically.
Author
mrdlink

Field Summary

Modifier and TypeField and Description
pack-priv final VertexAttributes
pack-priv final FloatBuffer
pack-priv int
pack-priv final ByteBuffer
pack-priv boolean
pack-priv final boolean
pack-priv boolean
pack-priv final boolean
pack-priv final int

Constructor Summary

AccessConstructor and Description
public
InstanceBufferObjectSubData(boolean
whether the vertex data is static.
isStatic
,
int
the maximum number of vertices
numInstances
,
VertexAttribute... instanceAttributes)

Constructs a new interleaved InstanceBufferObject.

public
InstanceBufferObjectSubData(boolean
whether the vertex data is static.
isStatic
,
int
the maximum number of vertices
numInstances
,
VertexAttributes instanceAttributes)

Constructs a new interleaved InstanceBufferObject.

Method Summary

Modifier and TypeMethod and Description
public void
bind(final ShaderProgram
the shader
shader
)

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

Binds this InstanceBufferObject for rendering via glDrawArraysInstanced or glDrawElementsInstanced

public void
bind(final ShaderProgram shader, final int[] locations)

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

Binds this InstanceData for rendering via glDrawArraysInstanced or glDrawElementsInstanced.

private void
private int
public void
dispose()

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

Disposes of all resources this InstanceBufferObject uses.

public VertexAttributes
public FloatBuffer
getBuffer()

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

Deprecated use getBuffer(boolean) instead

Returns the underlying FloatBuffer and marks it as dirty, causing the buffer contents to be uploaded on the next call to bind.

public FloatBuffer
getBuffer(boolean forWriting)

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

Returns the underlying FloatBuffer for reading or writing.

public int

Returns:

the InstanceBufferObject handle
getBufferHandle
()

Returns the InstanceBufferObject handle

public int

Returns:

number of instances in this buffer
getNumInstances
()

Implements com.badlogic.gdx.graphics.glutils.InstanceData.getNumInstances.

Effectively returns getNumInstances().

public int

Returns:

maximum number of instances in this buffer
getNumMaxInstances
()

Implements com.badlogic.gdx.graphics.glutils.InstanceData.getNumMaxInstances.

Effectively returns getNumMaxInstances().

public void
invalidate()

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

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

public void
setInstanceData(float[] data, int offset, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.setInstanceData.

Sets the vertices of this InstanceData, discarding the old vertex data.

public void
setInstanceData(FloatBuffer data, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.setInstanceData.

Sets the vertices of this InstanceData, discarding the old vertex data.

public void
unbind(final ShaderProgram
the shader
shader
)

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

Unbinds this InstanceBufferObject.

public void
unbind(final ShaderProgram shader, final int[] locations)

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

Unbinds this InstanceData.

public void
updateInstanceData(int targetOffset, float[] data, int sourceOffset, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.updateInstanceData.

Update (a portion of) the vertices.

public void
updateInstanceData(int targetOffset, FloatBuffer data, int sourceOffset, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.updateInstanceData.

Update (a portion of) the vertices.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
pack-priv final VertexAttributes attributes
bufferback to summary
pack-priv final FloatBuffer 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
isStaticback to summary
pack-priv final boolean isStatic
usageback to summary
pack-priv final int usage

Constructor Detail

InstanceBufferObjectSubDataback to summary
public InstanceBufferObjectSubData(boolean isStatic, int numInstances, VertexAttribute... instanceAttributes)

Constructs a new interleaved InstanceBufferObject.

Parameters
isStatic:boolean

whether the vertex data is static.

numInstances:int

the maximum number of vertices

instanceAttributes:VertexAttribute[]

the VertexAttributes.

InstanceBufferObjectSubDataback to summary
public InstanceBufferObjectSubData(boolean isStatic, int numInstances, VertexAttributes instanceAttributes)

Constructs a new interleaved InstanceBufferObject.

Parameters
isStatic:boolean

whether the vertex data is static.

numInstances:int

the maximum number of vertices

instanceAttributes:VertexAttributes

the VertexAttributes.

Method Detail

bindback to summary
public void bind(final ShaderProgram shader)

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

Binds this InstanceBufferObject for rendering via glDrawArraysInstanced or glDrawElementsInstanced

Parameters
shader:ShaderProgram

the shader

Annotations
@Override
bindback to summary
public void bind(final ShaderProgram shader, final int[] locations)

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

Doc from com.badlogic.gdx.graphics.glutils.InstanceData.bind.

Binds this InstanceData for rendering via glDrawArraysInstanced or glDrawElementsInstanced.

Annotations
@Override
bufferChangedback to summary
private void bufferChanged()
createBufferObjectback to summary
private int createBufferObject()
disposeback to summary
public void dispose()

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

Disposes of all resources this InstanceBufferObject uses.

Annotations
@Override
getAttributesback to summary
public VertexAttributes getAttributes()

Implements com.badlogic.gdx.graphics.glutils.InstanceData.getAttributes.

Annotations
@Override
getBufferback to summary
public FloatBuffer getBuffer()

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

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

Deprecated

use getBuffer(boolean) instead

Returns the underlying FloatBuffer and marks it as dirty, causing the buffer contents to be uploaded on the next call to bind. If you need immediate uploading use setInstanceData(float[], int, int); Any modifications made to the Buffer *after* the call to bind will not automatically be uploaded.

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

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

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

Returns the underlying FloatBuffer for reading or writing.

Annotations
@Override
getBufferHandleback to summary
public int getBufferHandle()

Returns the InstanceBufferObject handle

Returns:int

the InstanceBufferObject handle

getNumInstancesback to summary
public int getNumInstances()

Implements com.badlogic.gdx.graphics.glutils.InstanceData.getNumInstances.

Effectively returns getNumInstances().

Returns:int

number of instances in this buffer

Annotations
@Override
getNumMaxInstancesback to summary
public int getNumMaxInstances()

Implements com.badlogic.gdx.graphics.glutils.InstanceData.getNumMaxInstances.

Effectively returns getNumMaxInstances().

Returns:int

maximum number of instances in this buffer

Annotations
@Override
invalidateback to summary
public void invalidate()

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

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

setInstanceDataback to summary
public void setInstanceData(float[] data, int offset, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.setInstanceData.

Doc from com.badlogic.gdx.graphics.glutils.InstanceData.setInstanceData.

Sets the vertices of this InstanceData, discarding the old vertex data. The count must equal the number of floats per vertex times the number of vertices to be copied to this VertexData. The order of the vertex attributes must be the same as specified at construction time via VertexAttributes.

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

Annotations
@Override
setInstanceDataback to summary
public void setInstanceData(FloatBuffer data, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.setInstanceData.

Doc from com.badlogic.gdx.graphics.glutils.InstanceData.setInstanceData.

Sets the vertices of this InstanceData, discarding the old vertex data. The count must equal the number of floats per vertex times the number of vertices to be copied to this InstanceData. The order of the vertex attributes must be the same as specified at construction time via VertexAttributes.

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

Annotations
@Override
unbindback to summary
public void unbind(final ShaderProgram shader)

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

Unbinds this InstanceBufferObject.

Parameters
shader:ShaderProgram

the shader

Annotations
@Override
unbindback to summary
public void unbind(final ShaderProgram shader, final int[] locations)

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

Doc from com.badlogic.gdx.graphics.glutils.InstanceData.unbind.

Unbinds this InstanceData.

Annotations
@Override
updateInstanceDataback to summary
public void updateInstanceData(int targetOffset, float[] data, int sourceOffset, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.updateInstanceData.

Doc from com.badlogic.gdx.graphics.glutils.InstanceData.updateInstanceData.

Update (a portion of) the vertices. Does not resize the backing buffer.

Annotations
@Override
updateInstanceDataback to summary
public void updateInstanceData(int targetOffset, FloatBuffer data, int sourceOffset, int count)

Implements com.badlogic.gdx.graphics.glutils.InstanceData.updateInstanceData.

Doc from com.badlogic.gdx.graphics.glutils.InstanceData.updateInstanceData.

Update (a portion of) the vertices. Does not resize the backing buffer.

Annotations
@Override