How to reset my texture?

Started by
2 comments, last by ak09 10 years, 12 months ago

I have a FBO holding a texture, and to that texture I need to apply a post-processing filter, which is done via GLSL.
So, the way I found to do so:


    glUseProgram(program);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboDst); //fboDst has an empty texture (newTex)
    // ... draw fboSrc texture (oldTex)
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    glUseProgram(0);
    copyImage(&fboDst, &fboSrc); // Replace oldTex by newTex via glBlitFramebufferEXT

Ok. At this point, fboSrc contains my wanted filtered texture. But what if I try to filter it again? Now fboDst isn't clear anymore.
So I ask you: how to fully clear it, including the alpha channel, without having to recreate everything?

PS: Have tried glClearColor(1, 1, 1, 0) + glClear(GL_COLOR_BUFFER_BIT) but it seems to screw up my scene.

Advertisement

Hi.

You need to use Ping-Pong texturing. Check out this article which presents an "n" pass post-processing method with FBOs: Tutorial - Post Processing

You can clear a bound FBO texture by using glClearBuffer: http://www.opengl.org/sdk/docs/man3/xhtml/glClearBuffer.xml

This is available with OpenGL 3.3 or higher, and for best compatibility I'd advise that you stop using the "EXT" versions of the FBO calls and tokens and start using the core GL equivalent.

Another option is to store the values you wish to clear to in a PBO, and glTexSubImage from the PBO. That won't involve any FBO changes, will work with downlevel GL, and - since the PBO can be static - should do the transfer entirely on the GPU.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

You can clear a bound FBO texture by using glClearBuffer: http://www.opengl.org/sdk/docs/man3/xhtml/glClearBuffer.xml

This is available with OpenGL 3.3 or higher, and for best compatibility I'd advise that you stop using the "EXT" versions of the FBO calls and tokens and start using the core GL equivalent.

Another option is to store the values you wish to clear to in a PBO, and glTexSubImage from the PBO. That won't involve any FBO changes, will work with downlevel GL, and - since the PBO can be static - should do the transfer entirely on the GPU.


Thank you! It worked smoothly! By the way, what's wrong with the 'EXT'? (I'm new on FBO's).

Hi.

You need to use Ping-Pong texturing. Check out this article which presents an "n" pass post-processing method with FBOs: Tutorial - Post Processing


Thanks for the further reading.

This topic is closed to new replies.

Advertisement