I tried to use sf::VideoMode::getDesktopMode() to initialize a window with my desktop size, I then get a window size of 4480x1440.
I have one monitor with a resolution of 2560x1440 and another with 1920x1080 so the window covers both monitors.
I modified the example of the window example in the SFML project to output the desktop and fullscreen modes:
Fullscreen modes:
- 4480x1440x32
- 1920x1080x32
- 1680x1050x32
- 1600x900x32
- 1440x900x32
- 1366x768x32
- 1280x1024x32
- 1280x800x32
- 1280x720x32
- 1024x768x32
- 800x600x32
- 720x576x32
- 720x480x32
- 640x480x32
...
Desktop mode: 4480x1440x24
The determined desktop resolution covers both monitors and the resolution list looks like a mix between the modes of the two monitors.
xrandr gives me the following lists:
Monitor 2560x1440
-----------------
2560x1440
1920x1080
1680x1050
1440x900
1440x576
1440x480
1280x1024
1280x960
1280x800
1280x720
1152x864
1024x768
800x600
720x576
720x480
640x480
Monitor 1920x1080
-----------------
1920x1080
1680x1050
1600x900
1280x1024
1280x800
1280x720
1024x768
800x600
720x576
720x480
640x480
I created a branch and modified VideoModeImpl.cpp and after that I get the following:
Fullscreen modes:
- 2560x1440x32
- 1920x1080x32
- 1680x1050x32
- 1440x900x32
- 1440x576x32
- 1440x480x32
- 1280x1024x32
- 1280x960x32
- 1280x800x32
- 1280x720x32
- 1152x864x32
- 1024x768x32
- 800x600x32
- 720x576x32
- 720x480x32
- 640x480x32
...
Desktop mode: 2560x1440x24
See my changes:
https://github.com/SFML/SFML/compare/master...hachmeister:multi-monitor-resolution
Are there some issues with the current implementation or am I missing something here when using SFML?
My system: Debian testing, KDE 5 desktop with NVIDIA GeForce GTX 1060
I searched the internet before about this issue and my understanding is, that SFML can not use multiple monitors and uses only the primary display.
Is this wrong?
So my expectation was that I get a window size of 2560x1440 from the getDesktopMode() function. That is also my native desktop resolution of my first screen.
But it gave me a window size of 4480x1440.
xrandr tool shows this screen as primary, just to be sure here the output:
Screen 0: minimum 8 x 8, current 4480 x 1440, maximum 32767 x 32767
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 1920x1080+2560+180 (normal left inverted right x axis y axis) 544mm x 303mm
1920x1080 60.00*+ 59.94 50.00 60.05 60.00 50.04
1680x1050 59.95
1600x900 60.00
1280x1024 75.02 60.02
1280x800 59.81
1280x720 60.00 59.94 50.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-0 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
2560x1440 59.95*+
1920x1080 60.00 59.94 50.00
1680x1050 59.95
1440x900 59.89
1440x576 50.00
1440x480 59.94
1280x1024 75.02 60.02
1280x960 60.00
1280x800 59.81
1280x720 60.00 59.94 50.00
1152x864 75.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-1 disconnected (normal left inverted right x axis y axis)
My knowledge about X11 programming is very limited, but my understanding of the line
int screen = DefaultScreen(display);
is that it reports the primary screen and so I would expect only screen resolutions of this screen from getDesktopMode()/getFullscreenModes()
I looked at the source code of the xrandr tool and modified the SFML code as far as I understand the xrandr tool what is does to find the screen resolutions.
I just say that my expectation is that the getDesktopMode() function should return the native resolution of my primary screen and never a window size that covers multiple monitors.
Maybe I am wrong with my expectation?