I created a mirror according to the NeHe tutorial. If I try it in front of a black background (glClear()-ed), it shows the reflection. The stencil works OK.
My problem is, that i use a background image and if i display it, the “transparent” part of the stencil disappears, which means, no reflection is visible, just the bgr image. I think it is somehow related to the fact, that displaying the bgr makes the stencil buffer fill up with 1.
What I did:
//this draws the bgr
room.background_img.display_bgr_image();
//NeHe things
glDisable(GL_LIGHTING);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glDisable(GL_DEPTH_TEST);
//draws the quad for the mirror
draw_quad(
100,0,0,
40,100,0,
200,100,0,
200,0,0
);
//NeHe stuff again
glEnable(GL_DEPTH_TEST);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
//mirroring
glScalef(1.0f, 1.0f, -1.0f);
mesh.display_mesh();
glDisable(GL_STENCIL_TEST);
glEnable(GL_LIGHTING);
Can pls. someone tell me, how I can draw the mirror and the background?