whenever i use glScale with a negative number, the depth test seems not to be performed. if i render my geometry as usual, everything is fine, but if i use glScalef( 1.0f, -1.0f, 1.0f ) to mirror the geometry (needed for reflections), it’s all screwed up. is this a known issue or am i missing sth obvious? thanks in advance!
With scale -1 you end up with reverse-winding polygons, that are culled by glEnable(GL_CULL_FACE), and depends on glCullFace(GL_BACK).
Play with glFrontFace(GL_CW).
BTW, if someone can explain why we have both glCullface and glFrontface ? The semantic is different, but the operation seem equivalent ?
What am I missing here ?
EDIT: Ok, 2 sided lighting. nevermind
First off, there’s simply a conceptual difference between “Which type of faces should be culled” and “Which vertex order indicates front-facing polygons”. Having both functions allows you to formulate algorithms that use face culling (for example stencil shadow) independently of the polygon winding of your particular geometry.
Secondly, the selection of winding for front facing polygons also affects other parts, not related to culling, such as materials (two sided lighting and front/back side material).
ok so i guess i should use glCullface(GL_FRONT); to solve this problem?
It makes more sense with glFrontFace(GL_CW).
Don’t forget to go back to glFrontFace(GL_CCW) when scale is >0.