View Full Version : API for finding screen size

06-14-2008, 01:56 AM
Hi all,,

is there any function in opengl, which can determine the screen size when an application is called.
as becoz setting parameters based on different screen sizes is quite a cumbersome task.

do let me know..

thanks in advance

Ilian Dinev
06-14-2008, 02:33 AM
width = GetSystemMetrics(SM_CXSCREEN);
height= GetSystemMetrics(SM_CYSCREEN);

Mark Shaxted
06-14-2008, 02:39 AM
or, just for your primary monitor...

GetClientRect( GetDesktopWindow() ,&r );

06-14-2008, 03:41 PM
so can these functions be put in the opengl code..will it work fine..

06-14-2008, 04:16 PM
There is no reason why they should not work with an application that uses OpenGL. If you know one, please tell.

06-14-2008, 11:46 PM
When i m using the Rect r;.. at that instant its not of any help for my glutInitWindowSize() method as it accepts 2 parameters i.e XSIZE and the YSIZE.

Using the other declaration as
int width = GetSystemMetrics(SM_CXSCREEN);
int height= GetSystemMetrics(SM_CYSCREEN); in the main()

its working fine, but my application window is starting minimized at the beginning, and i m maximizing it using the mouse..which is not intended as how itz to work..

Plz let me know on this...

Sik the hedgehog
06-15-2008, 11:48 AM
Using the RECT method: use r.right and r.bottom. Gotta check if you have to add 1 or not (dunno if it specifies the bottom-rightmost pixel or the size, I always use the other method). Anyways, it should be obvious if you try it and very easy to fix if it is wrong (just add or remove the "+ 1").

And about it starting minimized, no idea. Check if by any chance the program is set to start minimized (right click on the EXE and select "Properties"). If you're running it from an IDE, check if it isn't the IDE's fault (run the EXE directly instead from the IDE and see what happens).