|
@@ -157,6 +157,7 @@ Graphics::Graphics(Context* context_) :
|
|
|
multiSample_(1),
|
|
multiSample_(1),
|
|
|
fullscreen_(false),
|
|
fullscreen_(false),
|
|
|
resizable_(false),
|
|
resizable_(false),
|
|
|
|
|
+ borderless_(false),
|
|
|
vsync_(false),
|
|
vsync_(false),
|
|
|
tripleBuffer_(false),
|
|
tripleBuffer_(false),
|
|
|
sRGB_(false),
|
|
sRGB_(false),
|
|
@@ -231,22 +232,28 @@ void Graphics::SetWindowPosition(int x, int y)
|
|
|
SetWindowPosition(IntVector2(x, y));
|
|
SetWindowPosition(IntVector2(x, y));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, bool vsync, bool tripleBuffer, int multiSample)
|
|
|
|
|
|
|
+bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer, int multiSample)
|
|
|
{
|
|
{
|
|
|
PROFILE(SetScreenMode);
|
|
PROFILE(SetScreenMode);
|
|
|
|
|
+
|
|
|
|
|
+ bool maximize = false;
|
|
|
|
|
|
|
|
- // Fullscreen can not be resizable
|
|
|
|
|
- if (fullscreen)
|
|
|
|
|
|
|
+ // Fullscreen or Borderless can not be resizable
|
|
|
|
|
+ if (fullscreen || borderless)
|
|
|
resizable = false;
|
|
resizable = false;
|
|
|
|
|
+
|
|
|
|
|
+ // Borderless cannot be fullscreen, they are mutually exclusive
|
|
|
|
|
+ if (borderless)
|
|
|
|
|
+ fullscreen = false;
|
|
|
|
|
|
|
|
multiSample = Clamp(multiSample, 1, 16);
|
|
multiSample = Clamp(multiSample, 1, 16);
|
|
|
|
|
|
|
|
- if (IsInitialized() && width == width_ && height == height_ && fullscreen == fullscreen_ && resizable == resizable_ &&
|
|
|
|
|
|
|
+ if (IsInitialized() && width == width_ && height == height_ && fullscreen == fullscreen_ && borderless == borderless_ && resizable == resizable_ &&
|
|
|
vsync == vsync_ && tripleBuffer == tripleBuffer_ && multiSample == multiSample_)
|
|
vsync == vsync_ && tripleBuffer == tripleBuffer_ && multiSample == multiSample_)
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
// If only vsync changes, do not destroy/recreate the context
|
|
// If only vsync changes, do not destroy/recreate the context
|
|
|
- if (IsInitialized() && width == width_ && height == height_ && fullscreen == fullscreen_ && resizable == resizable_ &&
|
|
|
|
|
|
|
+ if(IsInitialized() && width == width_ && height == height_ && fullscreen == fullscreen_ && borderless == borderless_ && resizable == resizable_ &&
|
|
|
tripleBuffer == tripleBuffer_ && multiSample == multiSample_ && vsync != vsync_)
|
|
tripleBuffer == tripleBuffer_ && multiSample == multiSample_ && vsync != vsync_)
|
|
|
{
|
|
{
|
|
|
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
|
|
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
|
|
@@ -254,21 +261,22 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // If zero dimensions in windowed mode, set default. If zero in fullscreen, use desktop mode
|
|
|
|
|
|
|
+ // If zero dimensions in windowed mode, ignore well maximize. If zero in fullscreen, use desktop mod
|
|
|
if (!width || !height)
|
|
if (!width || !height)
|
|
|
{
|
|
{
|
|
|
- if (!fullscreen)
|
|
|
|
|
- {
|
|
|
|
|
- width = 1024;
|
|
|
|
|
- height = 768;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ if (fullscreen || borderless)
|
|
|
{
|
|
{
|
|
|
SDL_DisplayMode mode;
|
|
SDL_DisplayMode mode;
|
|
|
SDL_GetDesktopDisplayMode(0, &mode);
|
|
SDL_GetDesktopDisplayMode(0, &mode);
|
|
|
width = mode.w;
|
|
width = mode.w;
|
|
|
height = mode.h;
|
|
height = mode.h;
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ maximize = true;
|
|
|
|
|
+ width = 1024;
|
|
|
|
|
+ height = 768;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check fullscreen mode validity (desktop only). If not valid, revert to windowed
|
|
// Check fullscreen mode validity (desktop only). If not valid, revert to windowed
|
|
@@ -330,10 +338,12 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
int y = fullscreen ? 0 : SDL_WINDOWPOS_UNDEFINED;
|
|
int y = fullscreen ? 0 : SDL_WINDOWPOS_UNDEFINED;
|
|
|
|
|
|
|
|
unsigned flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
|
|
unsigned flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
|
|
|
- if (fullscreen)
|
|
|
|
|
- flags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
|
|
|
|
|
|
|
+ if(fullscreen)
|
|
|
|
|
+ flags |= SDL_WINDOW_FULLSCREEN;
|
|
|
if (resizable)
|
|
if (resizable)
|
|
|
flags |= SDL_WINDOW_RESIZABLE;
|
|
flags |= SDL_WINDOW_RESIZABLE;
|
|
|
|
|
+ if (borderless)
|
|
|
|
|
+ flags |= SDL_WINDOW_BORDERLESS;
|
|
|
|
|
|
|
|
for (;;)
|
|
for (;;)
|
|
|
{
|
|
{
|
|
@@ -366,6 +376,9 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
CreateWindowIcon();
|
|
CreateWindowIcon();
|
|
|
|
|
+
|
|
|
|
|
+ if(maximize)
|
|
|
|
|
+ Maximize();
|
|
|
|
|
|
|
|
// Create/restore context and GPU objects and set initial renderstate
|
|
// Create/restore context and GPU objects and set initial renderstate
|
|
|
Restore();
|
|
Restore();
|
|
@@ -435,6 +448,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
|
|
|
|
|
fullscreen_ = fullscreen;
|
|
fullscreen_ = fullscreen;
|
|
|
resizable_ = resizable;
|
|
resizable_ = resizable;
|
|
|
|
|
+ borderless_ = borderless;
|
|
|
vsync_ = vsync;
|
|
vsync_ = vsync;
|
|
|
tripleBuffer_ = tripleBuffer;
|
|
tripleBuffer_ = tripleBuffer;
|
|
|
multiSample_ = multiSample;
|
|
multiSample_ = multiSample;
|
|
@@ -453,6 +467,8 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
#ifdef ENABLE_LOGGING
|
|
#ifdef ENABLE_LOGGING
|
|
|
String msg;
|
|
String msg;
|
|
|
msg.AppendWithFormat("Set screen mode %dx%d %s", width_, height_, (fullscreen_ ? "fullscreen" : "windowed"));
|
|
msg.AppendWithFormat("Set screen mode %dx%d %s", width_, height_, (fullscreen_ ? "fullscreen" : "windowed"));
|
|
|
|
|
+ if (borderless_)
|
|
|
|
|
+ msg.Append(" borderless");
|
|
|
if (resizable_)
|
|
if (resizable_)
|
|
|
msg.Append(" resizable");
|
|
msg.Append(" resizable");
|
|
|
if (multiSample > 1)
|
|
if (multiSample > 1)
|
|
@@ -467,6 +483,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
eventData[P_HEIGHT] = height_;
|
|
eventData[P_HEIGHT] = height_;
|
|
|
eventData[P_FULLSCREEN] = fullscreen_;
|
|
eventData[P_FULLSCREEN] = fullscreen_;
|
|
|
eventData[P_RESIZABLE] = resizable_;
|
|
eventData[P_RESIZABLE] = resizable_;
|
|
|
|
|
+ eventData[P_BORDERLESS] = borderless_;
|
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -474,7 +491,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool resizable, b
|
|
|
|
|
|
|
|
bool Graphics::SetMode(int width, int height)
|
|
bool Graphics::SetMode(int width, int height)
|
|
|
{
|
|
{
|
|
|
- return SetMode(width, height, fullscreen_, resizable_, vsync_, tripleBuffer_, multiSample_);
|
|
|
|
|
|
|
+ return SetMode(width, height, fullscreen_, borderless_, resizable_, vsync_, tripleBuffer_, multiSample_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Graphics::SetSRGB(bool enable)
|
|
void Graphics::SetSRGB(bool enable)
|
|
@@ -490,7 +507,7 @@ void Graphics::SetSRGB(bool enable)
|
|
|
|
|
|
|
|
bool Graphics::ToggleFullscreen()
|
|
bool Graphics::ToggleFullscreen()
|
|
|
{
|
|
{
|
|
|
- return SetMode(width_, height_, !fullscreen_, resizable_, vsync_, tripleBuffer_, multiSample_);
|
|
|
|
|
|
|
+ return SetMode(width_, height_, !fullscreen_, borderless_, resizable_, vsync_, tripleBuffer_, multiSample_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Graphics::Close()
|
|
void Graphics::Close()
|
|
@@ -2022,6 +2039,7 @@ void Graphics::WindowResized()
|
|
|
eventData[P_HEIGHT] = height_;
|
|
eventData[P_HEIGHT] = height_;
|
|
|
eventData[P_FULLSCREEN] = fullscreen_;
|
|
eventData[P_FULLSCREEN] = fullscreen_;
|
|
|
eventData[P_RESIZABLE] = resizable_;
|
|
eventData[P_RESIZABLE] = resizable_;
|
|
|
|
|
+ eventData[P_BORDERLESS] = borderless_;
|
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2193,6 +2211,22 @@ void Graphics::Restore()
|
|
|
(*i)->OnDeviceReset();
|
|
(*i)->OnDeviceReset();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void Graphics::Maximize()
|
|
|
|
|
+{
|
|
|
|
|
+ if (!impl_->window_)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ SDL_MaximizeWindow(impl_->window_);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void Graphics::Minimize()
|
|
|
|
|
+{
|
|
|
|
|
+ if (!impl_->window_)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ SDL_MinimizeWindow(impl_->window_);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void Graphics::CleanupRenderSurface(RenderSurface* surface)
|
|
void Graphics::CleanupRenderSurface(RenderSurface* surface)
|
|
|
{
|
|
{
|
|
|
if (!surface)
|
|
if (!surface)
|