I’m trying to use stencilling to control where my reflected object is visible like I’ve seen in several tutorials, but I can’t seem to prevent the reflection from showing up at all. Here’s the relevant code snippet:
glClear(GL_STENCIL_BUFFER_BIT); //disable drawing glDisable(GL_DEPTH_TEST); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); //enable stencilling glEnable(GL_STENCIL_TEST); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); glStencilFunc(GL_ALWAYS, 1, 1); //would draw stencil for reflective surface here //reenable drawing glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glEnable(GL_DEPTH_TEST); //set up stencil glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); draw_reflection(); //disable stencilling glDisable(GL_STENCIL_TEST);
From what I understand of stencilling, since I haven’t specified any area to have a stencil value of 1, the object from draw_reflection shouldn’t be drawn at all. When I run the code, the reflected object shows up unchanged. What am I not understanding here?