summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Campbell <[email protected]>2007-04-04 07:49:21 +0000
committerChristopher Campbell <[email protected]>2007-04-04 07:49:21 +0000
commit316004096ddb50ab79a3e9a1ae193fa75f8a157e (patch)
tree4599a195daa6277bd9be6ac3462ccb19ab51b716
parentff22ba17c2356f3fc66f41c52c27e9deaba02dd2 (diff)
Hacked in support for setUniform() in ShaderNode. When I say hack, I mean it. Will clean it up later.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@58 83d24430-9974-4f80-8418-2cc3294053b9
-rw-r--r--src/net/java/joglutils/msg/elements/GLShaderElement.java14
-rw-r--r--src/net/java/joglutils/msg/nodes/ShaderNode.java9
2 files changed, 23 insertions, 0 deletions
diff --git a/src/net/java/joglutils/msg/elements/GLShaderElement.java b/src/net/java/joglutils/msg/elements/GLShaderElement.java
index a7abbc6..cf28c97 100644
--- a/src/net/java/joglutils/msg/elements/GLShaderElement.java
+++ b/src/net/java/joglutils/msg/elements/GLShaderElement.java
@@ -36,9 +36,12 @@
package net.java.joglutils.msg.elements;
+import java.util.*;
+
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
+import net.java.joglutils.msg.math.*;
import net.java.joglutils.msg.misc.*;
import net.java.joglutils.msg.nodes.*;
@@ -87,6 +90,17 @@ public class GLShaderElement extends ShaderElement {
}
if (curShader != null) {
curShader.enable();
+
+ // FIXME: the following is a big hack...
+ Map<String, Vec4f> fMap = shader.getUniformfMap();
+ if (!fMap.isEmpty()) {
+ for (String name : fMap.keySet()) {
+ Vec4f val = fMap.get(name);
+ //curShader.setUniform(name, val.x(), val.y(), val.z(), val.w());
+ curShader.setUniform(name, val.x());
+ fMap.clear();
+ }
+ }
}
}
}
diff --git a/src/net/java/joglutils/msg/nodes/ShaderNode.java b/src/net/java/joglutils/msg/nodes/ShaderNode.java
index 73154ee..ab9ea60 100644
--- a/src/net/java/joglutils/msg/nodes/ShaderNode.java
+++ b/src/net/java/joglutils/msg/nodes/ShaderNode.java
@@ -45,6 +45,7 @@ import javax.media.opengl.*;
import net.java.joglutils.msg.actions.*;
import net.java.joglutils.msg.elements.*;
+import net.java.joglutils.msg.math.*;
import net.java.joglutils.msg.misc.*;
/** Represents a vertex/fragment shader. */
@@ -78,6 +79,14 @@ public class ShaderNode extends Node {
this.fragmentShaderCode = fragmentShaderCode;
}
+ private Map<String, Vec4f> fMap = new HashMap<String, Vec4f>();
+ public void setUniform(String name, float val) {
+ fMap.put(name, new Vec4f(val, val, val, val));
+ }
+ public Map<String, Vec4f> getUniformfMap() {
+ return fMap;
+ }
+
/** Fetches the Shader object associated with this ShaderNode.
It is required to call this each frame during rendering.
An OpenGL context must be current at the time this method is