Updated to latest love-android code (b615972822cb)

This commit is contained in:
fysx
2015-08-13 17:21:53 +02:00
parent f3dd769e98
commit 9cbddc2f5e
50 changed files with 827 additions and 663 deletions
-1
View File
@@ -77,7 +77,6 @@ StringMap<Window::Setting, Window::SETTING_MAX_ENUM>::Entry Window::settingEntri
{"centered", SETTING_CENTERED},
{"display", SETTING_DISPLAY},
{"highdpi", SETTING_HIGHDPI},
{"srgb", SETTING_SRGB},
{"refreshrate", SETTING_REFRESHRATE},
{"x", SETTING_X},
{"y", SETTING_Y},
-2
View File
@@ -57,7 +57,6 @@ public:
SETTING_CENTERED,
SETTING_DISPLAY,
SETTING_HIGHDPI,
SETTING_SRGB,
SETTING_REFRESHRATE,
SETTING_X,
SETTING_Y,
@@ -210,7 +209,6 @@ struct WindowSettings
bool centered = true;
int display = 0;
bool highdpi = false;
bool sRGB = false;
double refreshrate = 0.0;
bool useposition = false;
int x = 0;
+31 -15
View File
@@ -62,9 +62,14 @@ Window::Window()
, context(nullptr)
, displayedWindowError(false)
, displayedContextError(false)
, hasSDL203orEarlier(false)
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
throw love::Exception("Could not initialize SDL video subsystem (%s)", SDL_GetError());
SDL_version version = {};
SDL_GetVersion(&version);
hasSDL203orEarlier = (version.major == 2 && version.minor == 0 && version.patch <= 3);
}
Window::~Window()
@@ -88,12 +93,17 @@ void Window::setGLFramebufferAttributes(int msaa, bool sRGB)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (msaa > 0) ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (msaa > 0) ? msaa : 0);
// SDL or GLX may have bugs with this: https://bugzilla.libsdl.org/show_bug.cgi?id=2897
// It's fine to leave the attribute disabled on desktops though, because in
// practice the framebuffer will be sRGB-capable even if it's not requested.
#if !defined(LOVE_LINUX)
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, sRGB ? 1 : 0);
#endif
const char *driver = SDL_GetCurrentVideoDriver();
if (driver && strstr(driver, "x11") == driver)
{
// Always disable the sRGB flag when GLX is used with older SDL versions,
// because of this bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2897
// In practice GLX will always give an sRGB-capable framebuffer anyway.
if (hasSDL203orEarlier)
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 0);
}
#if defined(LOVE_WINDOWS)
// Avoid the Microsoft OpenGL 1.1 software renderer on Windows. Apparently
@@ -158,7 +168,7 @@ bool Window::checkGLVersion(const ContextAttribs &attribs)
return true;
}
bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa, bool sRGB)
bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa)
{
bool preferGLES = false;
@@ -175,6 +185,14 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
if (curdriver && strstr(curdriver, glesdriver) == curdriver)
{
preferGLES = true;
// Prior to SDL 2.0.4, backends that use OpenGL ES didn't properly
// ask for a sRGB framebuffer when requested by SDL_GL_SetAttribute.
// FIXME: This doesn't account for windowing backends that sometimes
// use EGL, e.g. the X11 and windows SDL backends.
if (hasSDL203orEarlier)
graphics::setGammaCorrect(false);
break;
}
}
@@ -196,11 +214,8 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
{2, 0, true, debug}, // OpenGL ES 2.
};
SDL_version sdlversion = {};
SDL_GetVersion(&sdlversion);
// OpenGL ES 3+ contexts are only properly supported in SDL 2.0.4+.
if (sdlversion.major == 2 && sdlversion.minor == 0 && sdlversion.patch <= 3)
if (hasSDL203orEarlier)
attribslist.erase(attribslist.begin() + 1);
// Move OpenGL ES to the front of the list if we should prefer GLES.
@@ -229,7 +244,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
}
int curMSAA = msaa;
bool curSRGB = sRGB;
bool curSRGB = love::graphics::isGammaCorrect();
setGLFramebufferAttributes(curMSAA, curSRGB);
setGLContextAttributes(attribs);
@@ -312,7 +327,10 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
}
if (context)
{
love::graphics::setGammaCorrect(curSRGB);
break;
}
}
if (!context || !window)
@@ -437,7 +455,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
close();
if (!createWindowAndContext(x, y, width, height, sdlflags, f.msaa, f.sRGB))
if (!createWindowAndContext(x, y, width, height, sdlflags, f.msaa))
return false;
// Make sure the window keeps any previously set icon.
@@ -460,7 +478,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
auto gfx = Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS);
if (gfx != nullptr)
gfx->setMode(curMode.pixelwidth, curMode.pixelheight, curMode.settings.sRGB);
gfx->setMode(curMode.pixelwidth, curMode.pixelheight);
#ifdef LOVE_ANDROID
love::android::setImmersive(f.fullscreen);
@@ -538,8 +556,6 @@ void Window::updateSettings(const WindowSettings &newsettings)
else
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
curMode.settings.sRGB = newsettings.sRGB;
// Verify MSAA setting.
int buffers = 0;
int samples = 0;
+3 -1
View File
@@ -119,7 +119,7 @@ private:
void setGLFramebufferAttributes(int msaa, bool sRGB);
void setGLContextAttributes(const ContextAttribs &attribs);
bool checkGLVersion(const ContextAttribs &attribs);
bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa, bool sRGB);
bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa);
// Update the saved window settings based on the window's actual state.
void updateSettings(const WindowSettings &newsettings);
@@ -149,6 +149,8 @@ private:
bool displayedWindowError;
bool displayedContextError;
bool hasSDL203orEarlier;
}; // Window
} // sdl
@@ -107,7 +107,6 @@ 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) - 1;
settings.highdpi = luax_boolflag(L, 3, settingName(Window::SETTING_HIGHDPI), false);
settings.sRGB = luax_boolflag(L, 3, settingName(Window::SETTING_SRGB), false);
lua_getfield(L, 3, settingName(Window::SETTING_X));
lua_getfield(L, 3, settingName(Window::SETTING_Y));
@@ -175,9 +174,6 @@ 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));
lua_pushnumber(L, settings.refreshrate);
lua_setfield(L, -2, settingName(Window::SETTING_REFRESHRATE));