Sign in to follow this  
kujneki

Lesson 26: Reflections using stencil buffer

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this