#include <FBO_Filter.h>
Public Member Functions | |
| FBO_Filter (CGprofile cgp, char *name, GLuint outputTex, int W, int H) | |
| GLuint | apply (GLuint iTex, bool FBOtex) |
FBO Filter is a generic image filter class which uses framebuffers.
|
||||||||||||||||||||||||
|
|
|
||||||||||||
|
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();
}
|
1.4.0