This is what i do:
- Setup perspective view
- Render a z-only pass
- render the level
- copy that image into a texture
- push projection-matrix
- setup ortho view
- theoretically distort the image (not done at the moment)
- pop projection matrix
- render my level lit, etc.
- add the distortet texture
I setup my ortho-view this way:
- Camera.PushProjectionMatrix ();
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho (0, 1024, 0, 768, Camera.GetNearPlane (), Camera.GetFarPlane ());
- glMatrixMode(GL_MODELVIEW);
… theoretically do some stuff (but NOTHING gets done, yet)
- Camera.PopProjectionMatrix ();
If i comment out line 4 everything works fine. But with it in the code, i get z-fighting afterwards, when i do multiple passes in perspective mode.
I swear, between push, ortho and pop, there is NOTHING done.
I thought maybe glOrtho changed the depthfunc, and made sure it is set to GL_LEQUAL, but that doesn´t fix the problem.
I really think that´s strange. A matrix should not change a bit (take that literally) when it gets pushed and popped.
And therefore the computations should not differ afterwards.
I have to do those operations in that order. So i have to switch between ortho and perspective view in the middle of the frame.
Any suggestions, or is this a driver bug?
Jan.