Is it possible to clear just certain textures in a framebuffer with multi target rendering?

StackOverflow https://stackoverflow.com/questions/18029258

  •  23-06-2022
  •  | 
  •  

Question

I have a framebuffer object in which I use Multi Target Rendering on N textures binded to it. At a certain time, I want to clear the content of some of those textures, but not all of them. If I call

glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

every texture binded to the FBO is going to be cleared (am I right?). Is there a way to do this on specific draw buffers/textures?

Was it helpful?

Solution

The GL_COLOR_BUFFER_BIT in the glClear call will clear all of the active draw color buffers, as specified via glDrawBuffers. So you could change the draw buffers before executing a clear.

But that's needless state changing. You can simply call glClearBuffer, which will clear a particular buffer.

OTHER TIPS

It will be all buffers. You can mask out buffers for clear with glColorMask though. http://www.opengl.org/sdk/docs/man/xhtml/glColorMask.xml

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top