Class VertexArray
- java.lang.Object
-
- gaia.cu9.ari.gaiaorbit.util.gdx.mesh.VertexArray
-
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,IntVertexData
public class VertexArray extends java.lang.Object implements IntVertexData
Convenience class for working with OpenGL vertex arrays. It interleaves all data in the order you specified in the constructor via
VertexAttribute
.This class is not compatible with OpenGL 3+ core profiles. For this
VertexBufferObject
s are needed.
-
-
Constructor Summary
Constructors Constructor Description VertexArray(int numVertices, com.badlogic.gdx.graphics.VertexAttribute... attributes)
Constructs a new interleaved VertexArrayVertexArray(int numVertices, com.badlogic.gdx.graphics.VertexAttributes attributes)
Constructs a new interleaved VertexArray
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(ExtShaderProgram shader)
Binds this VertexData for rendering via glDrawArrays or glDrawElements.void
bind(ExtShaderProgram shader, int[] locations)
Binds this VertexData for rendering via glDrawArrays or glDrawElements.void
dispose()
Disposes this VertexData and all its associated OpenGL resources.com.badlogic.gdx.graphics.VertexAttributes
getAttributes()
java.nio.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
getNumMaxVertices()
int
getNumVertices()
void
invalidate()
Invalidates the VertexData if applicable.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 Detail
-
VertexArray
public VertexArray(int numVertices, com.badlogic.gdx.graphics.VertexAttribute... attributes)
Constructs a new interleaved VertexArray- Parameters:
numVertices
- the maximum number of verticesattributes
- theVertexAttribute
s
-
VertexArray
public VertexArray(int numVertices, com.badlogic.gdx.graphics.VertexAttributes attributes)
Constructs a new interleaved VertexArray- Parameters:
numVertices
- the maximum number of verticesattributes
- theVertexAttributes
-
-
Method Detail
-
dispose
public void dispose()
Description copied from interface:IntVertexData
Disposes this VertexData and all its associated OpenGL resources.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Specified by:
dispose
in interfaceIntVertexData
-
getBuffer
public java.nio.FloatBuffer 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.
-
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
-
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
-
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
vertices
- the vertex datasourceOffset
- the offset to start copying the data fromcount
- the number of floats to copy
-
bind
public void bind(ExtShaderProgram shader)
Description copied from interface:IntVertexData
Binds this VertexData for rendering via glDrawArrays or glDrawElements.- Specified by:
bind
in interfaceIntVertexData
-
bind
public void bind(ExtShaderProgram shader, int[] locations)
Description copied from interface:IntVertexData
Binds this VertexData for rendering via glDrawArrays or glDrawElements.- Specified by:
bind
in interfaceIntVertexData
locations
- array containing the attribute locations.
-
unbind
public void unbind(ExtShaderProgram shader)
Unbinds this VertexBufferObject.- Specified by:
unbind
in interfaceIntVertexData
- Parameters:
shader
- the shader
-
unbind
public void unbind(ExtShaderProgram shader, int[] locations)
Description copied from interface:IntVertexData
Unbinds this VertexData.- Specified by:
unbind
in interfaceIntVertexData
locations
- array containing the attribute locations.
-
getAttributes
public com.badlogic.gdx.graphics.VertexAttributes getAttributes()
- Specified by:
getAttributes
in interfaceIntVertexData
- Returns:
- the
VertexAttributes
as specified during construction.
-
invalidate
public void invalidate()
Description copied from interface:IntVertexData
Invalidates the VertexData if applicable. Use this in case of a context loss.- Specified by:
invalidate
in interfaceIntVertexData
-
-