PDA

View Full Version : clear a GL_R32UI renderbuffer with an int



schr_10
01-04-2011, 06:33 AM
Hi,
I have trouble finding anything on how to clear an integer renderbuffer.
glClear(GL_COLOR_BUFFER_BIT) does set it to zero, but how can I set it to a different value?
Thanks,
Soren

carsten neumann
01-04-2011, 09:04 AM
Take a look at glClearBuffer (http://www.opengl.org/sdk/docs/man4/xhtml/glClearBuffer.xml).

arekkusu
01-04-2011, 12:03 PM
Or glClearColorIiEXT from EXT_texture_integer.

schr_10
01-06-2011, 02:45 AM
Thanks guys,
I have had a look at glClearBuffer but am unable to find a suitable example. Also the documentation does not specify integer use outside of depth and and stencil buffers.
Did not have any luck with the extensions either so may just draw a textured quad in stead.
Thanks
Soren

aqnuep
01-06-2011, 02:55 AM
Just use the following code:

unsigned int clear_value = put_here_your_clear_value;
glClearBufferuiv(GL_COLOR, 0, &clear_value);

Here GL_COLOR and 0 specifies that the first color buffer has to be cleared with the specified clear value.

schr_10
01-06-2011, 03:49 AM
That works! Thanks so much - I skipped over glClearBuffer too fast.
Thanks again!

Soren

aqnuep
01-06-2011, 06:06 AM
Before you try out my previous code, sorry, but I wrote it incorrectly, because the clear value must always be a vec4 value (even though you need only the red component), so the code should be like this:


unsigned int clear_value[4] = { put_here_your_clear_value, 0, 0, 0 };
glClearBufferuiv(GL_COLOR, 0, clear_value);