From 3ae26ed8a9f0d4394c5b1e22d8246c2cdf391b2e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Oct 2012 00:36:17 +0200 Subject: ShaderState: Adding Class API doc and removing attached object w/ 'int' key, similar to GLContext change 6d241fc2a46413ee478985d676d2481c5a7ed119 --- .../com/jogamp/opengl/util/glsl/ShaderState.java | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 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 62082aacd..2bfd7f391 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -42,9 +42,20 @@ import javax.media.opengl.GLUniformData; import jogamp.opengl.Debug; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.opengl.util.GLArrayDataEditable; +/** + * ShaderState allows to sharing data between shader programs, + * while updating the attribute and uniform locations when switching. + *

+ * This allows seamless switching of programs using almost same data + * but performing different artifacts. + *

+ *

+ * A {@link #useProgram(GL2ES2, boolean) used} ShaderState is attached to the current GL context + * and can be retrieved via {@link #getShaderState(GL)}. + *

+ */ public class ShaderState { public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true); private static final String currentStateKey = "jogamp.opengl.glsl.ShaderState" ; @@ -122,25 +133,6 @@ public class ShaderState { return attachedObjectsByString.remove(name); } - /** - * Returns the attached user object for the given name to this ShaderState. - */ - public final Object getAttachedObject(int name) { - return attachedObjectsByInt.get(name); - } - - /** - * Attach user object for the given name to this ShaderState. - * Returns the previously set object or null. - */ - public final Object attachObject(int name, Object obj) { - return attachedObjectsByInt.put(name, obj); - } - - public final Object detachObject(int name) { - return attachedObjectsByInt.remove(name); - } - /** * Turns the shader program on or off.
* Puts this ShaderState to to the thread local storage (TLS), @@ -262,7 +254,6 @@ public class ShaderState { public synchronized void destroy(GL2ES2 gl) { release(gl, true, true, true); attachedObjectsByString.clear(); - attachedObjectsByInt.clear(); } /** @@ -1044,7 +1035,6 @@ public class ShaderState { private ArrayList managedUniforms = new ArrayList(); private HashMap attachedObjectsByString = new HashMap(); - private IntObjectHashMap attachedObjectsByInt = new IntObjectHashMap(); private boolean resetAllShaderData = false; } -- cgit v1.2.3