codeanticode.glgraphics
Class GLTextureFilter

java.lang.Object
  extended by codeanticode.glgraphics.GLTextureFilter
All Implemented Interfaces:
GLConstants, processing.core.PConstants

public class GLTextureFilter
extends java.lang.Object
implements GLConstants, processing.core.PConstants

This class defines a 2D filter to apply on GLTexture objects. A filter is basically a glsl shader program with a set of predefined uniform attributes and a 2D grid where the input textures are mapped on. The points of the 2D grid can be altered in the vertex stage of the filter, allowing for arbitrary distortions in the shape of the mesh. The filter is specified in a xml file where the files names of the vertex and fragment shaders stored, as well as the definition of the grid (resolution and spacing).


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
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BILINEAR, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLAMP, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, DYNAMIC, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, FIXED, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HAS_NORMAL, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINEAR, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, OPENGL2, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINT_SPRITES, POINTS, POLYGON, POSTERIZE, PROBLEM, PROG_GL2, PROG_GL3, PROG_GL4, PROJECT, PROJECTION, QUAD, QUAD_STRIP, QUADRATIC, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, STATIC, STREAM, SUBTRACT, SW, TAB, TARGA, TEXT, TEXTURE2D, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TRILINEAR, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
GLTextureFilter()
          Default constructor.
GLTextureFilter(processing.core.PApplet parent, java.lang.String filename)
          Creates an instance of GLTextureFilter, loading the filter from filename.
GLTextureFilter(processing.core.PApplet parent, java.net.URL url)
          Creates an instance of GLTextureFilter, loading the filter from a URL.
 
Method Summary
 void apply(GLTexture destTex)
          Applies the shader program to generate texture destTex, without any source texture.
 void apply(GLTexture[] destTex)
          Applies the shader program to generate an array of destination textures, without using any source texture.
 void apply(GLTexture[] srcTex, GLTexture destTex)
          Applies the shader program on textures srcTex, writing the output to the texture destTex.
 void apply(GLTexture[] srcTex, GLTexture[] destTex)
          Applies the shader program on textures srcTex, writing the output to the textures destTex.
 void apply(GLTexture[] srcTex, GLTexture[] destTex, GLModel destModel)
          Applies the shader program on textures srcTex, writing the output to the textures destTex.
 void apply(GLTexture srcTex, GLTexture destTex)
          Applies the shader program on texture srcTex, writing the output to the texture destTex.
 void apply(GLTexture srcTex, GLTexture destTex, GLModel destModel)
          Applies the shader program on texture srcTex, writing the output to the texture destTex and model destModel.
 void beginIterativeMode()
          Begins the iterative mode.
 void delete()
           
 void endIterativeMode()
          Ends the iterative mode.
 java.lang.String getDescription()
          Returns the description of the filter.
 java.lang.String getName()
          Returns the name of the filter.
 int getNumInputTextures()
          Returns the maximum number of input or source textures supported by this filter.
 int getNumOutputTextures()
          Returns the maximum number of output or destination textures supported by this filter.
 GLTextureFilterParameter getParameter(int i)
          Returns the i-th parameter.
 GLTextureFilterParameter getParameter(java.lang.String paramName)
          Returns the parameter with the provided name.
 int getParameterCount()
          Get number of parameters.
 java.lang.String getParameterLabel(int i)
          Returns the label of the i-th parameter.
 java.lang.String getParameterName(int i)
          Returns the name of the i-th parameter.
 int getParameterType(int i)
          Returns the type of the i-th parameter.
 boolean hasParameter(java.lang.String paramName)
          Returns true of false depending on whether or not the filter has the specified parameter.
 void noBlend()
          Disables blending.
 void noCrop()
          Disables cropping of input textures.
 void noTint()
          Set the tint color to solid white.
 void setBlendMode(int MODE)
          Enables blending and sets the mode.
 void setCrop(int x, int y, int w, int h)
          Sets cropping region to be applied on the input textures.
 void setParameterValue(int n, float value)
          Sets the parameter value when the type is float.
 void setParameterValue(int n, float[] value)
          Sets the parameter value for any type.
 void setParameterValue(int n, int value)
          Sets the parameter value when the type is int.
 void setParameterValue(int n, int i, float value)
          Sets the ith value for the parameter (only valid for vec or mat types).
 void setParameterValue(int n, int i, int j, float value)
          Sets the (ith, jth) value for the parameter (only valid for mat types).
 void setParameterValue(java.lang.String paramName, float value)
          Sets the parameter value when the type is float.
 void setParameterValue(java.lang.String paramName, float[] value)
          Sets the parameter value for any type.
 void setParameterValue(java.lang.String paramName, int value)
          Sets the parameter value when the type is int.
 void setParameterValue(java.lang.String paramName, int i, float value)
          Sets the ith value for the parameter (only valid for vec or mat types).
 void setParameterValue(java.lang.String paramName, int i, int j, float value)
          Sets the (ith, jth) value for the parameter (only valid for mat types).
 void setParameterValues(float[]... values)
          Sets all the value for all the parameters, by means of a parameter list of variable length.
 void setTint(float gray)
          Set the tint color to the specified gray tone.
 void setTint(float gray, float alpha)
          Set the tint color to the specified gray tone and alpha value.
 void setTint(float x, float y, float z)
          Set the tint color to the specified color components.
 void setTint(float x, float y, float z, float a)
          Set the tint color to the specified color components and alpha component.
 void setTint(int rgb, float alpha)
          Set the tint color to the specified rgb color and alpha value.
 void setTint(int gray, int alpha)
          Set the tint color to the specified gray tone and alpha value.
 void setTint(int x, int y, int z)
          Set the tint color to the specified color components.
 void setTint(int x, int y, int z, int a)
          Set the tint color to the specified color components and alpha component.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLTextureFilter

public GLTextureFilter()
Default constructor.


GLTextureFilter

public GLTextureFilter(processing.core.PApplet parent,
                       java.lang.String filename)
Creates an instance of GLTextureFilter, loading the filter from filename.

Parameters:
parent - PApplet
filename - String

GLTextureFilter

public GLTextureFilter(processing.core.PApplet parent,
                       java.net.URL url)
Creates an instance of GLTextureFilter, loading the filter from a URL.

Method Detail

delete

public void delete()

getName

public java.lang.String getName()
Returns the name of the filter.

Returns:
String

getDescription

public java.lang.String getDescription()
Returns the description of the filter.

Returns:
String

getNumInputTextures

public int getNumInputTextures()
Returns the maximum number of input or source textures supported by this filter. It can be called with less than that number

Returns:
int

getNumOutputTextures

public int getNumOutputTextures()
Returns the maximum number of output or destination textures supported by this filter.

Returns:
int

apply

public void apply(GLTexture srcTex,
                  GLTexture destTex)
Applies the shader program on texture srcTex, writing the output to the texture destTex. Sets fade constant to 1.

Parameters:
srcTex - GLTexture
destTex - GLTexture

apply

public void apply(GLTexture srcTex,
                  GLTexture destTex,
                  GLModel destModel)
Applies the shader program on texture srcTex, writing the output to the texture destTex and model destModel. Sets fade constant to 1.

Parameters:
srcTex - GLTexture
destTex - GLTexture
destTex - GLModel

apply

public void apply(GLTexture[] srcTex,
                  GLTexture destTex)
Applies the shader program on textures srcTex, writing the output to the texture destTex.

Parameters:
srcTex - GLTexture[]
destTex - GLTexture

apply

public void apply(GLTexture[] srcTex,
                  GLTexture[] destTex)
Applies the shader program on textures srcTex, writing the output to the textures destTex.

Parameters:
srcTex - GLTexture[]
destTex - GLTexture[]

apply

public void apply(GLTexture destTex)
Applies the shader program to generate texture destTex, without any source texture.

Parameters:
destTex - GLTexture

apply

public void apply(GLTexture[] destTex)
Applies the shader program to generate an array of destination textures, without using any source texture.

Parameters:
destTex - GLTexture[]

apply

public void apply(GLTexture[] srcTex,
                  GLTexture[] destTex,
                  GLModel destModel)
Applies the shader program on textures srcTex, writing the output to the textures destTex.

Parameters:
srcTex - GLTexture[]
destTex - GLTexture[]

noTint

public void noTint()
Set the tint color to solid white.


setTint

public void setTint(float gray)
Set the tint color to the specified gray tone.

Parameters:
gray - float

setTint

public void setTint(int gray,
                    int alpha)
Set the tint color to the specified gray tone and alpha value.

Parameters:
gray - int
alpha - int

setTint

public void setTint(int rgb,
                    float alpha)
Set the tint color to the specified rgb color and alpha value.

Parameters:
rgb - int
alpha - float

setTint

public void setTint(float gray,
                    float alpha)
Set the tint color to the specified gray tone and alpha value.

Parameters:
gray - float
alpha - float

setTint

public void setTint(int x,
                    int y,
                    int z)
Set the tint color to the specified color components.

Parameters:
x - int
y - int
z - int

setTint

public void setTint(float x,
                    float y,
                    float z)
Set the tint color to the specified color components.

Parameters:
x - float
y - float
z - float

setTint

public void setTint(int x,
                    int y,
                    int z,
                    int a)
Set the tint color to the specified color components and alpha component.

Parameters:
x - int
y - int
z - int
a - int

setTint

public void setTint(float x,
                    float y,
                    float z,
                    float a)
Set the tint color to the specified color components and alpha component.

Parameters:
x - float
y - float
z - float
a - float

noCrop

public void noCrop()
Disables cropping of input textures.


setCrop

public void setCrop(int x,
                    int y,
                    int w,
                    int h)
Sets cropping region to be applied on the input textures.


noBlend

public void noBlend()
Disables blending.


setBlendMode

public void setBlendMode(int MODE)
Enables blending and sets the mode.

Parameters:
MODE - int

hasParameter

public boolean hasParameter(java.lang.String paramName)
Returns true of false depending on whether or not the filter has the specified parameter.

Parameters:
String - paramName

setParameterValue

public void setParameterValue(java.lang.String paramName,
                              int value)
Sets the parameter value when the type is int.

Parameters:
String - paramName
int - value

setParameterValue

public void setParameterValue(java.lang.String paramName,
                              float value)
Sets the parameter value when the type is float.

Parameters:
String - paramName
float - value

setParameterValue

public void setParameterValue(java.lang.String paramName,
                              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:
String - paramName
value - float[]

setParameterValue

public void setParameterValue(java.lang.String paramName,
                              int i,
                              float value)
Sets the ith value for the parameter (only valid for vec or mat types).

Parameters:
String - paramName
int - i
value - float

setParameterValue

public void setParameterValue(java.lang.String paramName,
                              int i,
                              int j,
                              float value)
Sets the (ith, jth) value for the parameter (only valid for mat types).

Parameters:
String - paramName
int - i
int - j
value - float

setParameterValues

public void setParameterValues(float[]... values)
Sets all the value for all the parameters, by means of a parameter list of variable length. values is an array of float[].

Parameters:
float[] - values

getParameterCount

public int getParameterCount()
Get number of parameters.

Returns:
int

getParameterType

public int getParameterType(int i)
Returns the type of the i-th parameter.

Returns:
int

getParameterName

public java.lang.String getParameterName(int i)
Returns the name of the i-th parameter.

Returns:
String

getParameterLabel

public java.lang.String getParameterLabel(int i)
Returns the label of the i-th parameter.

Returns:
String

getParameter

public GLTextureFilterParameter getParameter(int i)
Returns the i-th parameter.

Returns:
GLTextureFilterParameter

setParameterValue

public void setParameterValue(int n,
                              int value)
Sets the parameter value when the type is int.

Parameters:
int - n
int - value

setParameterValue

public void setParameterValue(int n,
                              float value)
Sets the parameter value when the type is float.

Parameters:
int - n
float - value

setParameterValue

public void setParameterValue(int n,
                              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:
int - n
value - float[]

setParameterValue

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

Parameters:
int - n
int - i
value - float

setParameterValue

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

Parameters:
int - n
int - i
int - j
value - float

getParameter

public GLTextureFilterParameter getParameter(java.lang.String paramName)
Returns the parameter with the provided name.

Returns:
GLTextureFilterParameter

beginIterativeMode

public void beginIterativeMode()
Begins the iterative mode. In this mode, the FBO of this filter is made current and then any framebuffer stack operation is disabled, to avoid subsequent framebuffer changes until endIterativeMode() is called. This mode is useful when using filters in an iterative or chained scheme: ... filter[i].apply(tex[i], tex[i+1]); filter[i+1].apply(tex[i+1], tex[i+2]); ... If all the textures have the same resolution, then there is no need to change the framebuffer since the same will serve for all the filter operations. Since FBO swap can introduce a performance hit, this mode could result in some optimization under this kind of usage patterns.


endIterativeMode

public void endIterativeMode()
Ends the iterative mode.



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