reepblue Posted August 15, 2015 Share Posted August 15, 2015 With my application, if a settings file does not exist, the main function creates one, and fills it with default values. One of these is to grab the main screen res of the user's monitor. In Windows, I can do: unsigned int width = GetSystemMetrics(SM_CXSCREEN); unsigned int height = GetSystemMetrics(SM_CYSCREEN); However, since my HDD with Ubuntu on it died, I can't test the linux variant I've found on the internet. #include <X11/Xlib.h> Display* disp = XOpenDisplay(NULL); Screen* scrn = DefaultScreenOfDisplay(disp); unsigned int width = scrn->width; unsigned int height = scrn->height; Is this correct/will work, or is there a different/better way? I tried using the Count/GetGraphicsModes function, and although it did work on my Linux machine, it did not work on my Windows Machine, and I've read that it's not perfect. Thanks. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
reepblue Posted August 15, 2015 Author Share Posted August 15, 2015 Thanks to macklebee, the correct answer is to use the count/getnodes function like: unsigned int xo = System::GetGraphicsMode(System::CountGraphicsModes() - 1).x; unsigned int yo = System::GetGraphicsMode(System::CountGraphicsModes() - 1).y; Then, use those int values for x and y. In this case, I need it to be a char to save to an XML file. namespace patch { template < typename T > std::string to_string(const T& n) { std::ostringstream stm; stm << n; return stm.str(); } } std::string sx = patch::to_string(xo); char const *pchar_resX = sx.c_str(); std::string sy = patch::to_string(yo); char const *pchar_resY = sy.c_str(); 1 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.