From f49f8e22953ed2426fd4264ee407e2dc3fc07cfc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 12 Oct 2012 14:56:20 +0200 Subject: GLArrayData* VBO binding: Adding explicit bindBuffer(..) method, since VBO is not more bound after enableBuffer(); Fix unit test (test VBO bound). Explicit bindBuffer(..) is required now, since enableBuffer() doesn't leave it bound. See fixed VBORegion* patch for use case, i.e. using a VBO index buffer for glDrawElements(). Complets commit 8582ece7dc7f65271b3184261697a542766d9864. --- .../com/jogamp/opengl/util/GLArrayDataClient.java | 8 +++++++- .../com/jogamp/opengl/util/GLArrayDataEditable.java | 21 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl') diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index 5a1524d05..30fc0012b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -171,7 +171,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData bufferEnabled = enable; } } - + + public void bindBuffer(GL gl, boolean bind) { + if(isVBO()) { + gl.glBindBuffer(getVBOTarget(), bind ? getVBOName() : 0); + } + } + public void setEnableAlways(boolean always) { enableBufferAlways = always; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java index bb22a4b7e..588e90d1e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java @@ -45,9 +45,15 @@ public interface GLArrayDataEditable extends GLArrayData { public void seal(GL gl, boolean seal); /** - *

Enables/disables the buffer, - * sets the client state, binds the VBO if used - * and transfers the data if necessary.

+ *

+ * Enables the buffer if enable is true, + * and transfers the data if required. + * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and data association. + * The VBO buffer is unbound when the method returns. + *

+ *

+ * Disables the buffer if enable is false. + *

* *

The action will only be executed, * if the internal enable state differs, @@ -61,6 +67,15 @@ public interface GLArrayDataEditable extends GLArrayData { * @see #setEnableAlways(boolean) */ public void enableBuffer(GL gl, boolean enable); + + /** + * In case {@link #isVBO() VBO is used}, the buffer is bound + * if bind is true, otherwise the buffer is unbound. + * + * @param gl + * @param bind + */ + public void bindBuffer(GL gl, boolean bind); /** * Affects the behavior of 'enableBuffer'. -- cgit v1.2.3