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

Author Topic: Working with multiple monitors  (Read 4324 times)

0 Members and 1 Guest are viewing this topic.

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Working with multiple monitors
« on: September 03, 2017, 03:44:12 am »
Is there any way to distinguish between the main monitor and secondary monitors? I have a fullscreen mode which calls getDesktopMode() to determine the size of the screen and resizes the window to fit it; however, it always uses only the size of the main monitor. I'd like it to take the size of whichever monitor the window currently resides on (based on the window's origin). Can this be done in SFML?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10858
    • View Profile
    • development blog
    • Email
Re: Working with multiple monitors
« Reply #1 on: September 03, 2017, 09:05:20 am »
Unfortunately not yet.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: Working with multiple monitors
« Reply #2 on: September 09, 2017, 04:58:55 am »
I see. I guess I'll have to either wait or use OS-specific routines for it. I don't suppose there's any plans to implement this?

Hapax

  • Hero Member
  • *****
  • Posts: 3362
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Working with multiple monitors
« Reply #3 on: September 10, 2017, 02:31:06 pm »
I don't suppose there's any plans to implement this?
There are. ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

rherzog

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Working with multiple monitors
« Reply #4 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>.

 

anything