Thanks for info!
I still want to try stencil tests anyway coz the funcy 2d stuffs really made the moving of 3d geometries sluggish.
I’ve looked at Nehe’s tutorials on stencil buffer. All of them are about reflection. After struggling I’ve not got the trick yet:-(
My scene is: some simple 3d stuffs float over a complex 2d art. My purpose of using stencil test is to prevent the 2d from being redrawn (that is expensive, but I am not sure) when the 3d things are redrawn.
Look at the cockpit as example:
// Now draw the panel to stencil buffer:
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
// Now draw the panel:
// Now draw a textured quad over the whole screen, but only where the stencil was written with 0 before:
glStencilFunc(GL_NOTEQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
The stencil let the 3d world be drawn only in the window area with the stencil of 0. that’s good. However stencil buffer does not keep the static panel from being redrawn each frame, well, as far as I can see. How can I make it?
(my problem is a little more complex the cockpit emulation. the 2d and 3d things overlap in my scene.)
I am newbie, please bear with me if my question does not make sense at all.
I also posted my question in Nehe’s forum to get more advice.
I appreciate if any help. Thanks!