codeanticode.gltexture
Class GLTextureFilter

java.lang.Object
  extended by codeanticode.gltexture.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  GLTextureFilterParams defFilterParams
           
protected  java.lang.String description
           
protected  int[] destFBO
           
protected  int destTexSizeUniform
           
protected  GL gl
           
protected  GLState glstate
           
protected  GLTextureGrid grid
           
protected  int numInputTex
           
protected  PApplet parent
           
protected  int parFlt1Uniform
           
protected  int parFlt2Uniform
           
protected  int parFlt3Uniform
           
protected  int parMat2Uniform
           
protected  int parMat3Uniform
           
protected  int parMat4Uniform
           
protected  PGraphicsOpenGL pgl
           
protected  GLSLShader shader
           
protected  int[] srcTexOffsetUniform
           
protected  int[] srcTexUnitUniform
           
protected  int timingDataUniform
           
protected  XMLElement xmlFilterCfg
           
 
Constructor Summary
GLTextureFilter(PApplet parent, java.lang.String filename)
          Creates an instance of GLTextureFilter, loading the filter from filename.
GLTextureFilter(PApplet parent, java.lang.String filename, int nInTex)
          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, GLTextureFilterParams params)
          Applies the shader program on textures srcTex, writing the output to the textures 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()
           
 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)
           
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 PApplet parent

gl

protected GL gl

pgl

protected PGraphicsOpenGL pgl

glstate

protected GLState glstate

destFBO

protected int[] destFBO

grid

protected GLTextureGrid grid

defFilterParams

protected GLTextureFilterParams 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

destTexSizeUniform

protected int destTexSizeUniform

parFlt1Uniform

protected int parFlt1Uniform

parFlt2Uniform

protected int parFlt2Uniform

parFlt3Uniform

protected int parFlt3Uniform

parMat2Uniform

protected int parMat2Uniform

parMat3Uniform

protected int parMat3Uniform

parMat4Uniform

protected int parMat4Uniform
Constructor Detail

GLTextureFilter

public GLTextureFilter(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(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
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

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,
                  GLTextureFilterParams params)
Applies the shader program on textures srcTex, writing the output to the textures destTex. Uses the provide parameters params.

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

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)

checkDestTex

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