Steven Bass
11-27-2007, 01:11 PM
I'm trying to do a simple stencil test to clip some data. This works on my development system (laptop with ATI Mobility X300) but does not clip on an Nvidia Quadro FX550). I looked at various tutorials and thought I had it right (until trying the other system).
Here's what I'm doing (the comments were to help me as I worked this through and are not necessarily accurate)
Gl.glClear(Gl.GL_STENCIL_BUFFER_BIT);
// don't draw things to the screen for now
Gl.glColorMask(Gl.GL_FALSE, Gl.GL_FALSE, Gl.GL_FALSE, Gl.GL_FALSE);
Gl.glEnable(Gl.GL_STENCIL_TEST); // Enable Stencil Test
// now we setup the stencil. First we say the test always passes
// and the reference and mask are 1
Gl.glStencilFunc(Gl.GL_ALWAYS, 1, 1);
// replace the value in the buffer, replace the
Gl.glStencilOp(Gl.GL_REPLACE, Gl.GL_REPLACE, Gl.GL_REPLACE);
DrawClippingShape(); // the shape to clip against
Gl.glColorMask(Gl.GL_TRUE, Gl.GL_TRUE, Gl.GL_TRUE, Gl.GL_TRUE);
Gl.glStencilFunc(Gl.GL_EQUAL, 1, 1);
Gl.glStencilOp(Gl.GL_KEEP, Gl.GL_KEEP, Gl.GL_KEEP);
I'm not doing much other setup for this. At startup, I do:
Gl.glClearStencil(0); // clear the stencil buffer to 0s
So what have I missed?
Perplexedly,
Steve Bass
Here's what I'm doing (the comments were to help me as I worked this through and are not necessarily accurate)
Gl.glClear(Gl.GL_STENCIL_BUFFER_BIT);
// don't draw things to the screen for now
Gl.glColorMask(Gl.GL_FALSE, Gl.GL_FALSE, Gl.GL_FALSE, Gl.GL_FALSE);
Gl.glEnable(Gl.GL_STENCIL_TEST); // Enable Stencil Test
// now we setup the stencil. First we say the test always passes
// and the reference and mask are 1
Gl.glStencilFunc(Gl.GL_ALWAYS, 1, 1);
// replace the value in the buffer, replace the
Gl.glStencilOp(Gl.GL_REPLACE, Gl.GL_REPLACE, Gl.GL_REPLACE);
DrawClippingShape(); // the shape to clip against
Gl.glColorMask(Gl.GL_TRUE, Gl.GL_TRUE, Gl.GL_TRUE, Gl.GL_TRUE);
Gl.glStencilFunc(Gl.GL_EQUAL, 1, 1);
Gl.glStencilOp(Gl.GL_KEEP, Gl.GL_KEEP, Gl.GL_KEEP);
I'm not doing much other setup for this. At startup, I do:
Gl.glClearStencil(0); // clear the stencil buffer to 0s
So what have I missed?
Perplexedly,
Steve Bass