Results 1 to 2 of 2

Thread: Concave Polys & Stencil Buffer

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    San Jose, CA, USA
    Posts
    4

    Concave Polys & Stencil Buffer

    Hi,

    I am trying to use the stencil buffer to render simple concave
    polygons (when detected). I found the algorithm i'm using online -
    but I think I don't have it right yet! Either my concave poly
    disappears or it gets drawn as before (i.e. with artifcats).

    This my code snippet...

    // Draw poly as set of fan tris - ie 123-
    // 134-145 etc.
    // draw into the stencil buffer
    glEnable(GL_STENCIL_TEST);
    glClear( GL_STENCIL_BUFFER_BIT );
    glColorMask(GL_FALSE,
    GL_FALSE,
    GL_FALSE,
    GL_FALSE);
    glStencilFunc(GL_ALWAYS, 0, 1);
    glStencilOp(GL_INVERT,
    GL_INVERT,
    GL_INVERT);

    int num_tris = num_children - 2;
    for( int i=0; i<num_tris; i++ )
    DrawTri(i);

    // then draw poly as normal but stencil
    // should limit drawing into the concave
    // parts. This time turn on drawing

    glStencilFunc(GL_EQUAL, 1, 1);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    glColorMask(GL_TRUE,
    GL_TRUE,
    GL_TRUE,
    GL_TRUE);

    DrawFace();

    glDisable(GL_STENCIL_TEST);

    I am sure the stencilop & func are wrong but
    I'm not that familiar with the stencil
    buffer to know what im doing wrong...?

    Any help appreciated.

    Dave

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Concave Polys & Stencil Buffer

    Crosspost. Answered in the advanced forum.

Similar Threads

  1. Replies: 1
    Last Post: 09-11-2013, 11:35 AM
  2. Concave Polygon via Stencil Buffer
    By pseudosig in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-10-2011, 01:32 PM
  3. Triangulation of concave polys
    By dabeav in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 12-05-2003, 03:56 PM
  4. Concave Polys & Stencil Buffer?
    By grafixkid2000 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-23-2003, 04:57 AM
  5. Semisolid polys and z-buffer? (trees...)
    By TB-Rex in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 08-20-2000, 09:55 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