Quote:Original post by daniel_i_l
Do you think that you (or someone else) could explain more? Maybe with a little code?
Thanks.
Let me try. First, you must request a stencil buffer when you create your window. Then do something like I do:
glClear(GL_STENCIL_BUFFER_BIT); // Clear the stencilglEnable(GL_STENCIL_TEST); //Enable stencil testglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); //Disable color writes// Now set the stencil to create a 2d mask of the object// Increase the value in the stencil buffer if the depth test passes// ie, if it's visibleglStencilFunc(GL_ALWAYS, 1, 0xffff); // the stencil test always passesglStencilOp(GL_KEEP, GL_INCR, GL_INCR);object.Draw();// At this point we have a mask of values > 0 where the object is// so we set the stencilfunc to allow fragments where stencil >= 1glStencilFunc(GL_GEQUAL, 1, 0xffff);glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify the valuesglLineWidth(5.0f);glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);object.DrawInWireframe();glDisable(GL_STENCIL_TEST);
That's it, i think. I hope you understand it, I'm not too good at explaining things.