Package gaiasky.util.gdx.mesh
Class VertexBufferObjectInstanced
java.lang.Object
gaiasky.util.gdx.mesh.VertexBufferObjectInstanced
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,IntVertexData
-
Constructor Summary
ConstructorDescriptionVertexBufferObjectInstanced
(boolean isStatic, int numGlobal, com.badlogic.gdx.graphics.VertexAttributes globalAttributes, int numInstance, com.badlogic.gdx.graphics.VertexAttributes instanceAttributes) Constructs a new interleaved VertexBufferObjectWithVAO. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(ExtShaderProgram shader) Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElementsvoid
bind
(ExtShaderProgram shader, int[] locations) Binds this VertexData for rendering via glDrawArrays or glDrawElements.void
dispose()
Disposes of all resources this VertexBufferObject uses.com.badlogic.gdx.graphics.VertexAttributes
Returns the underlying FloatBuffer and marks it as dirty, causing the buffer contents to be uploaded on the next call to bind.com.badlogic.gdx.graphics.VertexAttributes
int
int
void
Invalidates the VertexBufferObject so a new OpenGL buffer handle is created.void
setInstance
(float[] vertices, int offset, int count) void
setVertices
(float[] vertices, int offset, int count) Sets the vertices of this VertexData, discarding the old vertex data.void
unbind
(ExtShaderProgram shader) Unbinds this VertexBufferObject.void
unbind
(ExtShaderProgram shader, int[] locations) Unbinds this VertexData.void
updateVertices
(int targetOffset, float[] vertices, int sourceOffset, int count) Update (a portion of) the vertices.
-
Constructor Details
-
VertexBufferObjectInstanced
public VertexBufferObjectInstanced(boolean isStatic, int numGlobal, com.badlogic.gdx.graphics.VertexAttributes globalAttributes, int numInstance, com.badlogic.gdx.graphics.VertexAttributes instanceAttributes) Constructs a new interleaved VertexBufferObjectWithVAO.- Parameters:
isStatic
- whether the vertex data is static.numGlobal
- the maximum number of verticesglobalAttributes
- theVertexAttributes
.
-
-
Method Details
-
getAttributes
public com.badlogic.gdx.graphics.VertexAttributes getAttributes()- Specified by:
getAttributes
in interfaceIntVertexData
- Returns:
- the
VertexAttributes
as specified during construction.
-
getInstanceAttributes
public com.badlogic.gdx.graphics.VertexAttributes getInstanceAttributes() -
getNumVertices
public int getNumVertices()- Specified by:
getNumVertices
in interfaceIntVertexData
- Returns:
- the number of vertices this VertexData stores
-
getNumMaxVertices
public int getNumMaxVertices()- Specified by:
getNumMaxVertices
in interfaceIntVertexData
- Returns:
- the number of vertices this VertedData can store
-
getBuffer
Description copied from interface:IntVertexData
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 useIntVertexData.setVertices(float[], int, int)
; Any modifications made to the Buffer *after* the call to bind will not automatically be uploaded.- Specified by:
getBuffer
in interfaceIntVertexData
- Returns:
- the underlying FloatBuffer holding the vertex data.
-
setVertices
public void setVertices(float[] vertices, int offset, int count) Description copied from interface:IntVertexData
Sets the vertices of this VertexData, 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 viaVertexAttributes
.This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
- Specified by:
setVertices
in interfaceIntVertexData
- Parameters:
vertices
- the vertex dataoffset
- the offset to start copying the data fromcount
- the number of floats to copy
-
setInstance
public void setInstance(float[] vertices, int offset, int count) -
updateVertices
public void updateVertices(int targetOffset, float[] vertices, int sourceOffset, int count) Description copied from interface:IntVertexData
Update (a portion of) the vertices. Does not resize the backing buffer.- Specified by:
updateVertices
in interfaceIntVertexData
- Parameters:
vertices
- the vertex datasourceOffset
- the offset to start copying the data fromcount
- the number of floats to copy
-
bind
Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements- Specified by:
bind
in interfaceIntVertexData
- Parameters:
shader
- the shader
-
bind
Description copied from interface:IntVertexData
Binds this VertexData for rendering via glDrawArrays or glDrawElements.- Specified by:
bind
in interfaceIntVertexData
- Parameters:
locations
- array containing the attribute locations.
-
unbind
Unbinds this VertexBufferObject.- Specified by:
unbind
in interfaceIntVertexData
- Parameters:
shader
- the shader
-
unbind
Description copied from interface:IntVertexData
Unbinds this VertexData.- Specified by:
unbind
in interfaceIntVertexData
- Parameters:
locations
- array containing the attribute locations.
-
invalidate
public void invalidate()Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss.- Specified by:
invalidate
in interfaceIntVertexData
-
dispose
public void dispose()Disposes of all resources this VertexBufferObject uses.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Specified by:
dispose
in interfaceIntVertexData
-