codeanticode.glgraphics
Class GLCgFXEffect

java.lang.Object
  extended by codeanticode.glgraphics.GLCgFXEffect
All Implemented Interfaces:
GLConstants

public class GLCgFXEffect
extends java.lang.Object
implements GLConstants

This class encapsulates a CgFX shader effect. Based in the code by Victor Martins (http://www.pixelnerve.com/v/)


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
GLCgFXEffect(processing.core.PApplet parent, java.lang.String fn)
          Creates an instance of GLCgFXEffect, reading the effect from file.
 
Method Summary
 void delete()
          Releases the OpenGL resources associated to this effect.
 int getCgMatrixTransform(int glcode)
           
 CGeffect getEffect()
          Returns the internal CGeffect object that encapsulates the CgFX effect.
 void resetSelectedPass()
          Resets the currently selected pass in the current technique.
 boolean selectFirstPass()
          Selects the first pass in the current technique.
 boolean selectNextPass()
          Selects the next pass in the current technique.
 void setFirstTechnique()
          Sets for use the first technique contained in the effect.
 void setFloatParameter(java.lang.String param, float x)
          Sets the float parameter with name to the given value
 void setFloatParameterBySemantic(java.lang.String semantic, float x)
          Sets the float parameter with indicated semantic to the given value
 void setIntParameter(java.lang.String param, int x)
          Sets the int parameter with name to the given value
 void setIntParameterBySemantic(java.lang.String semantic, int x)
          Sets the int parameter with indicated semantic to the given value
 void setMatParameter(java.lang.String param, float m00, float m01, float m10, float m11)
          Sets the mat2 parameter with name to the given values
 void setMatParameter(java.lang.String param, float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
          Sets the mat3 parameter with name to the given value
 void setMatParameter(java.lang.String param, float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
          Sets the mat4 parameter with name to the given value
 void setMatParameterBySemantic(java.lang.String semantic, float m00, float m01, float m10, float m11)
          Sets the mat2 parameter with indicated semantic to the given values
 void setMatParameterBySemantic(java.lang.String semantic, float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
          Sets the mat3 parameter with indicated semantic to the given values
 void setMatParameterBySemantic(java.lang.String semantic, float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
          Sets the mat4 parameter with indicated semantic to the given values
 void setMatrixParameterBySemantic(java.lang.String semantic, float[] mat)
          Sets the matrix parameter with indicated semantic to the given values
 void setMatrixParameterBySemantic(java.lang.String semantic, int matrix)
          Sets the matrix parameter identified by semantic, and adding no post-transformation to the matrix.
 void setMatrixParameterBySemantic(java.lang.String semantic, int matrix, int gltransform)
          Sets the parameter with the given semantic with the current contents of the specified matrix, applying a certain transformation.
 void setModelviewMatrix(java.lang.String param)
          Sets the parameter param with the current contents of the OpenGL modelview matrix.
 void setModelviewMatrixBySemantic(java.lang.String semantic)
          Passes OpenGL's modelview matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.
 void setModelviewMatrixBySemantic(java.lang.String semantic, int gltransform)
          Sets the parameter with the given semantic with the current contents of the modelview matrix, applying a certain transformation.
 void setModelviewProjectionMatrix(java.lang.String param)
          Sets the parameter param with the current contents of the OpenGL modelview-projection matrix.
 void setModelviewProjectionMatrixBySemantic(java.lang.String semantic)
          Passes OpenGL's modelview-projection matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.
 void setModelviewProjectionMatrixBySemantic(java.lang.String semantic, int gltransform)
          Sets the parameter with the given semantic with the current contents of the modelview-projection matrix, applying a certain transformation.
 void setProjectionMatrix(java.lang.String param)
          Sets the parameter param with the current contents of the OpenGL projection matrix.
 void setProjectionMatrixBySemantic(java.lang.String semantic)
          Passes OpenGL's projection matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.
 void setProjectionMatrixBySemantic(java.lang.String semantic, int gltransform)
          Sets the parameter with the given semantic with the current contents of the projection matrix, applying a certain transformation.
 void setSelectedPass()
          Sets for use the currently selected pass in the current technique.
 void setTechnique(java.lang.String name)
          Sets for use the technique contained in the effect with the specified name.
 void setTexMatrix(java.lang.String param)
          Sets the parameter param with the current contents of the OpenGL texture matrix.
 void setTexParameter(java.lang.String param, GLTexture tex)
          Set the given texture for the parameter param.
 void setTexParameterBySemantic(java.lang.String semantic, GLTexture tex)
          Sets the parameter with indicated semantic to the given texture
 void setTextureMatrixBySemantic(java.lang.String semantic)
          Passes OpenGL's texture matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.
 void setTextureMatrixBySemantic(java.lang.String semantic, int gltransform)
          Sets the parameter with the given semantic with the current contents of the texture matrix, applying a certain transformation.
 void setVecParameter(java.lang.String param, float x, float y)
          Sets the vec2 parameter with name to the given values
 void setVecParameter(java.lang.String param, float x, float y, float z)
          Sets the vec3 parameter with name to the given values
 void setVecParameter(java.lang.String param, float x, float y, float z, float w)
          Sets the vec4 parameter with name to the given values
 void setVecParameterBySemantic(java.lang.String semantic, float x, float y)
          Sets the vec2 parameter with indicated semantic to the given values
 void setVecParameterBySemantic(java.lang.String semantic, float x, float y, float z)
          Sets the vec3 parameter with indicated semantic to the given values
 void setVecParameterBySemantic(java.lang.String semantic, float x, float y, float z, float w)
          Sets the vec4 parameter with indicated semantic to the given values
 void start()
          Starts effect execution.
 void stop()
          Stops effect execution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLCgFXEffect

public GLCgFXEffect(processing.core.PApplet parent,
                    java.lang.String fn)
Creates an instance of GLCgFXEffect, reading the effect from file.

Parameters:
parent - PApplet
fn - String
Method Detail

delete

public void delete()
Releases the OpenGL resources associated to this effect.


getEffect

public CGeffect getEffect()
Returns the internal CGeffect object that encapsulates the CgFX effect.

Returns:
CGeffect

start

public void start()
Starts effect execution.


stop

public void stop()
Stops effect execution.


setFirstTechnique

public void setFirstTechnique()
Sets for use the first technique contained in the effect.


setTechnique

public void setTechnique(java.lang.String name)
Sets for use the technique contained in the effect with the specified name.

Parameters:
name - String

setSelectedPass

public void setSelectedPass()
Sets for use the currently selected pass in the current technique.


resetSelectedPass

public void resetSelectedPass()
Resets the currently selected pass in the current technique.


selectFirstPass

public boolean selectFirstPass()
Selects the first pass in the current technique.

Returns:
boolean true or false depending if it was possible to select the first pass of the current technique

selectNextPass

public boolean selectNextPass()
Selects the next pass in the current technique. Returns true if there is a pass to select.

Returns:
boolean

setTexParameter

public void setTexParameter(java.lang.String param,
                            GLTexture tex)
Set the given texture for the parameter param.


setIntParameter

public void setIntParameter(java.lang.String param,
                            int x)
Sets the int parameter with name to the given value

Parameters:
name - String
x - int

setFloatParameter

public void setFloatParameter(java.lang.String param,
                              float x)
Sets the float parameter with name to the given value

Parameters:
name - String
x - float

setVecParameter

public void setVecParameter(java.lang.String param,
                            float x,
                            float y)
Sets the vec2 parameter with name to the given values

Parameters:
name - String
x - float
y - float

setVecParameter

public void setVecParameter(java.lang.String param,
                            float x,
                            float y,
                            float z)
Sets the vec3 parameter with name to the given values

Parameters:
name - String
x - float
y - float
z - float

setVecParameter

public void setVecParameter(java.lang.String param,
                            float x,
                            float y,
                            float z,
                            float w)
Sets the vec4 parameter with name to the given values

Parameters:
name - String
x - float
y - float
z - float
w - float

setMatParameter

public void setMatParameter(java.lang.String param,
                            float m00,
                            float m01,
                            float m10,
                            float m11)
Sets the mat2 parameter with name to the given values

Parameters:
name - String
m00 - float ...

setMatParameter

public void setMatParameter(java.lang.String param,
                            float m00,
                            float m01,
                            float m02,
                            float m10,
                            float m11,
                            float m12,
                            float m20,
                            float m21,
                            float m22)
Sets the mat3 parameter with name to the given value

Parameters:
name - String
m00 - float ...

setMatParameter

public void setMatParameter(java.lang.String param,
                            float m00,
                            float m01,
                            float m02,
                            float m03,
                            float m10,
                            float m11,
                            float m12,
                            float m13,
                            float m20,
                            float m21,
                            float m22,
                            float m23,
                            float m30,
                            float m31,
                            float m32,
                            float m33)
Sets the mat4 parameter with name to the given value

Parameters:
name - String
m00 - float ...

setModelviewMatrix

public void setModelviewMatrix(java.lang.String param)
Sets the parameter param with the current contents of the OpenGL modelview matrix.

Parameters:
param - String

setProjectionMatrix

public void setProjectionMatrix(java.lang.String param)
Sets the parameter param with the current contents of the OpenGL projection matrix.

Parameters:
param - String

setModelviewProjectionMatrix

public void setModelviewProjectionMatrix(java.lang.String param)
Sets the parameter param with the current contents of the OpenGL modelview-projection matrix.

Parameters:
param - String

setTexMatrix

public void setTexMatrix(java.lang.String param)
Sets the parameter param with the current contents of the OpenGL texture matrix.

Parameters:
param - String

setMatrixParameterBySemantic

public void setMatrixParameterBySemantic(java.lang.String semantic,
                                         int matrix)
Sets the matrix parameter identified by semantic, and adding no post-transformation to the matrix.

Parameters:
semantic - name string of the semantic attached to the parameter
matrix - int

setMatrixParameterBySemantic

public void setMatrixParameterBySemantic(java.lang.String semantic,
                                         int matrix,
                                         int gltransform)
Sets the parameter with the given semantic with the current contents of the specified matrix, applying a certain transformation. gltransform should be one of (IDENTITY_MATRIX, INVERSE_MATRIX, TRANSPOSE_MATRIX or INVERSE_TRANSPOSE_MATRIX. It is a transformation post-applied to the specified matrix.

Parameters:
semantic - String
matrix - int
gltransform - int

setModelviewMatrixBySemantic

public void setModelviewMatrixBySemantic(java.lang.String semantic)
Passes OpenGL's modelview matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.

Parameters:
semantic - name string of the semantic attached to the parameter

setModelviewMatrixBySemantic

public void setModelviewMatrixBySemantic(java.lang.String semantic,
                                         int gltransform)
Sets the parameter with the given semantic with the current contents of the modelview matrix, applying a certain transformation. gltransform should be one of (IDENTITY_MATRIX, INVERSE_MATRIX, TRANSPOSE_MATRIX or INVERSE_TRANSPOSE_MATRIX. It is a transformation post-applied to the specified matrix.

Parameters:
semantic - String
gltransform - int

setProjectionMatrixBySemantic

public void setProjectionMatrixBySemantic(java.lang.String semantic)
Passes OpenGL's projection matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.

Parameters:
semantic - name string of the semantic attached to the parameter

setProjectionMatrixBySemantic

public void setProjectionMatrixBySemantic(java.lang.String semantic,
                                          int gltransform)
Sets the parameter with the given semantic with the current contents of the projection matrix, applying a certain transformation. gltransform should be one of (IDENTITY_MATRIX, INVERSE_MATRIX, TRANSPOSE_MATRIX or INVERSE_TRANSPOSE_MATRIX. It is a transformation post-applied to the specified matrix.

Parameters:
semantic - String
gltransform - int

setModelviewProjectionMatrixBySemantic

public void setModelviewProjectionMatrixBySemantic(java.lang.String semantic)
Passes OpenGL's modelview-projection matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.

Parameters:
semantic - name string of the semantic attached to the parameter

setModelviewProjectionMatrixBySemantic

public void setModelviewProjectionMatrixBySemantic(java.lang.String semantic,
                                                   int gltransform)
Sets the parameter with the given semantic with the current contents of the modelview-projection matrix, applying a certain transformation. gltransform should be one of (IDENTITY_MATRIX, INVERSE_MATRIX, TRANSPOSE_MATRIX or INVERSE_TRANSPOSE_MATRIX. It is a transformation post-applied to the specified matrix.

Parameters:
semantic - String
gltransform - int

setTextureMatrixBySemantic

public void setTextureMatrixBySemantic(java.lang.String semantic)
Passes OpenGL's texture matrix to the Cg parameter identified by semantic, and adding no post-transformation to the matrix.

Parameters:
semantic - name string of the semantic attached to the parameter

setTextureMatrixBySemantic

public void setTextureMatrixBySemantic(java.lang.String semantic,
                                       int gltransform)
Sets the parameter with the given semantic with the current contents of the texture matrix, applying a certain transformation. gltransform should be one of (IDENTITY_MATRIX, INVERSE_MATRIX, TRANSPOSE_MATRIX or INVERSE_TRANSPOSE_MATRIX. It is a transformation post-applied to the specified matrix.

Parameters:
semantic - String
gltransform - int

setTexParameterBySemantic

public void setTexParameterBySemantic(java.lang.String semantic,
                                      GLTexture tex)
Sets the parameter with indicated semantic to the given texture

Parameters:
semantic - String
tex - GLTexture

setIntParameterBySemantic

public void setIntParameterBySemantic(java.lang.String semantic,
                                      int x)
Sets the int parameter with indicated semantic to the given value

Parameters:
semantic - String
x - int

setFloatParameterBySemantic

public void setFloatParameterBySemantic(java.lang.String semantic,
                                        float x)
Sets the float parameter with indicated semantic to the given value

Parameters:
semantic - String
x - float

setVecParameterBySemantic

public void setVecParameterBySemantic(java.lang.String semantic,
                                      float x,
                                      float y)
Sets the vec2 parameter with indicated semantic to the given values

Parameters:
semantic - String
x - float
y - float

setVecParameterBySemantic

public void setVecParameterBySemantic(java.lang.String semantic,
                                      float x,
                                      float y,
                                      float z)
Sets the vec3 parameter with indicated semantic to the given values

Parameters:
semantic - String
x - float
y - float
z - float

setVecParameterBySemantic

public void setVecParameterBySemantic(java.lang.String semantic,
                                      float x,
                                      float y,
                                      float z,
                                      float w)
Sets the vec4 parameter with indicated semantic to the given values

Parameters:
semantic - String
x - float
y - float
z - float
w - float

setMatParameterBySemantic

public void setMatParameterBySemantic(java.lang.String semantic,
                                      float m00,
                                      float m01,
                                      float m10,
                                      float m11)
Sets the mat2 parameter with indicated semantic to the given values

Parameters:
semantic - String
m00 - float ...

setMatParameterBySemantic

public void setMatParameterBySemantic(java.lang.String semantic,
                                      float m00,
                                      float m01,
                                      float m02,
                                      float m10,
                                      float m11,
                                      float m12,
                                      float m20,
                                      float m21,
                                      float m22)
Sets the mat3 parameter with indicated semantic to the given values

Parameters:
semantic - String
m00 - float ...

setMatParameterBySemantic

public void setMatParameterBySemantic(java.lang.String semantic,
                                      float m00,
                                      float m01,
                                      float m02,
                                      float m03,
                                      float m10,
                                      float m11,
                                      float m12,
                                      float m13,
                                      float m20,
                                      float m21,
                                      float m22,
                                      float m23,
                                      float m30,
                                      float m31,
                                      float m32,
                                      float m33)
Sets the mat4 parameter with indicated semantic to the given values

Parameters:
semantic - String
m00 - float ...

setMatrixParameterBySemantic

public void setMatrixParameterBySemantic(java.lang.String semantic,
                                         float[] mat)
Sets the matrix parameter with indicated semantic to the given values

Parameters:
semantic - String
mat - float[]

getCgMatrixTransform

public int getCgMatrixTransform(int glcode)


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