public class InstanceBufferObjectSubData extends Object implements InstanceData
VertexBufferObjectSubData
class.
Sets the glVertexAttribDivisor for every VertexAttribute
automatically.Constructor and Description |
---|
InstanceBufferObjectSubData(boolean isStatic,
int numInstances,
VertexAttribute... instanceAttributes)
Constructs a new interleaved InstanceBufferObject.
|
InstanceBufferObjectSubData(boolean isStatic,
int numInstances,
VertexAttributes instanceAttributes)
Constructs a new interleaved InstanceBufferObject.
|
Modifier and Type | Method and Description |
---|---|
void |
bind(ShaderProgram shader)
Binds this InstanceBufferObject for rendering via glDrawArraysInstanced or glDrawElementsInstanced
|
void |
bind(ShaderProgram shader,
int[] locations)
Binds this InstanceData for rendering via glDrawArraysInstanced or glDrawElementsInstanced.
|
void |
dispose()
Disposes of all resources this InstanceBufferObject uses.
|
VertexAttributes |
getAttributes() |
FloatBuffer |
getBuffer()
Returns the underlying FloatBuffer and marks it as dirty, causing the buffer contents to be uploaded on the next call to
bind.
|
int |
getBufferHandle()
Returns the InstanceBufferObject handle
|
int |
getNumInstances()
Effectively returns
getNumInstances() . |
int |
getNumMaxInstances()
Effectively returns
getNumMaxInstances() . |
void |
invalidate()
Invalidates the InstanceBufferObject so a new OpenGL buffer handle is created.
|
void |
setInstanceData(float[] data,
int offset,
int count)
Sets the vertices of this InstanceData, discarding the old vertex data.
|
void |
setInstanceData(FloatBuffer data,
int count)
Sets the vertices of this InstanceData, discarding the old vertex data.
|
void |
unbind(ShaderProgram shader)
Unbinds this InstanceBufferObject.
|
void |
unbind(ShaderProgram shader,
int[] locations)
Unbinds this InstanceData.
|
void |
updateInstanceData(int targetOffset,
float[] data,
int sourceOffset,
int count)
Update (a portion of) the vertices.
|
void |
updateInstanceData(int targetOffset,
FloatBuffer data,
int sourceOffset,
int count)
Update (a portion of) the vertices.
|
public InstanceBufferObjectSubData(boolean isStatic, int numInstances, VertexAttribute... instanceAttributes)
isStatic
- whether the vertex data is static.numInstances
- the maximum number of verticesinstanceAttributes
- the VertexAttributes
.public InstanceBufferObjectSubData(boolean isStatic, int numInstances, VertexAttributes instanceAttributes)
isStatic
- whether the vertex data is static.numInstances
- the maximum number of verticesinstanceAttributes
- the VertexAttribute
s.public VertexAttributes getAttributes()
getAttributes
in interface InstanceData
VertexAttributes
as specified during construction.public int getNumInstances()
getNumInstances()
.getNumInstances
in interface InstanceData
public int getNumMaxInstances()
getNumMaxInstances()
.getNumMaxInstances
in interface InstanceData
public FloatBuffer getBuffer()
InstanceData
InstanceData.setInstanceData(float[], int, int)
; Any modifications made to the Buffer
*after* the call to bind will not automatically be uploaded.getBuffer
in interface InstanceData
public void setInstanceData(float[] data, int offset, int count)
InstanceData
VertexAttributes
.
This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
setInstanceData
in interface InstanceData
data
- the instance dataoffset
- the offset to start copying the data fromcount
- the number of floats to copypublic void setInstanceData(FloatBuffer data, int count)
InstanceData
VertexAttributes
.
This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
setInstanceData
in interface InstanceData
data
- the instance datacount
- the number of floats to copypublic void updateInstanceData(int targetOffset, float[] data, int sourceOffset, int count)
InstanceData
updateInstanceData
in interface InstanceData
data
- the instance datasourceOffset
- the offset to start copying the data fromcount
- the number of floats to copypublic void updateInstanceData(int targetOffset, FloatBuffer data, int sourceOffset, int count)
InstanceData
updateInstanceData
in interface InstanceData
data
- the vertex datasourceOffset
- the offset to start copying the data fromcount
- the number of floats to copypublic void bind(ShaderProgram shader)
bind
in interface InstanceData
shader
- the shaderpublic void bind(ShaderProgram shader, int[] locations)
InstanceData
bind
in interface InstanceData
locations
- array containing the attribute locations.public void unbind(ShaderProgram shader)
unbind
in interface InstanceData
shader
- the shaderpublic void unbind(ShaderProgram shader, int[] locations)
InstanceData
unbind
in interface InstanceData
locations
- array containing the attribute locations.public void invalidate()
invalidate
in interface InstanceData
public void dispose()
dispose
in interface InstanceData
dispose
in interface Disposable
public int getBufferHandle()
Copyright © 2020. All rights reserved.