A VertexData implementation that uses vertex buffer objects and vertex array objects. (This is required for OpenGL 3.0+
core profiles. In particular, the default VAO has been deprecated, as has the use of client memory for passing vertex
attributes.) Use of VAOs should give a slight performance benefit since you don't have to bind the attributes on every draw
anymore.
If the OpenGL ES context was lost you can call invalidate() to recreate a new OpenGL vertex buffer object.
VertexBufferObjectWithVAO objects must be disposed via the dispose() method when no longer needed
VertexBufferObject.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final VertexAttributes | |
| pack-priv final FloatBuffer | |
| pack-priv int | |
| pack-priv final ByteBuffer | |
| pack-priv IntArray | |
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv final boolean | |
| pack-priv final boolean | |
| pack-priv static final IntBuffer | |
| pack-priv final int | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| public | VertexBufferObjectWithVAO(boolean
whether the vertex data is static. isStatic, int the maximum number of vertices numVertices, VertexAttribute... attributes)Constructs a new interleaved VertexBufferObjectWithVAO. |
| public | VertexBufferObjectWithVAO(boolean
whether the vertex data is static. isStatic, int the maximum number of vertices numVertices, VertexAttributes the attributes)VertexAttributes.Constructs a new interleaved VertexBufferObjectWithVAO. |
| public | VertexBufferObjectWithVAO(boolean isStatic, ByteBuffer unmanagedBuffer, VertexAttributes attributes)
|
| 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 | |
| private void | |
| private void | |
| private void | |
| 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 | |
| public void | invalidate()
Implements com. Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. |
| 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. |
| private void | |
| public void | updateVertices(int targetOffset, float[] vertices, int sourceOffset, int count)
Implements com. Update (a portion of) the vertices. |
| attributes | back to summary |
|---|---|
| pack-priv final VertexAttributes attributes | |
| buffer | back to summary |
|---|---|
| pack-priv final FloatBuffer buffer | |
| bufferHandle | back to summary |
|---|---|
| pack-priv int bufferHandle | |
| byteBuffer | back to summary |
|---|---|
| pack-priv final ByteBuffer byteBuffer | |
| cachedLocations | back to summary |
|---|---|
| pack-priv IntArray cachedLocations | |
| isBound | back to summary |
|---|---|
| pack-priv boolean isBound | |
| isDirty | back to summary |
|---|---|
| pack-priv boolean isDirty | |
| isStatic | back to summary |
|---|---|
| pack-priv final boolean isStatic | |
| ownsBuffer | back to summary |
|---|---|
| pack-priv final boolean ownsBuffer | |
| tmpHandle | back to summary |
|---|---|
| pack-priv static final IntBuffer tmpHandle | |
| usage | back to summary |
|---|---|
| pack-priv final int usage | |
| vaoHandle | back to summary |
|---|---|
| pack-priv int vaoHandle | |
| VertexBufferObjectWithVAO | back to summary |
|---|---|
| public VertexBufferObjectWithVAO(boolean isStatic, int numVertices, VertexAttribute... attributes) Constructs a new interleaved VertexBufferObjectWithVAO.
| |
| VertexBufferObjectWithVAO | back to summary |
|---|---|
| public VertexBufferObjectWithVAO(boolean isStatic, int numVertices, VertexAttributes attributes) Constructs a new interleaved VertexBufferObjectWithVAO.
| |
| VertexBufferObjectWithVAO | back to summary |
|---|---|
| public VertexBufferObjectWithVAO(boolean isStatic, ByteBuffer unmanagedBuffer, 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.
| |
| bindAttributes | back to summary |
|---|---|
| private void bindAttributes(ShaderProgram shader, int[] locations) | |
| bindData | back to summary |
|---|---|
| private void bindData(GL20 gl) | |
| bufferChanged | back to summary |
|---|---|
| private void bufferChanged() | |
| createVAO | back to summary |
|---|---|
| private void createVAO() | |
| deleteVAO | back to summary |
|---|---|
| private void deleteVAO() | |
| 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.
| |
| 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.
| |
| 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.
| |
| unbindAttributes | back to summary |
|---|---|
| private void unbindAttributes(ShaderProgram shaderProgram) | |
| 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.
| |