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 VertexAttributes.public VertexAttributes getAttributes()
getAttributes in interface InstanceDataVertexAttributes as specified during construction.public int getNumInstances()
getNumInstances().getNumInstances in interface InstanceDatapublic int getNumMaxInstances()
getNumMaxInstances().getNumMaxInstances in interface InstanceDatapublic FloatBuffer getBuffer()
InstanceDataInstanceData.setInstanceData(float[], int, int); Any modifications made to the Buffer
*after* the call to bind will not automatically be uploaded.getBuffer in interface InstanceDatapublic void setInstanceData(float[] data,
int offset,
int count)
InstanceDataVertexAttributes.
This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
setInstanceData in interface InstanceDatadata - the instance dataoffset - the offset to start copying the data fromcount - the number of floats to copypublic void setInstanceData(FloatBuffer data, int count)
InstanceDataVertexAttributes.
This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
setInstanceData in interface InstanceDatadata - the instance datacount - the number of floats to copypublic void updateInstanceData(int targetOffset,
float[] data,
int sourceOffset,
int count)
InstanceDataupdateInstanceData in interface InstanceDatadata - 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)
InstanceDataupdateInstanceData in interface InstanceDatadata - the vertex datasourceOffset - the offset to start copying the data fromcount - the number of floats to copypublic void bind(ShaderProgram shader)
bind in interface InstanceDatashader - the shaderpublic void bind(ShaderProgram shader, int[] locations)
InstanceDatabind in interface InstanceDatalocations - array containing the attribute locations.public void unbind(ShaderProgram shader)
unbind in interface InstanceDatashader - the shaderpublic void unbind(ShaderProgram shader, int[] locations)
InstanceDataunbind in interface InstanceDatalocations - array containing the attribute locations.public void invalidate()
invalidate in interface InstanceDatapublic void dispose()
dispose in interface InstanceDatadispose in interface Disposablepublic int getBufferHandle()
Copyright © 2021. All rights reserved.