Stencil buffer usage

I am trying to learn the usage of stencil buffer. I try to create reflection of an object on a floor.
But while i introduce the blue block the reflected object is not rendered.

With no blue block I see a solid object, floor and the object which is supposed to be the reflection of the first object appears partly hidden behind the floor!!

Below is the code. Please help me.

glEnable(GL_STENCIL_TEST);
glColorMask(0, 0, 0, 0);
glDisable(GL_DEPTH_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
draw_floor();

glColorMask(1, 1, 1, 1);
glEnable(GL_DEPTH_TEST);

glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

I could solve the problem !!

I was viewing from a wrong angle so i could not see the reflected image.

Thank you.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.