Clear/Delete certain pixels?

Started by Jack2606, January 11, 2011, 00:04:54

Previous topic - Next topic

Jack2606

Hi,

I've built a project and i've rendered some cubes in certain coordinate locations, I'm very new to LWJGL/OpenGL so i'm wonder how I would go about deleting or clearing certain pixels that I have rendered.

E.g. if i've created a cube of 0.1f*0.1f*0.1f at coordinates (10,10,10) how would I go about clearing *just* those specific coordinates?

Hope that makes sense! Done a few searches and cant find anything too helpful.. Took a look at glScissor but I need to be able to clear an area of 3 Dimensions whereas it seems to clear everything within the X/Y window.

Cheers!

kappa

With OpenGL you typically clear the whole screen and redraw every frame, so in this case you can just redraw the parts you need shown.

Kai

Hi,

you can use the stencil mechanism.
First, you activate stencil write and say to it "hey, write a 1 to the stencil buffer for each rendered pixel".
Then you clear the stencil buffer.
Then, you just render the cubes.
What you have now is 1's in the stencil buffer for each pixel where the cubes are drawn to and 0's everywhere else.

You can then clear only those areas by drawing a full-screen quad with the appropriate color using stencil testing (test whether stencil value is 1).
This results in only those areas being "cleared" where the original cubes have been drawn to.

Please search for OpenGL stencil buffer to see what functions with what parameters you can use there.