PDA

View Full Version : non rectangular scissor, how ??



haust
03-01-2002, 05:54 AM
Is there a way to acheive scissor effect with non rectangular shapes ??

Gorg
03-01-2002, 06:55 AM
You can use the stencil buffer.

AdrianD
03-01-2002, 07:14 AM
use the stencil buffer:

.
draw your scene first...
.

glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS,1,1);
glStencilOp(GL_REPLACE,GL_REPLACE,GL_REPLACE);

.
draw your clipping-shape
.

// to draw inside the clipping shape...
glStencilFunc(GL_EQUAL,1,1);
// to draw outside the clipping shape use:
// glStencilFunc(GL_NOTEQUAL,1,1);

glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);


.
draw the part out your scene inside the clipping-shape
.

glDisable(GL_STENCIL_TEST);


that's all.
btw.: if you have only one clipping-shape to draw, you probably should clear the stencil buffer together with the other buffers within one single glClear call.