aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/glsl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java25
1 files changed, 20 insertions, 5 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 36abd9d4d..aa9a73bdd 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -63,26 +63,42 @@ public class ShaderState {
*
* @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean)
* @see com.jogamp.opengl.util.glsl.ShaderState#getShaderState(GL)
+ * @see com.jogamp.opengl.util.glsl.ShaderState#setShaderState(GL)
* @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
*/
- public static synchronized ShaderState getCurrentShaderState() {
+ public static ShaderState getCurrentShaderState() {
return getShaderState(GLContext.getCurrentGL());
}
/**
- * Fetches the shader state from the GL object's GLContext
+ * Gets the shader state attached to the GL object's GLContext
*
* @param gl the GL object referencing the GLContext
*
* @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean)
* @see com.jogamp.opengl.util.glsl.ShaderState#getShaderState(GL)
+ * @see com.jogamp.opengl.util.glsl.ShaderState#setShaderState(GL)
* @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
*/
- public static synchronized ShaderState getShaderState(GL gl) {
+ public static ShaderState getShaderState(GL gl) {
return (ShaderState) gl.getContext().getAttachedObject(currentStateKey);
}
/**
+ * Attaches the shader state to the GL object's GLContext
+ *
+ * @param gl the GL object referencing the GLContext
+ *
+ * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean)
+ * @see com.jogamp.opengl.util.glsl.ShaderState#getShaderState(GL)
+ * @see com.jogamp.opengl.util.glsl.ShaderState#setShaderState(GL)
+ * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
+ */
+ public final ShaderState setShaderState(GL gl) {
+ return (ShaderState) gl.getContext().attachObject(currentStateKey, this);
+ }
+
+ /**
* Returns the attached user object for the given name to this ShaderState.
*/
public final Object getAttachedObject(String name) {
@@ -141,8 +157,7 @@ public class ShaderState {
public synchronized void useProgram(GL2ES2 gl, boolean on) throws GLException {
if(null==shaderProgram) { throw new GLException("No program is attached"); }
if(on) {
- // update the current ShaderState to the TLS ..
- gl.getContext().attachObject(currentStateKey, this);
+ setShaderState(gl);
if(shaderProgram.linked()) {
shaderProgram.useProgram(gl, true);
if(resetAllShaderData) {