Getting screen resolution

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
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
Yes.

Use GetSystemMetrics()

1
2
Int x = GetSystemMetrics(SM_CXSCREEN);
Int y = GetSystemMetrics(SM_CYSCREEN);
Last edited on
whats the header for GetSystemMetrics() and is it cross-platform?
closed account (jwkNwA7f)
#include <windows.h>

Edit: At least for Windows
Last edited on
Topic archived. No new replies allowed.