glutGet(GLUT_WINDOW_X) bug

I think there may be a bug in OpenGL.

glutGet(GLUT_WINDOW_X) and glutGet(GLUT_WINDOW_Y) always return 0, no matter where my window is.

The weird thing is glutGet(GLUT_WINDOW_WIDTH) and glutGet(GLUT_WINDOW_HEIGHT) always return the correct width and height.

Anyone else experience this problem/know a solution?

I think this may be one of those areas where GLUT is inconsistent between OS implementations. If you search the freeglut mailing list for GLUT_WINDOW_X you’ll see they spent some time arguing over whether to keep GLUT compatibility and inconsistancy, or break with GLUT and do something that makes sense.

You need to look at the source of your particular GLUT implementation where you’ll find that these XY values are probably just whatever is passed to the glutSetWindowPosition() function. If you hadn’t called that at the beginning of your program, then that’s why they’ll be 0.

To make the glutGet() function more usable for your intended purposes you would have to monitor the OS-specific window manager move function. On Win32, you would look for the window message handler’s WM_MOVE case and update the XY variables to match the current window coordinates.