I am using SDL 1.2.14, and I've found a case where I need to be able to select which monitor gets the fullscreen window. With Xorg, I found Xinerama could do the job using the SDL_VIDEO_FULLSCREEN_HEAD environment variable, however, I've been unable to find something similar for Win32.
The fullscreen window is always created on the primary monitor, and since SDL 1.2 does not (SDL 1.3 can, but it's not stable) provide the API to select which monitor is to be used on Win32, I wonder if it's possible to programmatically move the fullscreened window to the secondary monitor using Win32 API after it has been created.
I am able to get the underlying Win32 handles for the window/context.
Connect the second monitor to your PC, and launch the game you wish to play. Next, navigate to your desktop screen, and hit Windows and P keys together. A few options will display, select the PC screen only option. Finally, your primary display will go blank, but the game will continue to run on the second monitor.
Hit Windows+P and select "Extend" from the display options, then drag and drop your Window from one monitor to another monitor using your cursor. You can also press Windows+Shift+Left Arrow to move a window left, or Windows+Shift+Right Arrow to move a window right.
Raymond Chen wrote a useful article on how to switch an application between windowed and full screen. The important part for you would be this section of the code:
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &mi))
This gets the monitor information for a specific monitor, but uses the value returned from MonitorFromWindow
to pick the monitor on which the window currently resides. There are several other methods of picking a monitor, such as providing an X,Y coordinate, or enumerating them (using EnumDisplayMonitors(...)
).
GetMonitorInfo(...)
passes a MONITORINFO
back out, which contains the relative position and size of the display, which you can use to position your full-screen window.
The full API is detailed on MSDN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With