I am planning to draw a rectangle with a hole in its center. I am trying to use the stencil test on it but I can't make it work. You can see below for how I do it.
glEnable(GL_STENCIL_TEST);
glColorMask(GL_FALSE,GL_FALSE, GL_FALSE, GL_FALSE);
glDepthMask(GL_FALSE);
glStencilFunc(GL_ALWAYS, 2, ~0);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
// Draw the rectangle here
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilFunc(GL_EQUAL, 2, ~0);
glStencilOp(GL_INCR, GL_INCR, GL_INCR);
What am I doing wrong here? Any help would much be appreciated! :)