Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

opengl

fbo

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?

like image 679
darius Avatar asked Aug 03 '13 04:08

darius


2 Answers

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.

like image 109
Nicol Bolas Avatar answered Oct 02 '22 16:10

Nicol Bolas


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

like image 43
starmole Avatar answered Oct 02 '22 15:10

starmole