Lesson 26: Reflections using stencil buffer

Started by
3 comments, last by Caste 16 years ago
I've downloaded the code (port for LWJGL) from the tutorial and ran the program. Here is what I get: http://freeweb.t-2.net/vision/stencil.gif I don't think it's supposed to be like that, but since that's the code from the tutorial I'm getting really confused. Thanks in advance!
Advertisement
This looks as if the stencil buffer is not enabled, because you can see the sphere below the surface.

Try to enable it using the Display.create(myPixelFormat) method with a Pixelformat which requires a stencil buffer (http://www.lwjgl.org/javadoc/org/lwjgl/opengl/PixelFormat.html).

so perhaps Display.create(new PixelFormat(8,8,8));

Hope that helps
Carsten
Whilst I cant comment on what this program does or what source your are referring to - have you tried some debugging steps.

The first of which is to query OpenGL to determine the number of allocated stencil bits that you actually have.

try something like this:

int _iStencilBits=0;
glStencilMask(0xFFFFFFFF); // resets the stencil mask
glGetIntegerv (GL_STENCIL_BITS, &_iStencilBits);

If you find you dont have any stencil bit allocated then look at your device context code, ensure your setup includes a request for Stencil.
Also, in your render loop - the clear buffers command - ensure you clear the COLOR+DEPTH+STENCIL bits.
Thank you both! It was what Caste said. After creating Display with PixelFormat it worked like a charm.

p.s. - if owner of the site is reading this, please update the LWJGL code from Lesson 26, because it doesn't work.
Yeh, I already added it to my ToDo-List.. will be fixed soon.

This topic is closed to new replies.

Advertisement