A VertexData implementation based on OpenGL vertex buffer objects.
If the OpenGL ES context was lost you can call invalidate() to recreate a new OpenGL vertex buffer object.
The data is bound via glVertexAttribPointer() according to the attribute aliases specified via VertexAttributes in the
constructor.
VertexBufferObjects must be disposed via the dispose() method when no longer needed
| Modifier and Type | Field and Description |
|---|---|
| private VertexAttributes | |
| private FloatBuffer | |
| private int | |
| private ByteBuffer | |
| pack-priv boolean | |
| pack-priv boolean | |
| private boolean | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | VertexBufferObject(boolean
whether the vertex data is static. isStatic, int the maximum number of vertices numVertices, VertexAttribute... the attributes)VertexAttributes.Constructs a new interleaved VertexBufferObject. |
| public | VertexBufferObject(boolean
whether the vertex data is static. isStatic, int the maximum number of vertices numVertices, VertexAttributes the attributes)VertexAttributes.Constructs a new interleaved VertexBufferObject. |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | bind(ShaderProgram
the shader shader)Implements com. Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements |
| public void | bind(ShaderProgram shader, int[] locations)
Implements com. Binds this VertexData for rendering via glDrawArrays or glDrawElements. |
| private void | |
| public void | dispose()
Implements com. Disposes of all resources this VertexBufferObject uses. |
| public VertexAttributes | |
| public FloatBuffer | getBuffer()
Implements com.
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 | getBuffer(boolean forWriting)
Implements com. Returns the underlying FloatBuffer for reading or writing. |
| public int | |
| public int | |
| protected int | getUsage()
Returns: The GL enum used in the call to |
| public void | invalidate()
Implements com. Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. |
| protected void | setBuffer(Buffer data, boolean ownsBuffer, VertexAttributes value)
Low level method to reset the buffer and attributes to the specified values. |
| protected void | setUsage(int value)
Set the GL enum used in the call to |
| public void | setVertices(float[] vertices, int offset, int count)
Implements com. Sets the vertices of this VertexData, discarding the old vertex data. |
| public void | unbind(final ShaderProgram
the shader shader)Implements com. Unbinds this VertexBufferObject. |
| public void | unbind(final ShaderProgram shader, final int[] locations)
Implements com. Unbinds this VertexData. |
| public void | updateVertices(int targetOffset, float[] vertices, int sourceOffset, int count)
Implements com. Update (a portion of) the vertices. |
| attributes | back to summary |
|---|---|
| private VertexAttributes attributes | |
| buffer | back to summary |
|---|---|
| private FloatBuffer buffer | |
| bufferHandle | back to summary |
|---|---|
| private int bufferHandle | |
| byteBuffer | back to summary |
|---|---|
| private ByteBuffer byteBuffer | |
| isBound | back to summary |
|---|---|
| pack-priv boolean isBound | |
| isDirty | back to summary |
|---|---|
| pack-priv boolean isDirty | |
| ownsBuffer | back to summary |
|---|---|
| private boolean ownsBuffer | |
| usage | back to summary |
|---|---|
| private int usage | |
| VertexBufferObject | back to summary |
|---|---|
| public VertexBufferObject(boolean isStatic, int numVertices, VertexAttribute... attributes) Constructs a new interleaved VertexBufferObject.
| |
| VertexBufferObject | back to summary |
|---|---|
| public VertexBufferObject(boolean isStatic, int numVertices, VertexAttributes attributes) Constructs a new interleaved VertexBufferObject.
| |
| VertexBufferObject | back to summary |
|---|---|
| protected VertexBufferObject(int usage, ByteBuffer data, boolean ownsBuffer, VertexAttributes attributes) | |
| bind | back to summary |
|---|---|
| public void bind(ShaderProgram shader) Implements com. Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements
| |
| bind | back to summary |
|---|---|
| public void bind(ShaderProgram shader, int[] locations) Implements com. Doc from com. Binds this VertexData for rendering via glDrawArrays or glDrawElements.
| |
| bufferChanged | back to summary |
|---|---|
| private void bufferChanged() | |
| dispose | back to summary |
|---|---|
| public void dispose() Implements com. Disposes of all resources this VertexBufferObject uses.
| |
| getAttributes | back to summary |
|---|---|
| public VertexAttributes getAttributes() Implements com.
| |
| getBuffer | back to summary |
|---|---|
| public FloatBuffer getBuffer() Implements com. Doc from com. Deprecated use 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
| |
| getBuffer | back to summary |
|---|---|
| public FloatBuffer getBuffer(boolean forWriting) Implements com. Doc from com. Returns the underlying FloatBuffer for reading or writing.
| |
| getNumMaxVertices | back to summary |
|---|---|
| public int getNumMaxVertices() Implements com.
| |
| getNumVertices | back to summary |
|---|---|
| public int getNumVertices() Implements com.
| |
| getUsage | back to summary |
|---|---|
protected int getUsage()
| |
| invalidate | back to summary |
|---|---|
| public void invalidate() Implements com. Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss.
| |
| setBuffer | back to summary |
|---|---|
| protected void setBuffer(Buffer data, boolean ownsBuffer, VertexAttributes value) Low level method to reset the buffer and attributes to the specified values. Use with care! | |
| setUsage | back to summary |
|---|---|
| protected void setUsage(int value) Set the GL enum used in the call to | |
| setVertices | back to summary |
|---|---|
| public void setVertices(float[] vertices, int offset, int count) Implements com. Doc from com. 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 This can be called in between calls to bind and unbind. The vertex data will be updated instantly.
| |
| unbind | back to summary |
|---|---|
| public void unbind(final ShaderProgram shader) Implements com. Unbinds this VertexBufferObject.
| |
| unbind | back to summary |
|---|---|
| public void unbind(final ShaderProgram shader, final int[] locations) Implements com. Doc from com. Unbinds this VertexData.
| |
| updateVertices | back to summary |
|---|---|
| public void updateVertices(int targetOffset, float[] vertices, int sourceOffset, int count) Implements com. Doc from com. Update (a portion of) the vertices. Does not resize the backing buffer.
| |