GLFW get screen height/width?

Byzantian picture Byzantian · Jul 4, 2012 · Viewed 21.3k times · Source

Playing around with OpenGL for a while, using the freeglut library, I decided that I will use GLFW for my next training project instead, since I was told that GLUT was only designed for learning purposes and should not be used professionally. I had no problems with linking the lib to my NetBeans project and it compiles just fine, using mingw32 4.6.2.

However, I am running into difficulties trying to position the window at the center of the screen. Under freeglut, I previously used:

glutInitWindowPosition ( 
                         (glutGet(GLUT_SCREEN_WIDTH)-RES_X)  / 2,
                         (glutGet(GLUT_SCREEN_HEIGHT)-RES_Y) / 2 
                       );

I can't find any glfw function that would return the screen size or width. Is such a function simply not implemented?

Answer

Tim picture Tim · Jul 4, 2012

How about glfwGetDesktopMode, I think this is what you want.

Example:

GLFWvidmode return_struct;

glfwGetDesktopMode( &return_struct );

int height = return_struct.Height;