   Stencil Buffer Conundrum
  I''m playing with the stencil buffer, trying to use it to clip objects from drawing, and I''m having trouble getting the clipping to work. The idea is that I''m trying to draw a 3d object onto a HUD and clip it by the "window" that I''m displaying the object in. This is where the stencil buffer comes in. The object doesn''t morph, or any spiffy toys like that, so I''m calling a display list to draw the object.After setting up my ortho view with gluOrtho2D, I set up my stencil buffer by calling:glEnable(GL_STENCIL_TEST);glStencilFunc(GL_ALWAYS, 1, 1);glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);  Then I draw the window that''s on my HUD. I note that Lesson 26 from NeHe draws the object invisibly when it''s setting the stencil buffer. Is this important to the stencil buffer for some reason? I thought it was only because the programmer wanted a nice shading effect and so chose to draw that same object later.After drawing the window to the HUD:glStencilFunc(GL_EQUAL, 1, 1);glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);  Then I draw my object, then I clear and disable the stencil buffer and stencil buffer testing with:glDisable(GL_STENCIL_TEST);glClear(GL_STENCIL_BUFFER_BIT);Is there something I''m missing?Boucoup thanks in advance.   </pre> <br><hr width="60%"><small><i>"Remember:  Silly is a state of Mind, Stupid is a way of Life."</i> -- Dave Butler</small>   
  *bump*I know I shouldn''t bump my own topic, but I''m still not sure what I''m doing wrong, and this is getting frustrating.   "Remember:  Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler;  do you have depth testing on when you draw your hud?  Also, do you have depth testing on when you draw your object?  What happens if you draw your object w/o stencil, does it show up?  You could also use glReadPixels to get the stencil buffer after rendering your HUD and dump it to a bmp or something. ;  If you just want to limit the drawing to a rectangle on the screen, use the glScissor() function. 