|
@@ -43,17 +43,8 @@
|
|
// C
|
|
// C
|
|
#include <cstdio>
|
|
#include <cstdio>
|
|
|
|
|
|
-// SDL
|
|
|
|
-#if !SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
-#include <SDL_syswm.h>
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
#ifdef LOVE_GRAPHICS_VULKAN
|
|
#ifdef LOVE_GRAPHICS_VULKAN
|
|
-#if __has_include(<SDL3/SDL_vulkan.h>)
|
|
|
|
#include <SDL3/SDL_vulkan.h>
|
|
#include <SDL3/SDL_vulkan.h>
|
|
-#else
|
|
|
|
-#include <SDL_vulkan.h>
|
|
|
|
-#endif
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if defined(LOVE_WINDOWS)
|
|
#if defined(LOVE_WINDOWS)
|
|
@@ -84,6 +75,7 @@ void setHighDPIAllowedImplementation(bool enable)
|
|
#if defined(LOVE_WINDOWS)
|
|
#if defined(LOVE_WINDOWS)
|
|
// Windows uses a different API than SDL_WINDOW_ALLOW_HIGHDPI.
|
|
// Windows uses a different API than SDL_WINDOW_ALLOW_HIGHDPI.
|
|
// This must be set before the video subsystem is initialized.
|
|
// This must be set before the video subsystem is initialized.
|
|
|
|
+ // FIXME: How does this work in SDL3?
|
|
SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, enable ? "1" : "0");
|
|
SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, enable ? "1" : "0");
|
|
#else
|
|
#else
|
|
LOVE_UNUSED(enable);
|
|
LOVE_UNUSED(enable);
|
|
@@ -105,11 +97,7 @@ Window::Window()
|
|
, displayedWindowError(false)
|
|
, displayedWindowError(false)
|
|
, contextAttribs()
|
|
, contextAttribs()
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (!SDL_InitSubSystem(SDL_INIT_VIDEO))
|
|
if (!SDL_InitSubSystem(SDL_INIT_VIDEO))
|
|
-#else
|
|
|
|
- if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
|
|
|
-#endif
|
|
|
|
throw love::Exception("Could not initialize SDL video subsystem (%s)", SDL_GetError());
|
|
throw love::Exception("Could not initialize SDL video subsystem (%s)", SDL_GetError());
|
|
|
|
|
|
// Make sure the screensaver doesn't activate by default.
|
|
// Make sure the screensaver doesn't activate by default.
|
|
@@ -118,11 +106,7 @@ Window::Window()
|
|
#ifdef LOVE_WINDOWS
|
|
#ifdef LOVE_WINDOWS
|
|
// Turned off by default, because it (ironically) causes stuttering issues
|
|
// Turned off by default, because it (ironically) causes stuttering issues
|
|
// on some setups. More investigation is needed before enabling it.
|
|
// on some setups. More investigation is needed before enabling it.
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
canUseDwmFlush = SDL_GetHintBoolean("LOVE_GRAPHICS_VSYNC_DWM", false);
|
|
canUseDwmFlush = SDL_GetHintBoolean("LOVE_GRAPHICS_VSYNC_DWM", false);
|
|
-#else
|
|
|
|
- canUseDwmFlush = SDL_GetHintBoolean("LOVE_GRAPHICS_VSYNC_DWM", SDL_FALSE) != SDL_FALSE;
|
|
|
|
-#endif
|
|
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -329,11 +313,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
|
{
|
|
{
|
|
if (glcontext)
|
|
if (glcontext)
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_GL_DestroyContext(glcontext);
|
|
SDL_GL_DestroyContext(glcontext);
|
|
-#else
|
|
|
|
- SDL_GL_DeleteContext(glcontext);
|
|
|
|
-#endif
|
|
|
|
glcontext = nullptr;
|
|
glcontext = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -348,19 +328,11 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
|
if (window)
|
|
if (window)
|
|
{
|
|
{
|
|
SDL_DestroyWindow(window);
|
|
SDL_DestroyWindow(window);
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_FlushEvents(SDL_EVENT_WINDOW_FIRST, SDL_EVENT_WINDOW_LAST);
|
|
SDL_FlushEvents(SDL_EVENT_WINDOW_FIRST, SDL_EVENT_WINDOW_LAST);
|
|
-#else
|
|
|
|
- SDL_FlushEvent(SDL_WINDOWEVENT);
|
|
|
|
-#endif
|
|
|
|
window = nullptr;
|
|
window = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
window = SDL_CreateWindow(title.c_str(), w, h, windowflags);
|
|
window = SDL_CreateWindow(title.c_str(), w, h, windowflags);
|
|
-#else
|
|
|
|
- window = SDL_CreateWindow(title.c_str(), x, y, w, h, windowflags);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (!window)
|
|
if (!window)
|
|
{
|
|
{
|
|
@@ -368,9 +340,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SetWindowPosition(window, x, y);
|
|
SDL_SetWindowPosition(window, x, y);
|
|
-#endif
|
|
|
|
|
|
|
|
if (attribs != nullptr && renderer == love::graphics::Renderer::RENDERER_OPENGL)
|
|
if (attribs != nullptr && renderer == love::graphics::Renderer::RENDERER_OPENGL)
|
|
{
|
|
{
|
|
@@ -386,11 +356,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
|
// Make sure the context's version is at least what we requested.
|
|
// Make sure the context's version is at least what we requested.
|
|
if (glcontext && !checkGLVersion(*attribs, glversion))
|
|
if (glcontext && !checkGLVersion(*attribs, glversion))
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_GL_DestroyContext(glcontext);
|
|
SDL_GL_DestroyContext(glcontext);
|
|
-#else
|
|
|
|
- SDL_GL_DeleteContext(glcontext);
|
|
|
|
-#endif
|
|
|
|
glcontext = nullptr;
|
|
glcontext = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -494,7 +460,6 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
struct SDLDisplayIDs
|
|
struct SDLDisplayIDs
|
|
{
|
|
{
|
|
SDLDisplayIDs()
|
|
SDLDisplayIDs()
|
|
@@ -519,7 +484,6 @@ static SDL_DisplayID GetSDLDisplayIDForIndex(int displayindex)
|
|
return (SDL_DisplayID) 0;
|
|
return (SDL_DisplayID) 0;
|
|
return displayids.ids[displayindex];
|
|
return displayids.ids[displayindex];
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
|
|
|
|
bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
{
|
|
{
|
|
@@ -542,28 +506,17 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
f.minwidth = std::max(f.minwidth, 1);
|
|
f.minwidth = std::max(f.minwidth, 1);
|
|
f.minheight = std::max(f.minheight, 1);
|
|
f.minheight = std::max(f.minheight, 1);
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDLDisplayIDs displays;
|
|
SDLDisplayIDs displays;
|
|
int displaycount = displays.count;
|
|
int displaycount = displays.count;
|
|
-#else
|
|
|
|
- int displaycount = getDisplayCount();
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
f.displayindex = std::min(std::max(f.displayindex, 0), displaycount - 1);
|
|
f.displayindex = std::min(std::max(f.displayindex, 0), displaycount - 1);
|
|
|
|
|
|
// Use the desktop resolution if a width or height of 0 is specified.
|
|
// Use the desktop resolution if a width or height of 0 is specified.
|
|
if (width == 0 || height == 0)
|
|
if (width == 0 || height == 0)
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(displays.ids[f.displayindex]);
|
|
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(displays.ids[f.displayindex]);
|
|
width = mode->w;
|
|
width = mode->w;
|
|
height = mode->h;
|
|
height = mode->h;
|
|
-#else
|
|
|
|
- SDL_DisplayMode mode = {};
|
|
|
|
- SDL_GetDesktopDisplayMode(f.displayindex, &mode);
|
|
|
|
- width = mode.w;
|
|
|
|
- height = mode.h;
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// On Android, disable fullscreen first on window creation so it's
|
|
// On Android, disable fullscreen first on window creation so it's
|
|
@@ -599,15 +552,10 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
}
|
|
}
|
|
|
|
|
|
Uint32 sdlflags = 0;
|
|
Uint32 sdlflags = 0;
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_DisplayMode fsmode = {};
|
|
SDL_DisplayMode fsmode = {};
|
|
-#else
|
|
|
|
- SDL_DisplayMode fsmode = {0, width, height, 0, nullptr};
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (f.fullscreen)
|
|
if (f.fullscreen)
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
sdlflags |= SDL_WINDOW_FULLSCREEN;
|
|
sdlflags |= SDL_WINDOW_FULLSCREEN;
|
|
|
|
|
|
if (f.fstype == FULLSCREEN_EXCLUSIVE)
|
|
if (f.fstype == FULLSCREEN_EXCLUSIVE)
|
|
@@ -627,28 +575,6 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- if (f.fstype == FULLSCREEN_EXCLUSIVE)
|
|
|
|
- {
|
|
|
|
- // Fullscreen window creation will bug out if no mode can be used.
|
|
|
|
- if (SDL_GetClosestDisplayMode(f.displayindex, &fsmode, &fsmode) == nullptr)
|
|
|
|
- {
|
|
|
|
- // GetClosestDisplayMode will fail if we request a size larger
|
|
|
|
- // than the largest available display mode, so we'll try to use
|
|
|
|
- // the largest (first) mode in that case.
|
|
|
|
- if (SDL_GetDisplayMode(f.displayindex, 0, &fsmode) < 0)
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- sdlflags |= SDL_WINDOW_FULLSCREEN;
|
|
|
|
- width = fsmode.w;
|
|
|
|
- height = fsmode.h;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sdlflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
bool needsetmode = false;
|
|
bool needsetmode = false;
|
|
@@ -658,34 +584,22 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
|
|
|
|
if (isOpen())
|
|
if (isOpen())
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (fsmode.w > 0 && fsmode.h > 0)
|
|
if (fsmode.w > 0 && fsmode.h > 0)
|
|
SDL_SetWindowFullscreenMode(window, &fsmode);
|
|
SDL_SetWindowFullscreenMode(window, &fsmode);
|
|
else
|
|
else
|
|
SDL_SetWindowFullscreenMode(window, nullptr);
|
|
SDL_SetWindowFullscreenMode(window, nullptr);
|
|
|
|
+
|
|
if (SDL_SetWindowFullscreen(window, (sdlflags & SDL_WINDOW_FULLSCREEN) != 0) && renderer == graphics::RENDERER_OPENGL)
|
|
if (SDL_SetWindowFullscreen(window, (sdlflags & SDL_WINDOW_FULLSCREEN) != 0) && renderer == graphics::RENDERER_OPENGL)
|
|
-#else
|
|
|
|
- if (f.fullscreen && f.fstype == FULLSCREEN_EXCLUSIVE)
|
|
|
|
- SDL_SetWindowDisplayMode(window, &fsmode);
|
|
|
|
- if (SDL_SetWindowFullscreen(window, sdlflags) == 0 && renderer == graphics::RENDERER_OPENGL)
|
|
|
|
-#endif
|
|
|
|
SDL_GL_MakeCurrent(window, glcontext);
|
|
SDL_GL_MakeCurrent(window, glcontext);
|
|
|
|
|
|
|
|
+ // TODO: should we make this conditional, to avoid love.resize events when the size doesn't change?
|
|
SDL_SetWindowSize(window, width, height);
|
|
SDL_SetWindowSize(window, width, height);
|
|
|
|
|
|
if (this->settings.resizable != f.resizable)
|
|
if (this->settings.resizable != f.resizable)
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SetWindowResizable(window, f.resizable);
|
|
SDL_SetWindowResizable(window, f.resizable);
|
|
-#else
|
|
|
|
- SDL_SetWindowResizable(window, f.resizable ? SDL_TRUE : SDL_FALSE);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (this->settings.borderless != f.borderless)
|
|
if (this->settings.borderless != f.borderless)
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SetWindowBordered(window, !f.borderless);
|
|
SDL_SetWindowBordered(window, !f.borderless);
|
|
-#else
|
|
|
|
- SDL_SetWindowBordered(window, f.borderless ? SDL_FALSE : SDL_TRUE);
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -706,15 +620,9 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
sdlflags |= SDL_WINDOW_BORDERLESS;
|
|
sdlflags |= SDL_WINDOW_BORDERLESS;
|
|
|
|
|
|
// Note: this flag is ignored on Windows.
|
|
// Note: this flag is ignored on Windows.
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (isHighDPIAllowed())
|
|
if (isHighDPIAllowed())
|
|
sdlflags |= SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
|
sdlflags |= SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
|
-#else
|
|
|
|
- if (isHighDPIAllowed())
|
|
|
|
- sdlflags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
Uint32 createflags = sdlflags & (~SDL_WINDOW_FULLSCREEN);
|
|
Uint32 createflags = sdlflags & (~SDL_WINDOW_FULLSCREEN);
|
|
|
|
|
|
if (!createWindowAndContext(x, y, width, height, createflags, renderer))
|
|
if (!createWindowAndContext(x, y, width, height, createflags, renderer))
|
|
@@ -728,10 +636,6 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
SDL_SetWindowFullscreenMode(window, nullptr);
|
|
SDL_SetWindowFullscreenMode(window, nullptr);
|
|
SDL_SetWindowFullscreen(window, true);
|
|
SDL_SetWindowFullscreen(window, true);
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- if (!createWindowAndContext(x, y, width, height, sdlflags, renderer))
|
|
|
|
- return false;
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
needsetmode = true;
|
|
needsetmode = true;
|
|
}
|
|
}
|
|
@@ -771,6 +675,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
context = (void *) SDL_Metal_GetLayer(metalView);
|
|
context = (void *) SDL_Metal_GetLayer(metalView);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+ // TODO: try/catch
|
|
graphics->setMode(context, (int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil, f.depth, f.msaa);
|
|
graphics->setMode(context, (int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil, f.depth, f.msaa);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -788,9 +693,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|
love::android::setImmersive(fullscreen);
|
|
love::android::setImmersive(fullscreen);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SyncWindow(window);
|
|
SDL_SyncWindow(window);
|
|
-#endif
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -800,29 +703,9 @@ bool Window::onSizeChanged(int width, int height)
|
|
if (!window)
|
|
if (!window)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
|
|
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
|
|
-#else
|
|
|
|
- windowWidth = width;
|
|
|
|
- windowHeight = height;
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (!SDL_GetWindowSizeInPixels(window, &pixelWidth, &pixelHeight))
|
|
if (!SDL_GetWindowSizeInPixels(window, &pixelWidth, &pixelHeight))
|
|
-#else
|
|
|
|
- // TODO: Use SDL_GetWindowSizeInPixels here when supported.
|
|
|
|
- if (glcontext != nullptr)
|
|
|
|
- SDL_GL_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
|
|
|
-#ifdef LOVE_GRAPHICS_METAL
|
|
|
|
- else if (metalView != nullptr)
|
|
|
|
- SDL_Metal_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
|
|
|
-#endif
|
|
|
|
-#ifdef LOVE_GRAPHICS_VULKAN
|
|
|
|
- else if (windowRenderer == graphics::RENDERER_VULKAN)
|
|
|
|
- SDL_Vulkan_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
|
|
|
-#endif
|
|
|
|
- else
|
|
|
|
-#endif
|
|
|
|
{
|
|
{
|
|
pixelWidth = width;
|
|
pixelWidth = width;
|
|
pixelHeight = height;
|
|
pixelHeight = height;
|
|
@@ -840,9 +723,7 @@ bool Window::onSizeChanged(int width, int height)
|
|
|
|
|
|
void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport)
|
|
void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport)
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SyncWindow(window);
|
|
SDL_SyncWindow(window);
|
|
-#endif
|
|
|
|
|
|
|
|
Uint32 wflags = SDL_GetWindowFlags(window);
|
|
Uint32 wflags = SDL_GetWindowFlags(window);
|
|
|
|
|
|
@@ -852,27 +733,9 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
|
pixelWidth = windowWidth;
|
|
pixelWidth = windowWidth;
|
|
pixelHeight = windowHeight;
|
|
pixelHeight = windowHeight;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_GetWindowSizeInPixels(window, &pixelWidth, &pixelHeight);
|
|
SDL_GetWindowSizeInPixels(window, &pixelWidth, &pixelHeight);
|
|
-#else
|
|
|
|
- // TODO: Use SDL_GetWindowSizeInPixels here when supported.
|
|
|
|
- if ((wflags & SDL_WINDOW_OPENGL) != 0)
|
|
|
|
- SDL_GL_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
|
|
|
-#ifdef LOVE_GRAPHICS_METAL
|
|
|
|
- else if ((wflags & SDL_WINDOW_METAL) != 0)
|
|
|
|
- SDL_Metal_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
|
|
|
-#endif
|
|
|
|
-#ifdef LOVE_GRAPHICS_VULKAN
|
|
|
|
- else if ((wflags & SDL_WINDOW_VULKAN) != 0)
|
|
|
|
- SDL_Vulkan_GetDrawableSize(window, &pixelWidth, &pixelHeight);
|
|
|
|
-#endif
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (((wflags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) && SDL_GetWindowFullscreenMode(window) == nullptr)
|
|
if (((wflags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) && SDL_GetWindowFullscreenMode(window) == nullptr)
|
|
-#else
|
|
|
|
- if ((wflags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
|
|
|
-#endif
|
|
|
|
{
|
|
{
|
|
settings.fullscreen = true;
|
|
settings.fullscreen = true;
|
|
settings.fstype = FULLSCREEN_DESKTOP;
|
|
settings.fstype = FULLSCREEN_DESKTOP;
|
|
@@ -902,11 +765,7 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
|
|
|
|
|
getPosition(settings.x, settings.y, settings.displayindex);
|
|
getPosition(settings.x, settings.y, settings.displayindex);
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
setHighDPIAllowed((wflags & SDL_WINDOW_HIGH_PIXEL_DENSITY) != 0);
|
|
setHighDPIAllowed((wflags & SDL_WINDOW_HIGH_PIXEL_DENSITY) != 0);
|
|
-#else
|
|
|
|
- setHighDPIAllowed((wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
settings.usedpiscale = newsettings.usedpiscale;
|
|
settings.usedpiscale = newsettings.usedpiscale;
|
|
|
|
|
|
@@ -921,19 +780,11 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
|
settings.stencil = newsettings.stencil;
|
|
settings.stencil = newsettings.stencil;
|
|
settings.depth = newsettings.depth;
|
|
settings.depth = newsettings.depth;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDLDisplayIDs displayids;
|
|
SDLDisplayIDs displayids;
|
|
const SDL_DisplayMode *dmode = SDL_GetCurrentDisplayMode(displayids.ids[settings.displayindex]);
|
|
const SDL_DisplayMode *dmode = SDL_GetCurrentDisplayMode(displayids.ids[settings.displayindex]);
|
|
|
|
|
|
// May be 0 if the refresh rate can't be determined.
|
|
// May be 0 if the refresh rate can't be determined.
|
|
settings.refreshrate = dmode->refresh_rate;
|
|
settings.refreshrate = dmode->refresh_rate;
|
|
-#else
|
|
|
|
- SDL_DisplayMode dmode = {};
|
|
|
|
- SDL_GetCurrentDisplayMode(settings.displayindex, &dmode);
|
|
|
|
-
|
|
|
|
- // May be 0 if the refresh rate can't be determined.
|
|
|
|
- settings.refreshrate = (double) dmode.refresh_rate;
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
// Update the viewport size now instead of waiting for event polling.
|
|
// Update the viewport size now instead of waiting for event polling.
|
|
if (updateGraphicsViewport && graphics.get())
|
|
if (updateGraphicsViewport && graphics.get())
|
|
@@ -972,11 +823,7 @@ void Window::close(bool allowExceptions)
|
|
|
|
|
|
if (glcontext)
|
|
if (glcontext)
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_GL_DestroyContext(glcontext);
|
|
SDL_GL_DestroyContext(glcontext);
|
|
-#else
|
|
|
|
- SDL_GL_DeleteContext(glcontext);
|
|
|
|
-#endif
|
|
|
|
glcontext = nullptr;
|
|
glcontext = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -995,11 +842,7 @@ void Window::close(bool allowExceptions)
|
|
|
|
|
|
// The old window may have generated pending events which are no longer
|
|
// The old window may have generated pending events which are no longer
|
|
// relevant. Destroy them all!
|
|
// relevant. Destroy them all!
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_FlushEvents(SDL_EVENT_WINDOW_FIRST, SDL_EVENT_WINDOW_LAST);
|
|
SDL_FlushEvents(SDL_EVENT_WINDOW_FIRST, SDL_EVENT_WINDOW_LAST);
|
|
-#else
|
|
|
|
- SDL_FlushEvent(SDL_WINDOWEVENT);
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
open = false;
|
|
open = false;
|
|
@@ -1017,7 +860,6 @@ bool Window::setFullscreen(bool fullscreen, FullscreenType fstype)
|
|
newsettings.fullscreen = fullscreen;
|
|
newsettings.fullscreen = fullscreen;
|
|
newsettings.fstype = fstype;
|
|
newsettings.fstype = fstype;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
bool sdlflags = fullscreen;
|
|
bool sdlflags = fullscreen;
|
|
if (fullscreen)
|
|
if (fullscreen)
|
|
{
|
|
{
|
|
@@ -1031,36 +873,12 @@ bool Window::setFullscreen(bool fullscreen, FullscreenType fstype)
|
|
SDL_SetWindowFullscreenMode(window, &mode);
|
|
SDL_SetWindowFullscreenMode(window, &mode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- Uint32 sdlflags = 0;
|
|
|
|
-
|
|
|
|
- if (fullscreen)
|
|
|
|
- {
|
|
|
|
- if (fstype == FULLSCREEN_DESKTOP)
|
|
|
|
- sdlflags = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sdlflags = SDL_WINDOW_FULLSCREEN;
|
|
|
|
-
|
|
|
|
- SDL_DisplayMode mode = {};
|
|
|
|
- mode.w = windowWidth;
|
|
|
|
- mode.h = windowHeight;
|
|
|
|
-
|
|
|
|
- SDL_GetClosestDisplayMode(SDL_GetWindowDisplayIndex(window), &mode, &mode);
|
|
|
|
- SDL_SetWindowDisplayMode(window, &mode);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
#ifdef LOVE_ANDROID
|
|
#ifdef LOVE_ANDROID
|
|
love::android::setImmersive(fullscreen);
|
|
love::android::setImmersive(fullscreen);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (SDL_SetWindowFullscreen(window, sdlflags))
|
|
if (SDL_SetWindowFullscreen(window, sdlflags))
|
|
-#else
|
|
|
|
- if (SDL_SetWindowFullscreen(window, sdlflags) == 0)
|
|
|
|
-#endif
|
|
|
|
{
|
|
{
|
|
if (glcontext)
|
|
if (glcontext)
|
|
SDL_GL_MakeCurrent(window, glcontext);
|
|
SDL_GL_MakeCurrent(window, glcontext);
|
|
@@ -1079,21 +897,13 @@ bool Window::setFullscreen(bool fullscreen)
|
|
|
|
|
|
int Window::getDisplayCount() const
|
|
int Window::getDisplayCount() const
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDLDisplayIDs displayids;
|
|
SDLDisplayIDs displayids;
|
|
return displayids.count;
|
|
return displayids.count;
|
|
-#else
|
|
|
|
- return SDL_GetNumVideoDisplays();
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
const char *Window::getDisplayName(int displayindex) const
|
|
const char *Window::getDisplayName(int displayindex) const
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
const char *name = SDL_GetDisplayName(GetSDLDisplayIDForIndex(displayindex));
|
|
const char *name = SDL_GetDisplayName(GetSDLDisplayIDForIndex(displayindex));
|
|
-#else
|
|
|
|
- const char *name = SDL_GetDisplayName(displayindex);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (name == nullptr)
|
|
if (name == nullptr)
|
|
throw love::Exception("Invalid display index: %d", displayindex + 1);
|
|
throw love::Exception("Invalid display index: %d", displayindex + 1);
|
|
@@ -1103,11 +913,7 @@ const char *Window::getDisplayName(int displayindex) const
|
|
|
|
|
|
Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
|
|
Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
switch (SDL_GetCurrentDisplayOrientation(GetSDLDisplayIDForIndex(displayindex)))
|
|
switch (SDL_GetCurrentDisplayOrientation(GetSDLDisplayIDForIndex(displayindex)))
|
|
-#else
|
|
|
|
- switch (SDL_GetDisplayOrientation(displayindex))
|
|
|
|
-#endif
|
|
|
|
{
|
|
{
|
|
case SDL_ORIENTATION_UNKNOWN: return ORIENTATION_UNKNOWN;
|
|
case SDL_ORIENTATION_UNKNOWN: return ORIENTATION_UNKNOWN;
|
|
case SDL_ORIENTATION_LANDSCAPE: return ORIENTATION_LANDSCAPE;
|
|
case SDL_ORIENTATION_LANDSCAPE: return ORIENTATION_LANDSCAPE;
|
|
@@ -1123,7 +929,6 @@ std::vector<Window::WindowSize> Window::getFullscreenSizes(int displayindex) con
|
|
{
|
|
{
|
|
std::vector<WindowSize> sizes;
|
|
std::vector<WindowSize> sizes;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
int count = 0;
|
|
int count = 0;
|
|
SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(GetSDLDisplayIDForIndex(displayindex), &count);
|
|
SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(GetSDLDisplayIDForIndex(displayindex), &count);
|
|
|
|
|
|
@@ -1131,14 +936,6 @@ std::vector<Window::WindowSize> Window::getFullscreenSizes(int displayindex) con
|
|
{
|
|
{
|
|
// TODO: other mode properties?
|
|
// TODO: other mode properties?
|
|
WindowSize w = {modes[i]->w, modes[i]->h};
|
|
WindowSize w = {modes[i]->w, modes[i]->h};
|
|
-#else
|
|
|
|
- for (int i = 0; i < SDL_GetNumDisplayModes(displayindex); i++)
|
|
|
|
- {
|
|
|
|
- SDL_DisplayMode mode = {};
|
|
|
|
- SDL_GetDisplayMode(displayindex, i, &mode);
|
|
|
|
-
|
|
|
|
- WindowSize w = {mode.w, mode.h};
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
// SDL2's display mode list has multiple entries for modes of the same
|
|
// SDL2's display mode list has multiple entries for modes of the same
|
|
// size with different bits per pixel, so we need to filter those out.
|
|
// size with different bits per pixel, so we need to filter those out.
|
|
@@ -1146,16 +943,13 @@ std::vector<Window::WindowSize> Window::getFullscreenSizes(int displayindex) con
|
|
sizes.push_back(w);
|
|
sizes.push_back(w);
|
|
}
|
|
}
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_free(modes);
|
|
SDL_free(modes);
|
|
-#endif
|
|
|
|
|
|
|
|
return sizes;
|
|
return sizes;
|
|
}
|
|
}
|
|
|
|
|
|
void Window::getDesktopDimensions(int displayindex, int &width, int &height) const
|
|
void Window::getDesktopDimensions(int displayindex, int &width, int &height) const
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(GetSDLDisplayIDForIndex(displayindex));
|
|
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(GetSDLDisplayIDForIndex(displayindex));
|
|
if (mode != nullptr)
|
|
if (mode != nullptr)
|
|
{
|
|
{
|
|
@@ -1163,15 +957,6 @@ void Window::getDesktopDimensions(int displayindex, int &width, int &height) con
|
|
width = mode->w;
|
|
width = mode->w;
|
|
height = mode->h;
|
|
height = mode->h;
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- if (displayindex >= 0 && displayindex < getDisplayCount())
|
|
|
|
- {
|
|
|
|
- SDL_DisplayMode mode = {};
|
|
|
|
- SDL_GetDesktopDisplayMode(displayindex, &mode);
|
|
|
|
- width = mode.w;
|
|
|
|
- height = mode.h;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
else
|
|
else
|
|
{
|
|
{
|
|
width = 0;
|
|
width = 0;
|
|
@@ -1194,10 +979,7 @@ void Window::setPosition(int x, int y, int displayindex)
|
|
y += displaybounds.y;
|
|
y += displaybounds.y;
|
|
|
|
|
|
SDL_SetWindowPosition(window, x, y);
|
|
SDL_SetWindowPosition(window, x, y);
|
|
-
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SyncWindow(window);
|
|
SDL_SyncWindow(window);
|
|
-#endif
|
|
|
|
|
|
|
|
settings.useposition = true;
|
|
settings.useposition = true;
|
|
}
|
|
}
|
|
@@ -1211,7 +993,6 @@ void Window::getPosition(int &x, int &y, int &displayindex)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_DisplayID displayid = SDL_GetDisplayForWindow(window);
|
|
SDL_DisplayID displayid = SDL_GetDisplayForWindow(window);
|
|
SDLDisplayIDs displayids;
|
|
SDLDisplayIDs displayids;
|
|
displayindex = 0;
|
|
displayindex = 0;
|
|
@@ -1223,9 +1004,6 @@ void Window::getPosition(int &x, int &y, int &displayindex)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- displayindex = std::max(SDL_GetWindowDisplayIndex(window), 0);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
SDL_GetWindowPosition(window, &x, &y);
|
|
SDL_GetWindowPosition(window, &x, &y);
|
|
|
|
|
|
@@ -1235,11 +1013,7 @@ void Window::getPosition(int &x, int &y, int &displayindex)
|
|
if (x != 0 || y != 0)
|
|
if (x != 0 || y != 0)
|
|
{
|
|
{
|
|
SDL_Rect displaybounds = {};
|
|
SDL_Rect displaybounds = {};
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_GetDisplayBounds(displayid, &displaybounds);
|
|
SDL_GetDisplayBounds(displayid, &displaybounds);
|
|
-#else
|
|
|
|
- SDL_GetDisplayBounds(displayindex, &displaybounds);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
x -= displaybounds.x;
|
|
x -= displaybounds.x;
|
|
y -= displaybounds.y;
|
|
y -= displaybounds.y;
|
|
@@ -1304,41 +1078,18 @@ bool Window::setIcon(love::image::ImageData *imgd)
|
|
if (!window)
|
|
if (!window)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
-#if !SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
- Uint32 rmask, gmask, bmask, amask;
|
|
|
|
-#ifdef LOVE_BIG_ENDIAN
|
|
|
|
- rmask = 0xFF000000;
|
|
|
|
- gmask = 0x00FF0000;
|
|
|
|
- bmask = 0x0000FF00;
|
|
|
|
- amask = 0x000000FF;
|
|
|
|
-#else
|
|
|
|
- rmask = 0x000000FF;
|
|
|
|
- gmask = 0x0000FF00;
|
|
|
|
- bmask = 0x00FF0000;
|
|
|
|
- amask = 0xFF000000;
|
|
|
|
-#endif
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
int w = imgd->getWidth();
|
|
int w = imgd->getWidth();
|
|
int h = imgd->getHeight();
|
|
int h = imgd->getHeight();
|
|
int bytesperpixel = (int) getPixelFormatBlockSize(imgd->getFormat());
|
|
int bytesperpixel = (int) getPixelFormatBlockSize(imgd->getFormat());
|
|
int pitch = w * bytesperpixel;
|
|
int pitch = w * bytesperpixel;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_Surface *sdlicon = SDL_CreateSurfaceFrom(w, h, SDL_PIXELFORMAT_RGBA8888, imgd->getData(), pitch);
|
|
SDL_Surface *sdlicon = SDL_CreateSurfaceFrom(w, h, SDL_PIXELFORMAT_RGBA8888, imgd->getData(), pitch);
|
|
-#else
|
|
|
|
- SDL_Surface *sdlicon = SDL_CreateRGBSurfaceFrom(imgd->getData(), w, h, bytesperpixel * 8, pitch, rmask, gmask, bmask, amask);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (!sdlicon)
|
|
if (!sdlicon)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
SDL_SetWindowIcon(window, sdlicon);
|
|
SDL_SetWindowIcon(window, sdlicon);
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_DestroySurface(sdlicon);
|
|
SDL_DestroySurface(sdlicon);
|
|
-#else
|
|
|
|
- SDL_FreeSurface(sdlicon);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -1356,7 +1107,6 @@ void Window::setVSync(int vsync)
|
|
|
|
|
|
// Check if adaptive vsync was requested but not supported, and fall
|
|
// Check if adaptive vsync was requested but not supported, and fall
|
|
// back to regular vsync if so.
|
|
// back to regular vsync if so.
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
if (vsync == -1)
|
|
if (vsync == -1)
|
|
{
|
|
{
|
|
int actualvsync = 0;
|
|
int actualvsync = 0;
|
|
@@ -1364,10 +1114,6 @@ void Window::setVSync(int vsync)
|
|
if (actualvsync != -1)
|
|
if (actualvsync != -1)
|
|
SDL_GL_SetSwapInterval(1);
|
|
SDL_GL_SetSwapInterval(1);
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- if (vsync == -1 && SDL_GL_GetSwapInterval() != -1)
|
|
|
|
- SDL_GL_SetSwapInterval(1);
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef LOVE_GRAPHICS_VULKAN
|
|
#ifdef LOVE_GRAPHICS_VULKAN
|
|
@@ -1391,13 +1137,9 @@ int Window::getVSync() const
|
|
{
|
|
{
|
|
if (glcontext != nullptr)
|
|
if (glcontext != nullptr)
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
int interval = 0;
|
|
int interval = 0;
|
|
SDL_GL_GetSwapInterval(&interval);
|
|
SDL_GL_GetSwapInterval(&interval);
|
|
return interval;
|
|
return interval;
|
|
-#else
|
|
|
|
- return SDL_GL_GetSwapInterval();
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#if defined(LOVE_GRAPHICS_METAL)
|
|
#if defined(LOVE_GRAPHICS_METAL)
|
|
@@ -1433,11 +1175,7 @@ void Window::setDisplaySleepEnabled(bool enable)
|
|
|
|
|
|
bool Window::isDisplaySleepEnabled() const
|
|
bool Window::isDisplaySleepEnabled() const
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
return SDL_ScreenSaverEnabled();
|
|
return SDL_ScreenSaverEnabled();
|
|
-#else
|
|
|
|
- return SDL_IsScreenSaverEnabled() != SDL_FALSE;
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void Window::minimize()
|
|
void Window::minimize()
|
|
@@ -1515,27 +1253,16 @@ void Window::swapBuffers()
|
|
dwmRefreshRate = (double)info.rateRefresh.uiNumerator / (double)info.rateRefresh.uiDenominator;
|
|
dwmRefreshRate = (double)info.rateRefresh.uiNumerator / (double)info.rateRefresh.uiDenominator;
|
|
|
|
|
|
SDL_DisplayMode dmode = {};
|
|
SDL_DisplayMode dmode = {};
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_DisplayID display = SDL_GetDisplayForWindow(window);
|
|
SDL_DisplayID display = SDL_GetDisplayForWindow(window);
|
|
const SDL_DisplayMode* modePtr = SDL_GetCurrentDisplayMode(display);
|
|
const SDL_DisplayMode* modePtr = SDL_GetCurrentDisplayMode(display);
|
|
if (modePtr)
|
|
if (modePtr)
|
|
dmode = *modePtr;
|
|
dmode = *modePtr;
|
|
-#else
|
|
|
|
- int displayindex = SDL_GetWindowDisplayIndex(window);
|
|
|
|
-
|
|
|
|
- if (displayindex >= 0)
|
|
|
|
- SDL_GetCurrentDisplayMode(displayindex, &dmode);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
if (dmode.refresh_rate > 0 && dwmRefreshRate > 0 && (fabs(dmode.refresh_rate - dwmRefreshRate) < 2))
|
|
if (dmode.refresh_rate > 0 && dwmRefreshRate > 0 && (fabs(dmode.refresh_rate - dwmRefreshRate) < 2))
|
|
{
|
|
{
|
|
SDL_GL_SetSwapInterval(0);
|
|
SDL_GL_SetSwapInterval(0);
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
int interval = 0;
|
|
int interval = 0;
|
|
if (SDL_GL_GetSwapInterval(&interval) == 0 && interval == 0)
|
|
if (SDL_GL_GetSwapInterval(&interval) == 0 && interval == 0)
|
|
-#else
|
|
|
|
- if (SDL_GL_GetSwapInterval() == 0)
|
|
|
|
-#endif
|
|
|
|
useDwmFlush = true;
|
|
useDwmFlush = true;
|
|
else
|
|
else
|
|
SDL_GL_SetSwapInterval(swapInterval);
|
|
SDL_GL_SetSwapInterval(swapInterval);
|
|
@@ -1568,32 +1295,20 @@ bool Window::hasMouseFocus() const
|
|
|
|
|
|
bool Window::isVisible() const
|
|
bool Window::isVisible() const
|
|
{
|
|
{
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
return window && (SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN) == 0;
|
|
return window && (SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN) == 0;
|
|
-#else
|
|
|
|
- return window && (SDL_GetWindowFlags(window) & SDL_WINDOW_SHOWN) != 0;
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void Window::setMouseGrab(bool grab)
|
|
void Window::setMouseGrab(bool grab)
|
|
{
|
|
{
|
|
mouseGrabbed = grab;
|
|
mouseGrabbed = grab;
|
|
if (window)
|
|
if (window)
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
SDL_SetWindowMouseGrab(window, grab);
|
|
SDL_SetWindowMouseGrab(window, grab);
|
|
-#else
|
|
|
|
- SDL_SetWindowGrab(window, (SDL_bool) grab);
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
bool Window::isMouseGrabbed() const
|
|
bool Window::isMouseGrabbed() const
|
|
{
|
|
{
|
|
if (window)
|
|
if (window)
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
return SDL_GetWindowMouseGrab(window);
|
|
return SDL_GetWindowMouseGrab(window);
|
|
-#else
|
|
|
|
- return SDL_GetWindowGrab(window) != SDL_FALSE;
|
|
|
|
-#endif
|
|
|
|
else
|
|
else
|
|
return mouseGrabbed;
|
|
return mouseGrabbed;
|
|
}
|
|
}
|
|
@@ -1739,11 +1454,7 @@ bool Window::showMessageBox(const std::string &title, const std::string &message
|
|
SDL_MessageBoxFlags flags = convertMessageBoxType(type);
|
|
SDL_MessageBoxFlags flags = convertMessageBoxType(type);
|
|
SDL_Window *sdlwindow = attachtowindow ? window : nullptr;
|
|
SDL_Window *sdlwindow = attachtowindow ? window : nullptr;
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
return SDL_ShowSimpleMessageBox(flags, title.c_str(), message.c_str(), sdlwindow);
|
|
return SDL_ShowSimpleMessageBox(flags, title.c_str(), message.c_str(), sdlwindow);
|
|
-#else
|
|
|
|
- return SDL_ShowSimpleMessageBox(flags, title.c_str(), message.c_str(), sdlwindow) >= 0;
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
int Window::showMessageBox(const MessageBoxData &data)
|
|
int Window::showMessageBox(const MessageBoxData &data)
|
|
@@ -1763,11 +1474,7 @@ int Window::showMessageBox(const MessageBoxData &data)
|
|
{
|
|
{
|
|
SDL_MessageBoxButtonData sdlbutton = {};
|
|
SDL_MessageBoxButtonData sdlbutton = {};
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
sdlbutton.buttonID = i;
|
|
sdlbutton.buttonID = i;
|
|
-#else
|
|
|
|
- sdlbutton.buttonid = i;
|
|
|
|
-#endif
|
|
|
|
sdlbutton.text = data.buttons[i].c_str();
|
|
sdlbutton.text = data.buttons[i].c_str();
|
|
|
|
|
|
if (i == data.enterButtonIndex)
|
|
if (i == data.enterButtonIndex)
|
|
@@ -1796,17 +1503,7 @@ void Window::requestAttention(bool continuous)
|
|
|
|
|
|
FLASHWINFO flashinfo = { sizeof(FLASHWINFO) };
|
|
FLASHWINFO flashinfo = { sizeof(FLASHWINFO) };
|
|
|
|
|
|
-#if SDL_VERSION_ATLEAST(3, 0, 0)
|
|
|
|
flashinfo.hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
|
|
flashinfo.hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
|
|
-#else
|
|
|
|
- SDL_SysWMinfo wminfo = {};
|
|
|
|
- SDL_VERSION(&wminfo.version);
|
|
|
|
- if (!SDL_GetWindowWMInfo(window, &wminfo))
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- flashinfo.hwnd = wminfo.info.win.window;
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
flashinfo.uCount = 1;
|
|
flashinfo.uCount = 1;
|
|
flashinfo.dwFlags = FLASHW_ALL;
|
|
flashinfo.dwFlags = FLASHW_ALL;
|
|
|
|
|