APIdia Launch Partner
Top Description Methods
com.badlogic.gdx.graphics.glutils

public Interface VertexData

extends Disposable
Known Direct Implementers
com.badlogic.gdx.graphics.glutils.VertexArray, com.badlogic.gdx.graphics.glutils.VertexBufferObject, com.badlogic.gdx.graphics.glutils.VertexBufferObjectSubData, com.badlogic.gdx.graphics.glutils.VertexBufferObjectWithVAO
Imports
java.nio.FloatBuffer, com.badlogic.gdx.graphics.VertexAttributes, com.badlogic.gdx.utils.Disposable

A VertexData instance holds vertices for rendering with OpenGL. It is implemented as either a VertexArray or a VertexBufferObject. Only the later supports OpenGL ES 2.0.
Author
mzechner

Method Summary

Modifier and TypeMethod and Description
public void
bind(ShaderProgram shader)

Binds this VertexData for rendering via glDrawArrays or glDrawElements.

public void
bind(ShaderProgram shader, int[]
array containing the attribute locations.
locations
)

Binds this VertexData for rendering via glDrawArrays or glDrawElements.

public void
dispose()

Redeclares com.badlogic.gdx.utils.Disposable.dispose.

Disposes this VertexData and all its associated OpenGL resources.

public VertexAttributes
getAttributes()

Returns: the VertexAttributes as specified during construction.

public FloatBuffer

Returns:

the underlying FloatBuffer holding the vertex data.
getBuffer
()
Deprecated use getBuffer(boolean) instead.

Returns the underlying FloatBuffer and marks it as dirty, causing the buffer contents to be uploaded on the next call to bind.

public FloatBuffer

Returns:

the underlying FloatBuffer holding the vertex data.
getBuffer
(boolean
when true, the underlying buffer will be uploaded on the next call to bind. If you need immediate uploading use setVertices(float[], int, int).
forWriting
)

Returns the underlying FloatBuffer for reading or writing.

public int
getNumMaxVertices()

Returns: the number of vertices this VertedData can store

public int
getNumVertices()

Returns: the number of vertices this VertexData stores

public void
invalidate()

Invalidates the VertexData if applicable.

public void
setVertices(float[]
the vertex data
vertices
,
int
the offset to start copying the data from
offset
,
int
the number of floats to copy
count
)

Sets the vertices of this VertexData, discarding the old vertex data.

public void
unbind(ShaderProgram shader)

Unbinds this VertexData.

public void
unbind(ShaderProgram shader, int[]
array containing the attribute locations.
locations
)

Unbinds this VertexData.

public void
updateVertices(int targetOffset, float[]
the vertex data
vertices
,
int
the offset to start copying the data from
sourceOffset
,
int
the number of floats to copy
count
)

Update (a portion of) the vertices.

Method Detail

bindback to summary
public void bind(ShaderProgram shader)

Binds this VertexData for rendering via glDrawArrays or glDrawElements.

bindback to summary
public void bind(ShaderProgram shader, int[] locations)

Binds this VertexData for rendering via glDrawArrays or glDrawElements.

Parameters
locations:int[]

array containing the attribute locations.

disposeback to summary
public void dispose()

Redeclares com.badlogic.gdx.utils.Disposable.dispose.

Disposes this VertexData and all its associated OpenGL resources.

getAttributesback to summary
public VertexAttributes getAttributes()
Returns:VertexAttributes

the VertexAttributes as specified during construction.

getBufferback to summary
public FloatBuffer getBuffer()

Deprecated

use getBuffer(boolean) instead.

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 use setVertices(float[], int, int); Any modifications made to the Buffer *after* the call to bind will not automatically be uploaded.

Returns:FloatBuffer

the underlying FloatBuffer holding the vertex data.

Annotations
@Deprecated
getBufferback to summary
public FloatBuffer getBuffer(boolean forWriting)

Returns the underlying FloatBuffer for reading or writing.

Parameters
forWriting:boolean

when true, the underlying buffer will be uploaded on the next call to bind. If you need immediate uploading use setVertices(float[], int, int).

Returns:FloatBuffer

the underlying FloatBuffer holding the vertex data.

getNumMaxVerticesback to summary
public int getNumMaxVertices()
Returns:int

the number of vertices this VertedData can store

getNumVerticesback to summary
public int getNumVertices()
Returns:int

the number of vertices this VertexData stores

invalidateback to summary
public void invalidate()

Invalidates the VertexData if applicable. Use this in case of a context loss.

setVerticesback to summary
public void setVertices(float[] vertices, int offset, int count)

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 via VertexAttributes.

This can be called in between calls to bind and unbind. The vertex data will be updated instantly.

Parameters
vertices:float[]

the vertex data

offset:int

the offset to start copying the data from

count:int

the number of floats to copy

unbindback to summary
public void unbind(ShaderProgram shader)

Unbinds this VertexData.

unbindback to summary
public void unbind(ShaderProgram shader, int[] locations)

Unbinds this VertexData.

Parameters
locations:int[]

array containing the attribute locations.

updateVerticesback to summary
public void updateVertices(int targetOffset, float[] vertices, int sourceOffset, int count)

Update (a portion of) the vertices. Does not resize the backing buffer.

Parameters
vertices:float[]

the vertex data

sourceOffset:int

the offset to start copying the data from

count:int

the number of floats to copy