diff options
-rw-r--r-- | src/net/java/joglutils/msg/elements/GLShaderElement.java | 14 | ||||
-rw-r--r-- | src/net/java/joglutils/msg/nodes/ShaderNode.java | 9 |
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 |