public interface InstanceData extends Disposable
InstanceBufferObject
or a
InstanceBufferObjectSubData
. Both require Open GL 3.3+.Modifier and Type | Method and Description |
---|---|
void |
bind(ShaderProgram shader)
Binds this InstanceData for rendering via glDrawArraysInstanced or glDrawElementsInstanced.
|
void |
bind(ShaderProgram shader,
int[] locations)
Binds this InstanceData for rendering via glDrawArraysInstanced or glDrawElementsInstanced.
|
void |
dispose()
Disposes this InstanceData and all its associated OpenGL resources.
|
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 InstanceData if applicable.
|
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 InstanceData.
|
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.
|
int getNumInstances()
int getNumMaxInstances()
VertexAttributes getAttributes()
VertexAttributes
as specified during construction.void setInstanceData(float[] data, int offset, int count)
VertexAttributes
.
This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
data
- the instance dataoffset
- the offset to start copying the data fromcount
- the number of floats to copyvoid updateInstanceData(int targetOffset, float[] data, int sourceOffset, int count)
data
- the instance datasourceOffset
- the offset to start copying the data fromcount
- the number of floats to copyvoid setInstanceData(FloatBuffer data, int count)
VertexAttributes
.
This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
data
- the instance datacount
- the number of floats to copyvoid updateInstanceData(int targetOffset, FloatBuffer data, int sourceOffset, int count)
data
- the vertex datasourceOffset
- the offset to start copying the data fromcount
- the number of floats to copyFloatBuffer getBuffer()
setInstanceData(float[], int, int)
; Any modifications made to the Buffer
*after* the call to bind will not automatically be uploaded.void bind(ShaderProgram shader)
void bind(ShaderProgram shader, int[] locations)
locations
- array containing the attribute locations.void unbind(ShaderProgram shader)
void unbind(ShaderProgram shader, int[] locations)
locations
- array containing the attribute locations.void invalidate()
void dispose()
dispose
in interface Disposable
Copyright © 2020. All rights reserved.