Results 1 to 4 of 4

Thread: Scissor query

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    2

    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

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    134

    Re: Scissor query

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

    Here's the man page.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2009
    Posts
    463

    Re: Scissor query

    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:

    Code :
    // 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);

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    2

    Re: Scissor query

    Cheers guys.

    Lance

Similar Threads

  1. AMD scissor bug
    By imported_Groovounet in forum OpenGL: Drivers
    Replies: 1
    Last Post: 03-10-2011, 07:12 PM
  2. scissor test
    By zadeh79 in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 10-05-2006, 08:38 PM
  3. circular scissor
    By guidigio in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-18-2003, 11:20 AM
  4. Scissor for attenuated light
    By bakery2k in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 08-19-2002, 12:38 PM
  5. non rectangular scissor, how ??
    By haust in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-01-2002, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean