views:

34

answers:

1

I can comfortably render a scene to a texture and map that texture back onto a framebuffer for screen display. But what if I wanted to map the texture back onto itself in order to blur it (say, at a quarter opacity in a new location). Is that possible?

The way I've done it is simply to enable the texture:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, color_tex);

And then draw to it:

glVertexPointer(2, GL_FLOAT, 0, sv);
glTexCoordPointer(2, GL_FLOAT, 0, tcb1);
glColor4f (1.0f,1.0f,1.0f,0.25f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

(some code omitted, obviously)

Is there anything obviously wrong with that idea? Am I being an idiot?

+2  A: 

No, you can't write the texture to the same texture, that triggers undefined behaviour.

But you can use a technique called Ping-Pong rendering, so you draw the result of the operation into another texture, and if you need to do more processing, you write the result to the first texture.

Matias Valdenegro
You are an absolute star. Thanks for helping out again.
mtc06