PDA

View Full Version : Reverse glScissor ?



raziza
06-12-2012, 10:35 PM
Hey everybody,

I want to draw something and to clip some areas inside the draw, Like glScissor, but the other way around.
To define an area that the draw will not perform.


I've attached this example.
759
I draw rotated red quad.
And then I want to draw the star with an rectangle area that the star should NOT drawn over (I drew it here as the gray rectangle just for the example).

Is there a way to do it in OpenGL ?

kyle_
06-13-2012, 02:37 AM
Is there a way to do it in OpenGL ?

Yes. Use 'discard' on the region you want to remove in fragment shader.

V-man
06-13-2012, 04:30 AM
Yes. Use 'discard' on the region you want to remove in fragment shader.

Use the classical way -> Use your stencil buffer. It will run faster since stencil testing happens before the fragment shader stage and there are other optimizations at the stencil & depth testing stage.

raziza
06-13-2012, 06:56 AM
Wow... So easy.. Both ways.. Never used stencil before.. but it is easy and effective. Hope also very good in performances.

Had small problem that my stencil bits was 0, but after setting it, it works great..

Thanks all

Have good day :D