Hi, I have an OpenGL program where I need to render a 2D image as background ( using ortho projection ) and a few 3D models over this background ( using perspective ).
Due to others requirements of the application I only can clear the depth buffer once, before render any object, and I can’t disable the glDepthMask.
So, I have built two projection matrices one as ortho for 2D and another one as perspective for 3D, where the near and far component of each projection are the same.
Moreover I use the same view matrix for the all objects, the background ( 2D ) and the others ( 3D ).
So I expected that giving a farther Z value to the 2D background position and rendering later the 3D objects with a closer Z position, the scene would be fine.
But it’s not what it happens, the background is the unique visible in the resulting scene.
After it I have tested multiply a same vector by both matrix, ( ortho and perspective ) and I have noticed that the Z component of te resulting vector are diferents.
So, it’s this result correct? If it is, how can I dertermine when the object drawn with the ortho matrix will be behind the rest of the objetcts?
Thanks in advance.