문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top