codeanticode.glgraphics
Class GLSLShaderUniform

java.lang.Object
  extended by codeanticode.glgraphics.GLSLShaderUniform
All Implemented Interfaces:
GLConstants
Direct Known Subclasses:
GLModelEffectParameter

public class GLSLShaderUniform
extends java.lang.Object

This class stores the uniform variable of a GLSL shader.


Field Summary
 
Fields inherited from interface codeanticode.glgraphics.GLConstants
BACKGROUND_ALPHA, CG_CONTEXT, CG_EFFECT, CG_PROGRAM, COLOR, DOUBLE, FLOAT, FRAGMENT_PROGRAM, GEOMETRY_PROGRAM, GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_FRAME_BUFFER, GL_PIXEL_BUFFER, GL_RENDER_BUFFER, GL_TEXTURE_OBJECT, GL_UNSIGNED_INT_24_8, GL_VERTEX_BUFFER, GLGRAPHICS, GLSL_PROGRAM, GLSL_SHADER, IDENTITY_MATRIX, INVERSE_MATRIX, INVERSE_TRANSPOSE_MATRIX, LINE_ADJACENCY, LINEAR_MIPMAP_LINEAR, LINEAR_MIPMAP_NEAREST, LINEAR_SAMPLING, NEAREST_MIPMAP_LINEAR, NEAREST_MIPMAP_NEAREST, NEAREST_SAMPLING, SHADER_VAR_ARRAY, SHADER_VAR_FLOAT, SHADER_VAR_INT, SHADER_VAR_MAT2, SHADER_VAR_MAT3, SHADER_VAR_MAT4, SHADER_VAR_MODELVIEW_MAT, SHADER_VAR_MODELVIEW_PROJECTION_MAT, SHADER_VAR_PROJECTION_MAT, SHADER_VAR_TEXTURE_MAT, SHADER_VAR_TEXTURE_SAMPLER, SHADER_VAR_VEC2, SHADER_VAR_VEC3, SHADER_VAR_VEC4, TEX_BYTE, TEX_INT, TEX_NORM, TEX_ONEDIM, TEX_RECT, TRANSPOSE_MATRIX, TRIANGLE_ADJACENCY, VERTEX_PROGRAM
 
Constructor Summary
GLSLShaderUniform(processing.core.PApplet parent, GLShader shader, java.lang.String name, java.lang.String label, int type, int len)
          Creates an instance of GLSLShaderUniform using the specified parameters.
GLSLShaderUniform(processing.core.PApplet parent, java.lang.String name, java.lang.String label, int type, int len)
          Creates an instance of GLSLShaderUniform using the specified parameters.
 
Method Summary
 boolean available()
          Returns true or false depending on whether this variable is available for use.
 void copyToShader()
          Copies the parameter value to the GPU.
 int getArrayLength()
          Returns array length.
 java.lang.String getLabel()
          Returns parameter label.
 java.lang.String getName()
          Returns parameter name.
 int getType()
          Returns parameter type.
static int getType(java.lang.String typeStr)
          Returns the int constant that identifies a type, given the corresponding string.
 void init()
          Initializes this shader variable.
 void setShader(GLShader shader)
          Sets the shader this parameter corresponds to.
 void setValue(float value)
          Sets the parameter value when the type is float.
 void setValue(float[] value)
          Sets the parameter value for any type.
 void setValue(int value)
          Sets the parameter value when the type is int.
 void setValue(int i, float value)
          Sets the ith value for the parameter (only valid for vec or mat types).
 void setValue(int i, int j, float value)
          Sets the (ith, jth) value for the parameter (only valid for mat types).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLSLShaderUniform

public GLSLShaderUniform(processing.core.PApplet parent,
                         java.lang.String name,
                         java.lang.String label,
                         int type,
                         int len)
Creates an instance of GLSLShaderUniform using the specified parameters. The shader is set to null.

Parameters:
parent - PApplet
name - String
label - String
type - int
len - int

GLSLShaderUniform

public GLSLShaderUniform(processing.core.PApplet parent,
                         GLShader shader,
                         java.lang.String name,
                         java.lang.String label,
                         int type,
                         int len)
Creates an instance of GLSLShaderUniform using the specified parameters.

Parameters:
parent - PApplet
shader - GLShader
name - String
label - String
type - int
len - int
Method Detail

available

public boolean available()
Returns true or false depending on whether this variable is available for use.

Returns:
boolean

init

public void init()
Initializes this shader variable.


copyToShader

public void copyToShader()
Copies the parameter value to the GPU.


setShader

public void setShader(GLShader shader)
Sets the shader this parameter corresponds to.

Parameters:
shader - GLShader

setValue

public void setValue(int value)
Sets the parameter value when the type is int.

Parameters:
value - int

setValue

public void setValue(float value)
Sets the parameter value when the type is float.

Parameters:
value - float

setValue

public void setValue(float[] value)
Sets the parameter value for any type. When the type is int or float, the first element of the value array is considered.

Parameters:
value - float[]

setValue

public void setValue(int i,
                     float value)
Sets the ith value for the parameter (only valid for vec or mat types).

Parameters:
int - i
value - float

setValue

public void setValue(int i,
                     int j,
                     float value)
Sets the (ith, jth) value for the parameter (only valid for mat types).

Parameters:
int - i
int - j
value - float

getType

public static int getType(java.lang.String typeStr)
Returns the int constant that identifies a type, given the corresponding string.

Parameters:
String - typeStr
Returns:
int

getType

public int getType()
Returns parameter type.

Returns:
int

getName

public java.lang.String getName()
Returns parameter name.

Returns:
String

getLabel

public java.lang.String getLabel()
Returns parameter label.

Returns:
String

getArrayLength

public int getArrayLength()
Returns array length.

Returns:
String


processing library GLGraphics by Andres Colubri. (c) 2008-2011