Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

FBO_Filter Class Reference

FBO Filter is a generic image filter class which uses framebuffers. More...

#include <FBO_Filter.h>

List of all members.

Public Member Functions

 FBO_Filter (CGprofile cgp, char *name, GLuint outputTex, int W, int H)
GLuint apply (GLuint iTex, bool FBOtex)


Detailed Description

FBO Filter is a generic image filter class which uses framebuffers.

FBO Filter is a generic image filter class which uses framebuffers.


Constructor & Destructor Documentation

FBO_Filter::FBO_Filter CGprofile  cgp,
char *  name,
GLuint  outputTex,
int  W,
int  H
[inline]
 

Parameters:
cgp  Desired profile. Typically FP30 or FP40
name  filename of the Cg program. Note that the entry point function should be named "FragmentProgram" in the Cg
outputTex  the open GL texture object to which the results will go
W  width of the output texture,
H  height of the output texture


Member Function Documentation

GLuint FBO_Filter::apply GLuint  iTex,
bool  FBOtex
[inline]
 

This function applies the filter to the given texture iTex. The bool flag / denotes whether iTex is the result of a previous filtering operation or not. / So, if you were going to chain together a bunch of filters, the first / one would have FBOtex = false, and the rest FBOtex = true. This just handles / the up/down flip that seems to happen when FBO results are reused.

Typical usage might look something like:

            // Generate a texture to hold the input image 
            glGenTextures(1, &tex);              // texture 
            glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,  GL_REPLACE );
            glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex);
            glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, width,height, 0,
                         GL_RGB, GL_UNSIGNED_BYTE, Im->rgb_data );

            // Generate a texture to hold the output image.  Set the output texture's 
            // internal format to the desired output precision 
            glGenTextures(1, &oTex);              // texture 
            glBindTexture(GL_TEXTURE_RECTANGLE_NV, oTex);
            glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, width,height, 0,
                         GL_RGB, GL_UNSIGNED_BYTE, NULL );


            // Create the filter.
            filter = new FBO_Filter(CG_PROFILE_FP30,argv[1], oTex, width, height);

            ...

            // rendering loop 
            while(true) {

                 //apply the filter.  fills in oTex 
                 filter->apply( tex, false);

                 //show the resulting texture oTex 
                 glEnable(GL_TEXTURE_RECTANGLE_NV);
                 glBindTexture(GL_TEXTURE_RECTANGLE_NV, oTex) ;

                 // draw the 'tex' texture containing the framebuffer rendered drawing.
                 glBegin(GL_QUADS);
                    glTexCoord2f(0, height);
                    glVertex3f( 0.0, 1.0, d );

                    glTexCoord2f(0, 0);
                    glVertex3f( 0.0, 0.0, d );

                    glTexCoord2f(width, 0);
                    glVertex3f( 1.0, 0.0, d );

                    glTexCoord2f(width,height);
                    glVertex3f( 1.0, 1.0, d );
                glEnd();
            }

 
Parameters:
iTex  OpenGL texture object to use as input
FBOtex  set to true if the input texture is the result of a previous FBO_filter. False if not.


The documentation for this class was generated from the following file:
Generated on Mon Jun 27 14:54:29 2005 for OPENVIDIA by  doxygen 1.4.0