From 8582ece7dc7f65271b3184261697a542766d9864 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 10 Oct 2012 17:37:38 +0200 Subject: Simplify GLArrayHandler and reduce VBO sideffects VBO: Always unbind VBO ASAP after data transfer (glBufferData()) and assignment (glVertexPointer(..), glVertexAttribPointer()). It's a bug to leave it bound .. due to redundancy and other calls which could have change the VBO binding. Removed syncData(..), now it's only issued at enable and hence migrated into the enable method. --- .../classes/jogamp/opengl/util/GLFixedArrayHandler.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java') diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java index d8939dc0f..3ed41893a 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java @@ -54,10 +54,12 @@ public class GLFixedArrayHandler implements GLArrayHandler { throw new UnsupportedOperationException(); } - public final void syncData(GL gl, boolean enable, Object ext) { + public final void enableState(GL gl, boolean enable, Object ext) { + final GLPointerFunc glp = gl.getGL2ES1(); if(enable) { final Buffer buffer = ad.getBuffer(); - if(ad.isVBO()) { + final boolean vboBound = ad.isVBO(); + if(vboBound) { // always bind and refresh the VBO mgr, // in case more than one gl*Pointer objects are in use gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); @@ -68,7 +70,6 @@ public class GLFixedArrayHandler implements GLArrayHandler { ad.setVBOWritten(true); } } - final GLPointerFunc glp = gl.getGL2ES1(); switch(ad.getIndex()) { case GLPointerFunc.GL_VERTEX_ARRAY: glp.glVertexPointer(ad); @@ -85,14 +86,8 @@ public class GLFixedArrayHandler implements GLArrayHandler { default: throw new GLException("invalid glArrayIndex: "+ad.getIndex()+":\n\t"+ad); } - } else if(ad.isVBO()) { gl.glBindBuffer(ad.getVBOTarget(), 0); - } - } - - public final void enableState(GL gl, boolean enable, Object ext) { - final GLPointerFunc glp = gl.getGL2ES1(); - if(enable) { + glp.glEnableClientState(ad.getIndex()); } else { glp.glDisableClientState(ad.getIndex()); -- cgit v1.2.3