Search code examples
openglglu

Why glOrtho() works under Mac but gluOrtho2D() doesn't?


Several days ago I posted this question(I don't know if it's proper to open a new thread... however when I get the answer from this post I will close that one): QGLWidget not working correctly under Mac OS X Lion .

I grabbed some example code online, compared them with mine, and confirmed the problem is raised by:

gluOrtho2D(0, w, 0, h);

and after changing it to:

glOrtho(0, w, 0, h, -1, 1);

and removed glu as dependency, my program worked. why? what's the difference?


Solution

  • OK I think I get the answer.

    The problem is I was linking two versions of OpenGL; Apple has its own GL implementation, AGL, which Qt will link to; but I didn't know that so I linked glu installed under /opt/local to the program as well. I guess that version is introduced by Mac Ports to compile X11 programs.

    Anyway, because I removed dependency of GLU, the only linked implementation is AGL; so it worked as expected.