Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - rherzog

Pages: [1]
1
Window / Re: Working with multiple monitors
« on: May 21, 2022, 09:42:33 am »
I stumbled over the same issue recently that I want to have 2 fullscreen windows on two external displays.
However, SFML only chooses to use the same primary display as the fullscreen window.
At least for MS Windows I found a simple solution:


//...switching to fullscreen on current most overlapping display for SFML window1
RECT rect;
HMONITOR hMonitor;
MONITORINFO mi;
hMonitor = MonitorFromWindow(sfml_window1.getSystemHandle(), MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
rect = mi.rcMonitor;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
sfml_window1.create(sf::VideoMode(width, height), "Window1", sf::Style::None);
sfml_window1.setPosition(sf::Vector2i(rect.left, rect.top));
sfml_window1.setVerticalSyncEnabled(true);

The same can be done simultaneously with other SFML windows on different screens and they will go fullscreen on the current most overlapping display. You might need to include <winuser.h>.

Pages: [1]
anything