Reverse glScissor ?

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.
[ATTACH=CONFIG]194[/ATTACH]
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 ?

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.

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 :smiley: