Jump to content
  • Advertisement
Sign in to follow this  
ak09

How to reset my texture?

This topic is 2051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!