Advertisement

Stencil Reflection problem

Started by April 06, 2003 11:17 AM
2 comments, last by jaba 21 years, 10 months ago
Hello, I''m trying to make the reflection of an object on a plane. My code is //Draw the ground in the Stencil buffer glColorMask(0,0,0,0); glStencilFunc(GL_ALWAYS, 1, 1); glEnable(GL_STENCIL_TEST); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glDisable(GL_DEPTH_TEST); DrawGround(); //Draw the reflected object glColorMask(1,1,1,1); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glEnable(GL_CLIP_PLANE0); double eqr[] = {0.0f,-1.0f, 0.0f, 0.0f}; glClipPlane(GL_CLIP_PLANE0, eqr); glPushMatrix(); glScalef(1.0f,-1.0f, 1.0f); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glLightfv( GL_LIGHT1, GL_POSITION, LightPosition); DrawCar(); glPopMatrix(); ... http://www.geocities.com/opengladiator/imagenes/cap.jpg as you can see in this image the relected object is bad, I think it''s a depth test problem, what you think? Thank you
============================== Videoman Library Project
Well if you scale it like that then all the polygons are going to become inverted.

And if you are using backface culliing they will not show since they are inverted.

The way NeHe did it is just a hack and only works for spheres and such.

Make a special draw routine that draws with an inverted vetex order.

[edited by - lc_overlord on April 7, 2003 7:44:17 AM]
Advertisement
OK, problem resolved, the problem is the backface culliing. I have disabled it while drawing the reflected object, but this is a bad solution. I try with glFrontFace(GL_BACK) but don''t works.Must I make a special draw routine that draws with an inverted vetex order??? No other solution??
============================== Videoman Library Project
problem resolved
glFrontFace(GL_CW )
draw reflect object
glFrontFace(GL_CCW)

Thank you very much for the help
============================== Videoman Library Project

This topic is closed to new replies.

Advertisement