codeanticode.glgraphics
Class GLTextureFilter

java.lang.Object
  extended by codeanticode.glgraphics.GLTextureFilter

public class GLTextureFilter
extends java.lang.Object

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 distorsions 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
protected  boolean blendOn
           
protected  GLTextureFilterParameters defFilterParams
           
protected  java.lang.String description
           
protected  int[] destFBO
           
protected  int destTexSizeUniform
           
protected  int fadeConstUniform
           
protected  GL gl
           
protected  GLState glstate
           
protected  GLTextureGrid grid
           
protected  int numInputTex
           
protected  processing.core.PApplet parent
           
protected  PGraphicsOpenGL pgl
           
protected  GLSLShader shader
           
protected  int[] srcTexOffsetUniform
           
protected  int[] srcTexUnitUniform
           
protected  int timingDataUniform
           
protected  XMLElement xmlFilterCfg
           
 
Constructor Summary
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.lang.String filename, GLTextureFilterParameters params)
          Creates an instance of GLTextureFilter, loading the filter from filename and using the parameter params.
GLTextureFilter(processing.core.PApplet parent, java.lang.String filename, int nInTex)
          Creates an instance of GLTextureFilter, loading the filter from filename.
GLTextureFilter(processing.core.PApplet parent, java.lang.String filename, int nInTex, GLTextureFilterParameters params)
          Creates an instance of GLTextureFilter, loading the filter from filename.
 
Method Summary
 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, float fadeConst)
          Applies the shader program on textures srcTex, writing the output to the textures destTex.
 void apply(GLTexture[] srcTex, GLTexture[] destTex, float fade, GLTextureFilterParameters params)
          Applies the shader program on textures srcTex, writing the output to the textures destTex.
 void apply(GLTexture[] srcTex, GLTexture[] destTex, GLTextureFilterParameters params)
          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 srcTex0, GLTexture srcTex1, GLTexture destTex)
          Applies the shader program on textures srcTex0 and srcTex1, writing the output to the texture destTex.
 void apply(GLTexture srcTex0, GLTexture srcTex1, GLTexture srcTex2, GLTexture destTex)
          Applies the shader program on textures srcTex0, srcTex1 and srcTex2, writing the output to the texture destTex.
 void apply(GLTexture srcTex0, GLTexture srcTex1, GLTexture srcTex2, GLTexture srcTex3, GLTexture destTex)
          Applies the shader program on textures srcTex0, srcTex1, srcTex2 and srcTex3, writing the output to the texture destTex.
protected  void bindDestFBO()
           
protected  void bindDestTexToFBO(GLTexture[] destTex)
           
protected  void bindSrcTex(GLTexture[] srcTex)
           
protected  void checkDestTex(GLTexture[] destTex, int w, int h)
           
protected  void checkFBO()
           
 GLTextureFilterParameters getDefParams()
          Returns default parameters of the filter.
 java.lang.String getDescription()
          Returns the description of the filter.
 int getNumInputTextures()
          Returns the number of input or source textures supported by this filter.
protected  void initFBO()
           
protected  void initFilter(int nInTex, GLTextureFilterParameters params)
           
protected  void restoreGLConf()
           
protected  void setGLConf(int w, int h)
           
protected  void unbindDestFBO()
           
protected  void unbindSrcTex(int ntex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected processing.core.PApplet parent

gl

protected GL gl

pgl

protected PGraphicsOpenGL pgl

glstate

protected GLState glstate

destFBO

protected int[] destFBO

grid

protected GLTextureGrid grid

defFilterParams

protected GLTextureFilterParameters defFilterParams

xmlFilterCfg

protected XMLElement xmlFilterCfg

description

protected java.lang.String description

blendOn

protected boolean blendOn

shader

protected GLSLShader shader

numInputTex

protected int numInputTex

srcTexUnitUniform

protected int[] srcTexUnitUniform

srcTexOffsetUniform

protected int[] srcTexOffsetUniform

timingDataUniform

protected int timingDataUniform

fadeConstUniform

protected int fadeConstUniform

destTexSizeUniform

protected int destTexSizeUniform
Constructor Detail

GLTextureFilter

public GLTextureFilter(processing.core.PApplet parent,
                       java.lang.String filename)
Creates an instance of GLTextureFilter, loading the filter from filename. The number of input textures is set to 1.

Parameters:
parent - PApplet
filename - String

GLTextureFilter

public GLTextureFilter(processing.core.PApplet parent,
                       java.lang.String filename,
                       GLTextureFilterParameters params)
Creates an instance of GLTextureFilter, loading the filter from filename and using the parameter params. The number of input textures is set to 1.

Parameters:
parent - PApplet
filename - String
params - GLTextureFilterParameters

GLTextureFilter

public GLTextureFilter(processing.core.PApplet parent,
                       java.lang.String filename,
                       int nInTex)
Creates an instance of GLTextureFilter, loading the filter from filename. The filter will be able to accept up to nInTex input or source textures.

Parameters:
parent - PApplet
filename - String
nInTex - int

GLTextureFilter

public GLTextureFilter(processing.core.PApplet parent,
                       java.lang.String filename,
                       int nInTex,
                       GLTextureFilterParameters params)
Creates an instance of GLTextureFilter, loading the filter from filename. The filter will be able to accept up to nInTex input or source textures. It uses params as the default parameters.

Parameters:
parent - PApplet
filename - String
nInTex - int
params - GLTextureFilterParameters
Method Detail

getDescription

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

Returns:
String

getNumInputTextures

public int getNumInputTextures()
Returns the number of input or source textures supported by this filter.

Returns:
int

getDefParams

public GLTextureFilterParameters getDefParams()
Returns default parameters of the filter.

Returns:
GLTextureFilterParameters

apply

public void apply(GLTexture srcTex,
                  GLTexture destTex)
Applies the shader program on texture srcTex, writing the output to the texture destTex. The default parameter with all the fields set to zero is used.

Parameters:
srcTex - GLTexture
destTex - GLTexture

apply

public void apply(GLTexture srcTex0,
                  GLTexture srcTex1,
                  GLTexture destTex)
Applies the shader program on textures srcTex0 and srcTex1, writing the output to the texture destTex. The default parameter with all the fields set to zero is used.

Parameters:
srcTex0 - GLTexture
srcTex1 - GLTexture
destTex - GLTexture

apply

public void apply(GLTexture srcTex0,
                  GLTexture srcTex1,
                  GLTexture srcTex2,
                  GLTexture destTex)
Applies the shader program on textures srcTex0, srcTex1 and srcTex2, writing the output to the texture destTex. The default parameter with all the fields set to zero is used.

Parameters:
srcTex0 - GLTexture
srcTex1 - GLTexture
srcTex2 - GLTexture
destTex - GLTexture

apply

public void apply(GLTexture srcTex0,
                  GLTexture srcTex1,
                  GLTexture srcTex2,
                  GLTexture srcTex3,
                  GLTexture destTex)
Applies the shader program on textures srcTex0, srcTex1, srcTex2 and srcTex3, writing the output to the texture destTex. The default parameter with all the fields set to zero is used.

Parameters:
srcTex0 - GLTexture
srcTex1 - GLTexture
srcTex2 - GLTexture
srcTex3 - 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. The default parameter with all the fields set to zero is used.

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

apply

public void apply(GLTexture[] srcTex,
                  GLTexture[] destTex,
                  float fadeConst)
Applies the shader program on textures srcTex, writing the output to the textures destTex. Uses fade constant provided, and the default parameters.

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

apply

public void apply(GLTexture[] srcTex,
                  GLTexture[] destTex,
                  GLTextureFilterParameters params)
Applies the shader program on textures srcTex, writing the output to the textures destTex. Uses the provided parameters params, and sets fade constant to 1.

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

apply

public void apply(GLTexture[] srcTex,
                  GLTexture[] destTex,
                  float fade,
                  GLTextureFilterParameters params)
Applies the shader program on textures srcTex, writing the output to the textures destTex. Uses the provided parameters params and fade constant.

Parameters:
srcTex - GLTexture[]
destTex - GLTexture[]
fade - float
params - GLTextureFilterParameters

setGLConf

protected void setGLConf(int w,
                         int h)

restoreGLConf

protected void restoreGLConf()

bindSrcTex

protected void bindSrcTex(GLTexture[] srcTex)

unbindSrcTex

protected void unbindSrcTex(int ntex)

bindDestFBO

protected void bindDestFBO()

unbindDestFBO

protected void unbindDestFBO()

bindDestTexToFBO

protected void bindDestTexToFBO(GLTexture[] destTex)

checkFBO

protected void checkFBO()

initFBO

protected void initFBO()

initFilter

protected void initFilter(int nInTex,
                          GLTextureFilterParameters params)

checkDestTex

protected void checkDestTex(GLTexture[] destTex,
                            int w,
                            int h)