PDA

View Full Version : convolution



crista
06-10-2003, 01:25 PM
Hi, I have a problem with my code. Im trying to do an aplication that loads an image and shows as a texture, then I apply a convolution filter to this texture.
I want to render the new result, and I use glCopyTexSubImage* to copy from the frame buffer. My problem is that when my aplication do this, the image is not the correct because the frame buffer have the image resultant of apply the convolution.

Here is my code:
INIT:
GLfloat filter[] = {1.0,2.0,1.0, 0.0,0.0,0.0, -1.0,-2.0,-1.0};

glConvolutionFilter2D(GL_CONVOLUTION_2D,GL_LUMINAN CE,3,3,GL_LUMINANCE,
GL_FLOAT,filter);
}
glConvolutionParameteri(GL_CONVOLUTION_2D,GL_CONVO LUTION_BORDER_MODE,
GL_CONSTANT_BORDER);

glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture[1]);
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,256,25 6);

RENDER:
void render (void)
{
init;

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glColor3f(1.0,1.0,1.0);

glBindTexture(GL_TEXTURE_2D, texture[1]);

glBegin(GL_QUADS);

glTexCoord2f(0.0, 1.0);glVertex3f( -1, 1, 0.0);
glTexCoord2f(1.0, 1.0);glVertex3f( 1, 1, 0.0);
glTexCoord2f(1.0, 0.0);glVertex3f( 1, -1, 0.0);
glTexCoord2f(0.0, 0.0);glVertex3f( -1, -1, 0.0);
glEnd();
glutSetWindow(id_w1);
glutSwapBuffers();
glutPostRedisplay();

}