Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to reset my texture?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 ak09   Members   -  Reputation: 131

Like
0Likes
Like

Posted 30 April 2013 - 08:15 PM

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.



Sponsor:

#2 Kryzon   Prime Members   -  Reputation: 3314

Like
0Likes
Like

Posted 01 May 2013 - 01:24 PM

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



#3 mhagain   Crossbones+   -  Reputation: 8284

Like
2Likes
Like

Posted 01 May 2013 - 03:36 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 ak09   Members   -  Reputation: 131

Like
0Likes
Like

Posted 01 May 2013 - 07:19 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS