From d97c54896d349e8a22c9cafec75c62476c16fdd1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 20 Feb 2012 14:43:13 +0100 Subject: Fix commit fb7165e690546359dee92dd60b04be69f141c87e; Clarify ShaderState.attachShaderProgram(..) --- .../com/jogamp/opengl/util/glsl/ShaderState.java | 38 +++++----------------- .../graph/curve/opengl/RegionRendererImpl01.java | 2 +- .../graph/curve/opengl/TextRendererImpl01.java | 2 +- .../util/glsl/fixedfunc/FixedFuncPipeline.java | 8 ++--- 4 files changed, 15 insertions(+), 35 deletions(-) (limited to 'src/jogl') 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 a276018d9..4b680b849 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -197,27 +197,10 @@ public class ShaderState { * as well as switching to another program on the fly, * while managing all attribute and uniform data.

* - *

[Re]sets all data and use program in case of a program switch.
+ *

[Re]sets all data and use program in case of a program switch.

* - * Use program if linked and if previous program was in use.

- * - * @throws GLException if program was not linked and linking fails - */ - public synchronized void attachShaderProgram(GL2ES2 gl, ShaderProgram prog) throws GLException { - attachShaderProgram(gl, prog, false); - } - - /** - * Attach or switch a shader program - * - *

Attaching a shader program the first time, - * as well as switching to another program on the fly, - * while managing all attribute and uniform data.

- * - *

[Re]sets all data and use program in case of a program switch.
- * - * Use program if linked and if previous program was in use, - * or if enable is true.

+ *

Use program, {@link #useProgram(GL2ES2, boolean)}, + * if enable is true.

* * @throws GLException if program was not linked and linking fails */ @@ -227,7 +210,7 @@ public class ShaderState { if(DEBUG) { int curId = (null!=shaderProgram)?shaderProgram.id():-1; int newId = (null!=prog)?prog.id():-1; - System.err.println("Info: attachShaderProgram: "+curId+" -> "+newId+"\n\t"+shaderProgram+"\n\t"+prog); + System.err.println("Info: attachShaderProgram: "+curId+" -> "+newId+" (enable: "+enable+")\n\t"+shaderProgram+"\n\t"+prog); if(verbose) { Throwable tX = new Throwable("Info: attachShaderProgram: Trace"); tX.printStackTrace(); @@ -241,15 +224,12 @@ public class ShaderState { } return; } - prgInUse = shaderProgram.inUse(); - - if(prgInUse) { - // only disable if in use - if(null != prog) { + if(shaderProgram.inUse()) { + if(null != prog && enable) { // new program will issue glUseProgram(..) shaderProgram.programInUse = false; } else { - // no new program - disable + // no new 'enabled' program - disable useProgram(gl, false); } } @@ -262,9 +242,9 @@ public class ShaderState { if(null!=shaderProgram) { // [re]set all data and use program if switching program, // or use program if program is linked - if(shaderProgram.linked() || resetAllShaderData) { + if(resetAllShaderData || enable) { useProgram(gl, true); // may reset all data - if(!prgInUse && !enable) { + if(!enable) { useProgram(gl, false); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 0217a6369..06499208f 100755 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -66,7 +66,7 @@ public class RegionRendererImpl01 extends RegionRenderer { sp.add(rsFp); sp.init(gl); - st.attachShaderProgram(gl, sp); + st.attachShaderProgram(gl, sp, false); st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME); st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 5ed3529bf..fa57b3468 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -59,7 +59,7 @@ public class TextRendererImpl01 extends TextRenderer { sp.add(rsFp); sp.init(gl); - st.attachShaderProgram(gl, sp); + st.attachShaderProgram(gl, sp, false); st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME); st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index 973bcc147..41a694e9e 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -365,15 +365,15 @@ public class FixedFuncPipeline { if(textureEnabled) { if(lightingEnabled) { - shaderState.attachShaderProgram(gl, shaderProgramColorTextureLight); + shaderState.attachShaderProgram(gl, shaderProgramColorTextureLight, true); } else { - shaderState.attachShaderProgram(gl, shaderProgramColorTexture); + shaderState.attachShaderProgram(gl, shaderProgramColorTexture, true); } } else { if(lightingEnabled) { - shaderState.attachShaderProgram(gl, shaderProgramColorLight); + shaderState.attachShaderProgram(gl, shaderProgramColorLight, true); } else { - shaderState.attachShaderProgram(gl, shaderProgramColor); + shaderState.attachShaderProgram(gl, shaderProgramColor, true); } } if(DEBUG) { -- cgit v1.2.3