|
@@ -298,7 +298,7 @@ Graphics::~Graphics()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool highDPI, bool vsync, bool tripleBuffer,
|
|
bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool highDPI, bool vsync, bool tripleBuffer,
|
|
|
- int multiSample)
|
|
|
|
|
|
|
+ int multiSample, int monitor, int refreshRate)
|
|
|
{
|
|
{
|
|
|
URHO3D_PROFILE(SetScreenMode);
|
|
URHO3D_PROFILE(SetScreenMode);
|
|
|
|
|
|
|
@@ -306,9 +306,14 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
|
|
|
|
|
bool maximize = false;
|
|
bool maximize = false;
|
|
|
|
|
|
|
|
|
|
+ // make sure monitor index is not bigger than the currently detected monitors
|
|
|
|
|
+ int monitors = SDL_GetNumVideoDisplays();
|
|
|
|
|
+ if (monitor >= monitors)
|
|
|
|
|
+ monitor = 0; // this monitor is not present, use first monitor
|
|
|
|
|
+
|
|
|
// Find out the full screen mode display format (match desktop color depth)
|
|
// Find out the full screen mode display format (match desktop color depth)
|
|
|
SDL_DisplayMode mode;
|
|
SDL_DisplayMode mode;
|
|
|
- SDL_GetDesktopDisplayMode(0, &mode);
|
|
|
|
|
|
|
+ SDL_GetDesktopDisplayMode(monitor, &mode);
|
|
|
DXGI_FORMAT fullscreenFormat = SDL_BITSPERPIXEL(mode.format) == 16 ? DXGI_FORMAT_B5G6R5_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
DXGI_FORMAT fullscreenFormat = SDL_BITSPERPIXEL(mode.format) == 16 ? DXGI_FORMAT_B5G6R5_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
|
|
|
|
|
|
// If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. If zero in fullscreen, use desktop mode
|
|
// If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. If zero in fullscreen, use desktop mode
|
|
@@ -351,7 +356,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
// Check fullscreen mode validity. Use a closest match if not found
|
|
// Check fullscreen mode validity. Use a closest match if not found
|
|
|
if (fullscreen)
|
|
if (fullscreen)
|
|
|
{
|
|
{
|
|
|
- PODVector<IntVector2> resolutions = GetResolutions();
|
|
|
|
|
|
|
+ PODVector<IntVector3> resolutions = GetResolutions();
|
|
|
if (resolutions.Size())
|
|
if (resolutions.Size())
|
|
|
{
|
|
{
|
|
|
unsigned best = 0;
|
|
unsigned best = 0;
|
|
@@ -369,10 +374,12 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
|
|
|
|
|
width = resolutions[best].x_;
|
|
width = resolutions[best].x_;
|
|
|
height = resolutions[best].y_;
|
|
height = resolutions[best].y_;
|
|
|
|
|
+ refreshRate = resolutions[best].z_;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- AdjustWindow(width, height, fullscreen, borderless);
|
|
|
|
|
|
|
+ AdjustWindow(width, height, fullscreen, borderless, monitor);
|
|
|
|
|
+ monitor_ = monitor;
|
|
|
|
|
|
|
|
if (maximize)
|
|
if (maximize)
|
|
|
{
|
|
{
|
|
@@ -423,7 +430,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
|
|
|
|
|
bool Graphics::SetMode(int width, int height)
|
|
bool Graphics::SetMode(int width, int height)
|
|
|
{
|
|
{
|
|
|
- return SetMode(width, height, fullscreen_, borderless_, resizable_, highDPI_, vsync_, tripleBuffer_, multiSample_);
|
|
|
|
|
|
|
+ return SetMode(width, height, fullscreen_, borderless_, resizable_, highDPI_, vsync_, tripleBuffer_, multiSample_, monitor_, refreshRate_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Graphics::SetSRGB(bool enable)
|
|
void Graphics::SetSRGB(bool enable)
|
|
@@ -2082,7 +2089,7 @@ bool Graphics::OpenWindow(int width, int height, bool resizable, bool borderless
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen, bool& newBorderless)
|
|
|
|
|
|
|
+void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen, bool& newBorderless, int& monitor)
|
|
|
{
|
|
{
|
|
|
if (!externalWindow_)
|
|
if (!externalWindow_)
|
|
|
{
|
|
{
|
|
@@ -2091,8 +2098,17 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
|
|
|
SDL_MaximizeWindow(window_);
|
|
SDL_MaximizeWindow(window_);
|
|
|
SDL_GetWindowSize(window_, &newWidth, &newHeight);
|
|
SDL_GetWindowSize(window_, &newWidth, &newHeight);
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (newFullscreen || newBorderless)
|
|
|
|
|
+ {
|
|
|
|
|
+ // reposition the window on the specified monitor
|
|
|
|
|
+ SDL_Rect display_rect;
|
|
|
|
|
+ SDL_GetDisplayBounds(monitor, &display_rect);
|
|
|
|
|
+ SDL_SetWindowPosition(window_, display_rect.x, display_rect.y);
|
|
|
|
|
+ }
|
|
|
SDL_SetWindowSize(window_, newWidth, newHeight);
|
|
SDL_SetWindowSize(window_, newWidth, newHeight);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Hack fix: on SDL 2.0.4 a fullscreen->windowed transition results in a maximized window when the D3D device is reset, so hide before
|
|
// Hack fix: on SDL 2.0.4 a fullscreen->windowed transition results in a maximized window when the D3D device is reset, so hide before
|
|
|
SDL_HideWindow(window_);
|
|
SDL_HideWindow(window_);
|