Jump to content

Multi-monitor Support


Josh

2,200 views

 Share

New commands in Turbo Engine will add better support for multiple monitors. The new Display class lets you iterate through all your monitors:

for (int n = 0; n < CountDisplays(); ++n)
{
	auto display = GetDisplay(n);
	Print(display->GetPosition()); //monitor XY coordinates
	Print(display->GetSize()); //monitor size
	Print(display->GetScale()); //DPI scaling
}

The CreateWindow() function now takes a parameter for the monitor to create the window on / relative to.

auto display = GetDisplay(0);
Vec2 scale = display->GetScale();
auto window = CreateWindow(display, "My Game", 0, 0, 1280.0 * scale.x, 720.0 * scale.y, WINDOW_TITLEBAR | WINDOW_RESIZABLE);

The WINDOW_CENTER style can be used to center the window on one display.

You can use GetDisplay(DISPLAY_PRIMARY) to retrieve the main display. This will be the same as GetDisplay(0) on systems with only one monitor.

  • Like 4
 Share

4 Comments


Recommended Comments

Great start but this is a little confusing to me.  Some questions:

  • What does GetSize return?  Is it the number of pixels across and down on the given monitor (the monitor's resolution)?
  • What does GetPosition return?  What are the XY coordinates on a monitor?  Or, how does the display have a position?
  • How would you make a full screen window over two or more displays of your choice?
Link to comment

-Yes.

-A monitor has a position relative to the other monitors. They all make up one big virtual screen.

-I’m not sure yet.

Link to comment

Thanks.

1 hour ago, Josh said:

-A monitor has a position relative to the other monitors. They all make up one big virtual screen.

Ah, makes sense.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...