[SOLVED] Get screen resolution.


Recommended Posts


Is any way to get the current screen resolution? (not window resolution)

I've searching on docs and i've not found any info.

Raúl Salas

Link to post

Hi Raul,

There are no such methods available in API. For a simple case it may look like this (https://stackoverflow.com/a/50205813):

#if WIN32
  #include <windows.h>
  #include <X11/Xlib.h>


void getScreenResolution(int &width, int &height) {
#if WIN32
    width  = (int) GetSystemMetrics(SM_CXSCREEN);
    height = (int) GetSystemMetrics(SM_CYSCREEN);
    Display* disp = XOpenDisplay(NULL);
    Screen*  scrn = DefaultScreenOfDisplay(disp);
    width  = scrn->width;
    height = scrn->height;

int main() {
    int width, height;
    getScreenResolution(width, height);
    printf("Screen resolution: %dx%d\n", width, height);


How to submit a good bug report
FTP server for test scenes and user uploads:

Link to post
  • silent changed the title to [SOLVED] Get screen resolution.