mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 12:40:28 +02:00
updated to changeset 80f0adedfaa5 of love-android (including newest mobile-common changes)
This commit is contained in:
@@ -50,6 +50,7 @@ WindowSettings::WindowSettings()
|
||||
, centered(true)
|
||||
, display(0)
|
||||
, highdpi(false)
|
||||
, sRGB(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -86,6 +87,7 @@ StringMap<Window::Setting, Window::SETTING_MAX_ENUM>::Entry Window::settingEntri
|
||||
{"centered", SETTING_CENTERED},
|
||||
{"display", SETTING_DISPLAY},
|
||||
{"highdpi", SETTING_HIGHDPI},
|
||||
{"srgb", SETTING_SRGB},
|
||||
};
|
||||
|
||||
StringMap<Window::Setting, Window::SETTING_MAX_ENUM> Window::settings(Window::settingEntries, sizeof(Window::settingEntries));
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
SETTING_CENTERED,
|
||||
SETTING_DISPLAY,
|
||||
SETTING_HIGHDPI,
|
||||
SETTING_SRGB,
|
||||
SETTING_MAX_ENUM
|
||||
};
|
||||
|
||||
@@ -157,6 +158,7 @@ struct WindowSettings
|
||||
bool centered; // = true
|
||||
int display; // = 0
|
||||
bool highdpi; // false
|
||||
bool sRGB; // false
|
||||
|
||||
}; // WindowSettings
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
f.minwidth = std::max(f.minwidth, 1);
|
||||
f.minheight = std::max(f.minheight, 1);
|
||||
|
||||
f.display = std::min(std::max(f.display, 0), getDisplayCount());
|
||||
f.display = std::min(std::max(f.display, 0), getDisplayCount() - 1);
|
||||
|
||||
// Use the desktop resolution if a width or height of 0 is specified.
|
||||
if (width == 0 || height == 0)
|
||||
@@ -161,7 +161,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
if (!window)
|
||||
{
|
||||
// In Windows and Linux, some GL attributes are set on window creation.
|
||||
setWindowGLAttributes(f.fsaa);
|
||||
setWindowGLAttributes(f.fsaa, f.sRGB);
|
||||
|
||||
const char *title = windowTitle.c_str();
|
||||
int pos = f.centered ? centeredpos : uncenteredpos;
|
||||
@@ -197,7 +197,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
|
||||
SDL_RaiseWindow(window);
|
||||
|
||||
if (!setContext(f.fsaa, f.vsync))
|
||||
if (!setContext(f.fsaa, f.vsync, f.sRGB))
|
||||
{
|
||||
created = false;
|
||||
return false;
|
||||
@@ -216,7 +216,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
SDL_GL_GetDrawableSize(window, &width, &height);
|
||||
#endif
|
||||
|
||||
if (!gfx->setMode(width, height))
|
||||
if (!gfx->setMode(width, height, curMode.settings.sRGB))
|
||||
displayError("Could not set graphics mode", "Unsupported OpenGL version?");
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ bool Window::onWindowResize(int width, int height)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::setContext(int fsaa, bool vsync)
|
||||
bool Window::setContext(int fsaa, bool vsync, bool sRGB)
|
||||
{
|
||||
// We would normally only need to recreate the context if FSAA changes or
|
||||
// SDL_GL_MakeCurrent is unsuccessful, but in Windows MakeCurrent can
|
||||
@@ -249,7 +249,7 @@ bool Window::setContext(int fsaa, bool vsync)
|
||||
}
|
||||
|
||||
// Make sure the proper attributes are set.
|
||||
setWindowGLAttributes(fsaa);
|
||||
setWindowGLAttributes(fsaa, sRGB);
|
||||
|
||||
context = SDL_GL_CreateContext(window);
|
||||
|
||||
@@ -301,7 +301,7 @@ bool Window::setContext(int fsaa, bool vsync)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Window::setWindowGLAttributes(int fsaa) const
|
||||
void Window::setWindowGLAttributes(int fsaa, bool /* sRGB */) const
|
||||
{
|
||||
// Set GL window attributes.
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
@@ -315,6 +315,15 @@ void Window::setWindowGLAttributes(int fsaa) const
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa > 0) ? 1 : 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (fsaa > 0) ? fsaa : 0);
|
||||
|
||||
/* FIXME: Enable this code but make sure to try to re-create the window and
|
||||
* context with this disabled, if creation fails with it enabled.
|
||||
* We can leave this out for now because in practice the framebuffer will
|
||||
* already be sRGB-capable (on desktops at least.)
|
||||
#if SDL_VERSION_ATLEAST(2,0,1)
|
||||
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, sRGB ? 1 : 0);
|
||||
#endif
|
||||
*/
|
||||
|
||||
int contextprofile = 0;
|
||||
|
||||
bool tryES2 = false;
|
||||
@@ -410,6 +419,8 @@ void Window::updateSettings(const WindowSettings &newsettings)
|
||||
else
|
||||
#endif
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
|
||||
curMode.settings.sRGB = newsettings.sRGB;
|
||||
}
|
||||
|
||||
void Window::displayError(const std::string &title, const std::string &text) const
|
||||
|
||||
@@ -90,8 +90,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
bool setContext(int fsaa, bool vsync);
|
||||
void setWindowGLAttributes(int fsaa) const;
|
||||
bool setContext(int fsaa, bool vsync, bool sRGB);
|
||||
void setWindowGLAttributes(int fsaa, bool sRGB) const;
|
||||
|
||||
// Update the saved window settings based on the window's actual state.
|
||||
void updateSettings(const WindowSettings &newsettings);
|
||||
|
||||
@@ -96,6 +96,7 @@ int w_setMode(lua_State *L)
|
||||
settings.centered = luax_boolflag(L, 3, settingName(Window::SETTING_CENTERED), true);
|
||||
settings.display = luax_intflag(L, 3, settingName(Window::SETTING_DISPLAY), 1);
|
||||
settings.highdpi = luax_boolflag(L, 3, settingName(Window::SETTING_HIGHDPI), false);
|
||||
settings.sRGB = luax_boolflag(L, 3, settingName(Window::SETTING_SRGB), false);
|
||||
|
||||
// Display index is 1-based in Lua and 0-based internally.
|
||||
settings.display--;
|
||||
@@ -151,6 +152,9 @@ int w_getMode(lua_State *L)
|
||||
luax_pushboolean(L, settings.highdpi);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_HIGHDPI));
|
||||
|
||||
luax_pushboolean(L, settings.sRGB);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_SRGB));
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user