Scissor query

Stupid noob question time…

2D stuff.

How do I rotate a set up a scissor (or the equivalent thereof) that is rotated by a certain number of degrees, i.e. I can have a diamond shaped window with whatever gets written inside it cut off by the boundary of the diamond.

I’ve hunted everywhere, through the Red book & online and seem to find an answer - the problem is, I’m not sure if scissor is what I’m really after.

Cheers

Lance

Take a look at clipping planes. Those may be what you’re looking for.

Here’s the man page.

Scissor test rectangle can’t be rotated, instead you can use the stencil test to mask drawing to any shape.

There should be plenty of example code around, but basic code for using the stencil buffer for masking is:


// Enable stencil test
glEnable(GL_STENCIL_TEST);
// Clear stencil buffer
glClearStencil(0x0);
// Disable drawing to color buffer + depth buffer 
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDepthMask(GL_FALSE);
// Draw masking object, setting stencil = 1 wherever it draws
glStencilFunc(GL_ALWAYS, 0x1, 0x1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
***draw masking object***
// Re-enable drawing to color buffer + depth buffer
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_TRUE);
// Draw rest of objects, only where stencil = 1
glStencilFunc(GL_EQUAL, 0x1, 0x1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
***draw rest of objects***
// Disable stencil test
glDisable(GL_STENCIL_TEST);

Cheers guys.

Lance