public class InstanceBufferObject extends Object implements InstanceData
VertexBufferObject class.
Sets the glVertexAttribDivisor for every VertexAttribute automatically.| Constructor and Description |
|---|
InstanceBufferObject(boolean isStatic,
int numVertices,
VertexAttribute... attributes) |
InstanceBufferObject(boolean isStatic,
int numVertices,
VertexAttributes instanceAttributes) |
| 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 |
getNumInstances() |
int |
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 InstanceBufferObject(boolean isStatic,
int numVertices,
VertexAttribute... attributes)
public InstanceBufferObject(boolean isStatic,
int numVertices,
VertexAttributes instanceAttributes)
public VertexAttributes getAttributes()
getAttributes in interface InstanceDataVertexAttributes as specified during construction.public int getNumInstances()
getNumInstances in interface InstanceDatapublic int 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 DisposableCopyright © 2021. All rights reserved.