net.java.joglutils.msg.nodes
Class ShaderNode

java.lang.Object
  extended by net.java.joglutils.msg.nodes.Node
      extended by net.java.joglutils.msg.nodes.ShaderNode

public class ShaderNode
extends Node

Represents a vertex/fragment shader.


Constructor Summary
ShaderNode()
           
 
Method Summary
 void doAction(Action action)
          Performs the "typical" operation for this node when an action is applied to it.
 Shader getShader()
          Fetches the Shader object associated with this ShaderNode.
 void setShader(String fragmentShaderCode)
          Initializes this shader from the given String.
 void setShader(String vertexShaderCode, String fragmentShaderCode)
          Initializes this shader from the given String.
 void setUniform(String name, float f0)
          Sets the uniform variable of the given name with the provided float value.
 void setUniform(String name, float f0, float f1)
          Sets the uniform variable of the given name with the provided float values.
 void setUniform(String name, float f0, float f1, float f2)
          Sets the uniform variable of the given name with the provided float values.
 void setUniform(String name, float f0, float f1, float f2, float f3)
          Sets the uniform variable of the given name with the provided float values.
 void setUniform(String name, int i0)
          Sets the uniform variable of the given name with the provided integer value.
 void setUniform(String name, int i0, int i1)
          Sets the uniform variable of the given name with the provided integer values.
 void setUniform(String name, int i0, int i1, int i2)
          Sets the uniform variable of the given name with the provided integer values.
 void setUniform(String name, int i0, int i1, int i2, int i3)
          Sets the uniform variable of the given name with the provided integer values.
 void setUniformArray1f(String name, int count, float[] vals, int off)
          Sets the uniform array variable of the given name with the provided float array values.
 void setUniformArray1i(String name, int count, int[] vals, int off)
          Sets the uniform array variable of the given name with the provided int array values.
 void setUniformArray2f(String name, int count, float[] vals, int off)
          Sets the uniform array variable of the given name with the provided float array values.
 void setUniformArray2i(String name, int count, int[] vals, int off)
          Sets the uniform array variable of the given name with the provided int array values.
 void setUniformArray3f(String name, int count, float[] vals, int off)
          Sets the uniform array variable of the given name with the provided float array values.
 void setUniformArray3i(String name, int count, int[] vals, int off)
          Sets the uniform array variable of the given name with the provided int array values.
 void setUniformArray4f(String name, int count, float[] vals, int off)
          Sets the uniform array variable of the given name with the provided float array values.
 void setUniformArray4i(String name, int count, int[] vals, int off)
          Sets the uniform array variable of the given name with the provided int array values.
 void setUniformMatrices2f(String name, int count, boolean transpose, float[] vals, int off)
          Sets the uniform matrix (or matrix array) variable of the given name with the provided matrix values.
 void setUniformMatrices3f(String name, int count, boolean transpose, float[] vals, int off)
          Sets the uniform matrix (or matrix array) variable of the given name with the provided matrix values.
 void setUniformMatrices4f(String name, int count, boolean transpose, float[] vals, int off)
          Sets the uniform matrix (or matrix array) variable of the given name with the provided matrix values.
 
Methods inherited from class net.java.joglutils.msg.nodes.Node
rayPick, render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShaderNode

public ShaderNode()
Method Detail

setShader

public void setShader(String fragmentShaderCode)
Initializes this shader from the given String. No OpenGL work is done during this call; it is done lazily when the Shader is fetched.


setShader

public void setShader(String vertexShaderCode,
                      String fragmentShaderCode)
Initializes this shader from the given String. No OpenGL work is done during this call; it is done lazily when the Shader is fetched.


setUniform

public void setUniform(String name,
                       int i0)
Sets the uniform variable of the given name with the provided integer value.

Parameters:
name - the name of the uniform variable to be set
i0 - the first uniform parameter

setUniform

public void setUniform(String name,
                       int i0,
                       int i1)
Sets the uniform variable of the given name with the provided integer values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
i0 - the first uniform parameter
i1 - the second uniform parameter

setUniform

public void setUniform(String name,
                       int i0,
                       int i1,
                       int i2)
Sets the uniform variable of the given name with the provided integer values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
i0 - the first uniform parameter
i1 - the second uniform parameter
i2 - the third uniform parameter

setUniform

public void setUniform(String name,
                       int i0,
                       int i1,
                       int i2,
                       int i3)
Sets the uniform variable of the given name with the provided integer values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
i0 - the first uniform parameter
i1 - the second uniform parameter
i2 - the third uniform parameter
i3 - the fourth uniform parameter

setUniform

public void setUniform(String name,
                       float f0)
Sets the uniform variable of the given name with the provided float value.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
f0 - the first uniform parameter

setUniform

public void setUniform(String name,
                       float f0,
                       float f1)
Sets the uniform variable of the given name with the provided float values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
f0 - the first uniform parameter
f1 - the second uniform parameter

setUniform

public void setUniform(String name,
                       float f0,
                       float f1,
                       float f2)
Sets the uniform variable of the given name with the provided float values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
f0 - the first uniform parameter
f1 - the second uniform parameter
f2 - the third uniform parameter

setUniform

public void setUniform(String name,
                       float f0,
                       float f1,
                       float f2,
                       float f3)
Sets the uniform variable of the given name with the provided float values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
f0 - the first uniform parameter
f1 - the second uniform parameter
f2 - the third uniform parameter
f3 - the fourth uniform parameter

setUniformArray1i

public void setUniformArray1i(String name,
                              int count,
                              int[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided int array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of int elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray2i

public void setUniformArray2i(String name,
                              int count,
                              int[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided int array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of ivec2 elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray3i

public void setUniformArray3i(String name,
                              int count,
                              int[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided int array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of ivec3 elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray4i

public void setUniformArray4i(String name,
                              int count,
                              int[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided int array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of ivec4 elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray1f

public void setUniformArray1f(String name,
                              int count,
                              float[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided float array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of float elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray2f

public void setUniformArray2f(String name,
                              int count,
                              float[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided float array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of vec2 elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray3f

public void setUniformArray3f(String name,
                              int count,
                              float[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided float array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of vec3 elements in the array
vals - the array values to be set
off - the offset into the vals array

setUniformArray4f

public void setUniformArray4f(String name,
                              int count,
                              float[] vals,
                              int off)
Sets the uniform array variable of the given name with the provided float array values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of vec4 elements in the array
vals - the array values to be set
off - the offset into the vals array
Throws:
javax.media.opengl.GLException - if no OpenGL context was current or if any OpenGL-related errors occurred

setUniformMatrices2f

public void setUniformMatrices2f(String name,
                                 int count,
                                 boolean transpose,
                                 float[] vals,
                                 int off)
Sets the uniform matrix (or matrix array) variable of the given name with the provided matrix values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of 2x2 matrices (mat2 elements) in the array
transpose - if false, each matrix is assumed to be suppplied in column major order; otherwise assumed to be supplied in row major order
vals - the matrix values to be set
off - the offset into the vals array

setUniformMatrices3f

public void setUniformMatrices3f(String name,
                                 int count,
                                 boolean transpose,
                                 float[] vals,
                                 int off)
Sets the uniform matrix (or matrix array) variable of the given name with the provided matrix values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of 3x3 matrices (mat3 elements) in the array
transpose - if false, each matrix is assumed to be suppplied in column major order; otherwise assumed to be supplied in row major order
vals - the matrix values to be set
off - the offset into the vals array

setUniformMatrices4f

public void setUniformMatrices4f(String name,
                                 int count,
                                 boolean transpose,
                                 float[] vals,
                                 int off)
Sets the uniform matrix (or matrix array) variable of the given name with the provided matrix values.

No OpenGL work is done during this call; it is done lazily when the Shader is fetched.

Parameters:
name - the name of the uniform variable to be set
count - the number of 4x4 matrices (mat4 elements) in the array
transpose - if false, each matrix is assumed to be suppplied in column major order; otherwise assumed to be supplied in row major order
vals - the matrix values to be set
off - the offset into the vals array

getShader

public Shader getShader()
                 throws javax.media.opengl.GLException
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 called or a GLException will be thrown.

Throws:
javax.media.opengl.GLException

doAction

public void doAction(Action action)
Description copied from class: Node
Performs the "typical" operation for this node when an action is applied to it. The default implementation does nothing.

Overrides:
doAction in class Node