Mixing OpenGL immediate mode and shaders

Hi,

I have to mix an old program that uses OpenGL immediate mode and a new library that uses OpenGL shaders (version > 3.0). I’m not used to this kind of mixing…

Basically, the main rendering loop is something like that:

  • Init some global states and matrices,
  • Drawing with immediate mode,
  • Drawing with shaders,
  • Drawing with immediate mode,
  • Swap buffer.

It works fine, except I don’t have depth test between the two rendering mode. It seems that the immediate mode is always over the shader drawing (with depth test enabled and depth write too).
Is there something I have to check? Do I have to define the projection matrix exactly the same way? (I have some doubts about that…).

Thanks.

I guess you should not call glDisable(GL_DEPTH_TEST).
There is also glDepthMask to watch out for.

Do I have to define the projection matrix exactly the same way?

As long as the projection matrix values are the same, then it should be fine.