Frage

I have problems utilizing the stencil buffer, and it's seems to boil down to not work at all. Given the following code:

  glEnable(GL_STENCIL_TEST);
  glClearStencil(0);
  glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glColor4f(1, 1, 1, 1);
  glStencilFuncSeparate(GL_FRONT_AND_BACK, GL_NEVER, 0, 0);
  glStencilOpSeparate(GL_FRONT_AND_BACK, GL_INCR, GL_INCR, GL_INCR);
  glBegin(GL_TRIANGLES);
  { draw something }
  glEnd();

The triangles are still drawn!? Am I missing something trivial here?

Note: I'm not rendering to a frame buffer, I'm using glStencil...Separate just to make sure it's not related to front\back, I've kept bits of code that to me doesn't seem related.

War es hilfreich?

Lösung

You don't have a stencil buffer. And by the specification (from 4.3 core, folio page 432):

If there is no stencil buffer, no stencil modification can occur, and it is as if the stencil tests always pass, regardless of any calls to StencilFunc.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top