diff options
author | Sven Gothel <[email protected]> | 2011-05-17 12:53:26 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-05-17 12:53:26 +0200 |
commit | 89c243c4b1210da083afe43b37a1180c98a54414 (patch) | |
tree | eb8dfbacf0bde9b7e41b1b45624f5a1ff5d3d5ed /src/jogl/classes/com/jogamp/opengl/util | |
parent | dbfae67a9248296e4ad3586ffe8c05d9fb179eaf (diff) |
Fix: GLSLArrayHandler (data has no location); Fix ShaderState (switch program: set prev. !inUse)
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java | 4 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java | 24 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java index 73a1c2721..cc9be681c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java @@ -69,9 +69,9 @@ public class GLSLArrayHandler implements GLArrayHandler { } ad.setVBOWritten(true); st.vertexAttribPointer(glsl, ad); - } else { + } else if(ad.getLocation() >= 0) { // didn't experience a performance hit on this query .. - int[] qi = new int[1]; + final int[] qi = new int[1]; glsl.glGetVertexAttribiv(ad.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0); if(ad.getVBOName() != qi[0]) { if(DEBUG) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java index d0de473b4..e8a547057 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -208,9 +208,15 @@ public class ShaderState { } prgInUse = shaderProgram.inUse(); - if(prgInUse && null == prog) { - // only disable if in use _and_ no new prog shall be used - useProgram(gl, false); + if(prgInUse) { + // only disable if in use + if(null != prog) { + // new program will issue glUseProgram(..) + shaderProgram.programInUse = false; + } else { + // no new program - disable + useProgram(gl, false); + } } resetAllShaderData = true; } @@ -222,9 +228,9 @@ public class ShaderState { // [re]set all data and use program if switching program, // or use program if program is linked if(shaderProgram.linked() || resetAllShaderData) { - useProgram(gl, true); + useProgram(gl, true); // may reset all data if(!prgInUse) { - shaderProgram.useProgram(gl, false); + useProgram(gl, false); } } } @@ -707,11 +713,11 @@ public class ShaderState { */ public void disableAllVertexAttributeArrays(GL2ES2 gl, boolean removeFromState) { for(Iterator<String> iter = enabledAttributes.iterator(); iter.hasNext(); ) { - String name = iter.next(); + final String name = iter.next(); if(removeFromState) { enabledAttributes.remove(name); } - int index = getAttribLocation(gl, name); + final int index = getAttribLocation(gl, name); if(0<=index) { gl.glDisableVertexAttribArray(index); } @@ -720,8 +726,8 @@ public class ShaderState { private final void relocateAttribute(GL2ES2 gl, GLArrayData attribute) { // get new location .. - String name = attribute.getName(); - int loc = getAttribLocation(gl, name); + final String name = attribute.getName(); + final int loc = getAttribLocation(gl, name); attribute.setLocation(loc); if(0<=loc) { |