/** * Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements * * @param shader the shader */ @Override public void bind (ShaderProgram shader) { bind(shader, null); }
@Override public void bind (ShaderProgram shader, int[] locations) { GL30 gl = Gdx.gl30; gl.glBindVertexArray(vaoHandle); bindAttributes(shader, locations); //if our data has changed upload it: bindData(gl); isBound = true; }
@Override public void updateVertices (int targetOffset, float[] vertices, int sourceOffset, int count) { isDirty = true; final int pos = byteBuffer.position(); byteBuffer.position(targetOffset * 4); BufferUtils.copy(vertices, sourceOffset, count, byteBuffer); byteBuffer.position(pos); buffer.position(0); bufferChanged(); }
/** * Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss. */ @Override public void invalidate () { bufferHandle = Gdx.gl30.glGenBuffer(); createVAO(); isDirty = true; }
/** * Unbinds this VertexBufferObject. * * @param shader the shader */ @Override public void unbind (final ShaderProgram shader) { unbind(shader, null); }
/** * Disposes of all resources this VertexBufferObject uses. */ @Override public void dispose () { GL30 gl = Gdx.gl30; gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); gl.glDeleteBuffer(bufferHandle); bufferHandle = 0; deleteVAO(); }
unbindAttributes(shader); this.cachedLocations.clear();
private VertexData makeVertexBuffer (boolean isStatic, int maxVertices, VertexAttributes vertexAttributes) { if (Gdx.gl30 != null) { return new VertexBufferObjectWithVAO(isStatic, maxVertices, vertexAttributes); } else { return new VertexBufferObject(isStatic, maxVertices, vertexAttributes); } }
/** * Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss. */ @Override public void invalidate () { bufferHandle = Gdx.gl30.glGenBuffer(); createVAO(); isDirty = true; }
/** * Unbinds this VertexBufferObject. * * @param shader the shader */ @Override public void unbind (final ShaderProgram shader) { unbind(shader, null); }
/** * Disposes of all resources this VertexBufferObject uses. */ @Override public void dispose () { GL30 gl = Gdx.gl30; gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); gl.glDeleteBuffer(bufferHandle); bufferHandle = 0; deleteVAO(); }
unbindAttributes(shader); this.cachedLocations.clear();
private VertexData makeVertexBuffer (boolean isStatic, int maxVertices, VertexAttributes vertexAttributes) { if (Gdx.gl30 != null) { return new VertexBufferObjectWithVAO(isStatic, maxVertices, vertexAttributes); } else { return new VertexBufferObject(isStatic, maxVertices, vertexAttributes); } }
@Override public void bind (ShaderProgram shader, int[] locations) { GL30 gl = Gdx.gl30; gl.glBindVertexArray(vaoHandle); bindAttributes(shader, locations); //if our data has changed upload it: bindData(gl); isBound = true; }
/** * Invalidates the VertexBufferObject so a new OpenGL buffer handle is created. Use this in case of a context loss. */ @Override public void invalidate () { bufferHandle = Gdx.gl20.glGenBuffer(); createVAO(); isDirty = true; }
@Override public void updateVertices (int targetOffset, float[] vertices, int sourceOffset, int count) { isDirty = true; final int pos = buffer.position(); buffer.position(targetOffset); BufferUtils.copy(vertices, sourceOffset, count, buffer); buffer.position(pos); bufferChanged(); }
/** * Unbinds this VertexBufferObject. * * @param shader the shader */ @Override public void unbind (final ShaderProgram shader) { unbind(shader, null); }
/** * Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements * * @param shader the shader */ @Override public void bind (ShaderProgram shader) { bind(shader, null); }
/** * Disposes of all resources this VertexBufferObject uses. */ @Override public void dispose () { GL30 gl = Gdx.gl30; gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); gl.glDeleteBuffer(bufferHandle); bufferHandle = 0; BufferUtils.disposeUnsafeByteBuffer(byteBuffer); deleteVAO(); }
unbindAttributes(shader); this.cachedLocations.clear();