diff options
author | Sven Gothel <[email protected]> | 2011-04-25 15:54:35 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-25 15:54:35 +0200 |
commit | 727ad54808664e3028fee64cfca98dd9f0bcfbf6 (patch) | |
tree | 94446464532d741d533038e35b3fabd3abb40d0e /src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java | |
parent | e24ea541924d365c8a0896245436ca55e1575a22 (diff) |
ShaderState: 'Update' vertexAttribMap on enable
ShaderProgram:
- shaderCode's HashMap -> HashSet
- adding HashSet for attached ShaderCode
- link: allow relink, attachShader only if not yet attached
- new add(gl, ShaderCode, ..) method, allowing compile/attach pre linkage
- remove boxing of integer 'id', use generics style (warnings)
- rename: glReplaceShader -> replaceShader, glUseProgram -> useProgram
- fix: replaceShader
- hashCode _is_ 'id'
ShaderCode:
- remove boxing of integer 'id', use generics style (warnings)
- hashCode _is_ 'id'
ShaderUtil: Use generics style (warnings), static names
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java | 19 |
1 files changed, 13 insertions, 6 deletions
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 d3f224a2a..de77a1941 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -139,7 +139,7 @@ public class ShaderState { public synchronized void glUseProgram(GL2ES2 gl, boolean on) { if(null==shaderProgram) { throw new GLException("No program is attached"); } if(on) { - shaderProgram.glUseProgram(gl, true); + shaderProgram.useProgram(gl, true); // update the current ShaderState to the TLS .. gl.getContext().attachObject(ShaderState.class.getName(), this); if(resetAllShaderData) { @@ -148,7 +148,7 @@ public class ShaderState { glResetAllUniforms(gl); } } else { - shaderProgram.glUseProgram(gl, false); + shaderProgram.useProgram(gl, false); } } @@ -204,7 +204,7 @@ public class ShaderState { if(shaderProgram.linked()) { glUseProgram(gl, true); if(!prgInUse) { - shaderProgram.glUseProgram(gl, false); + shaderProgram.useProgram(gl, false); } } } @@ -249,7 +249,7 @@ public class ShaderState { if(null!=shaderProgram) { prgInUse = shaderProgram.inUse(); if(!prgInUse) { - shaderProgram.glUseProgram(gl, true); + shaderProgram.useProgram(gl, true); } } glReleaseAllVertexAttributes(gl); @@ -258,7 +258,7 @@ public class ShaderState { if(releaseProgramToo) { shaderProgram.release(gl, releaseShaderToo); } else if(!prgInUse) { - shaderProgram.glUseProgram(gl, false); + shaderProgram.useProgram(gl, false); } } } @@ -512,6 +512,9 @@ public class ShaderState { if(null==shaderProgram) throw new GLException("No program is attached"); if(0 > data.getLocation()) { glGetAttribLocation(gl, data); + } else { + // ensure data is the current bound one + vertexAttribMap2Data.put(data.getName(), data); } return glEnableVertexAttribArray(gl, data.getName(), data.getLocation()); } @@ -608,7 +611,11 @@ public class ShaderState { // if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); if(0 > data.getLocation()) { glGetAttribLocation(gl, data); - } + } /* else { + // Already achieved by glEnableVertexAttribArray(..) + // ensure data is the current bound one + vertexAttribMap2Data.put(data.getName(), data); + } */ if(0 <= data.getLocation()) { // only pass the data, if the attribute exists in the current shader if(DEBUG) { |