MacOS GLUT is broken, gives bous window dimensions

I have discovered something remarkable. I know that Apple has deprecated OpenGL, but still. This situation is appalling:

When Apple’s GLUT framework calls the handleResize callback (AKA reshape), it provides a window width & height that are quite bogus. The bigger the window, the smaller the width. The taller the window, the shorter the height. And the inverse is true.

I am using glViewport and glOrtho.

In addition, calling glutGet (GLUT_WINDOW_WIDTH) and glutGet (GLUT_WINDOW_HEIGHT) also provides these bogus values.

Also provide these bogus width and height values.

The effect is, if I draw a triangle that goes from left side to right side, top to bottom, is almost never touches the top and the right edges.

But the same code runs fine on GNU/Linux.

Is there a way on MacOS for me to get the true window size without messing with their broken GLUT?

Hi all,

By random experimentation, I discovered that I can fix Apple’s bug as follows:


    void handleResize(int w, int h) {
    #ifdef __APPLE__
      glutReshapeWindow (w,h);
      return;
    #endif
    // Handle non-Apple case here.
    }