Jump to content


stencil.c : eerie behavior ?


1 reply to this topic

#1 Whilibarj

    New Member

  • Members
  • Pip
  • 1 posts

Posted 04 April 2005 - 02:34 PM

I took the stencil.c example and I made a little modification.

http://www.opengl.org/resources/code/basic...dbook/stencil.c


I made this change in the display function :


void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

/* draw blue sphere where the stencil is 1 */
glStencilFunc (GL_EQUAL, 0x1, 0x1);
glStencilOp (GL_KEEP, GL_ZERO, GL_ZERO);
glCallList (BLUEMAT);
glutSolidSphere (0.5, 15, 15);

/* draw the tori where the stencil is not 1 */
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
glStencilFunc (GL_NOTEQUAL, 0x1, 0x1);
glPushMatrix();
glRotatef (45.0, 0.0, 0.0, 1.0);
glRotatef (45.0, 0.0, 1.0, 0.0);
glCallList (YELLOWMAT);
glutSolidTorus (0.275, 0.85, 15, 15);
glPushMatrix();
glRotatef (90.0, 1.0, 0.0, 0.0);
glutSolidTorus (0.275, 0.85, 15, 15);
glPopMatrix();
glPopMatrix();
}




Resize the window a few times and you will notice a very eerie behavior. Anyone can explain why ?

#2 Phaetos

    Member

  • Members
  • PipPip
  • 57 posts

Posted 05 April 2005 - 05:36 AM

I did not check yet, but I noticed you do not clear the Stencil-Buffer in the
glClear()-call...

Try: glClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

Greets
Phaetos





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users