Getting screen resolution

Aug 18, 2013 at 2:10pm
So I'm writing a game and I want to know how can i get the resolution of the computer the game is running on.

Any help would be appreciated.

Ass. jonhy31
Aug 18, 2013 at 3:34pm
Aug 18, 2013 at 7:38pm
Here is how to do it with the X windows System.

1
2
3
4
5
6
#include <X11/Xlib.h>

Display* disp = XOpenDisplay(NULL);
Screen*  scrn = DefaultScreenOfDisplay(disp);
int height = scrn->height;
int width  = scrn->width;

Last edited on Aug 18, 2013 at 7:51pm
Aug 18, 2013 at 11:34pm
Yes.

Use GetSystemMetrics()

1
2
Int x = GetSystemMetrics(SM_CXSCREEN);
Int y = GetSystemMetrics(SM_CYSCREEN);
Last edited on Aug 18, 2013 at 11:35pm
Aug 19, 2013 at 11:58am
whats the header for GetSystemMetrics() and is it cross-platform?
Aug 23, 2013 at 6:57pm
closed account (jwkNwA7f)
#include <windows.h>

Edit: At least for Windows
Last edited on Aug 23, 2013 at 6:59pm
Topic archived. No new replies allowed.