Always recreate the GL context in love.window.setMode - SDL_GL_MakeCurrent can return success sometimes in Windows even when the context is trashed

This commit is contained in:
Alex Szpakowski
2013-08-28 01:07:00 -03:00
parent 4a609aca03
commit 51d3fe22fc
+5 -7
View File
@@ -211,17 +211,16 @@ bool Window::onWindowResize(int width, int height)
bool Window::setContext(int fsaa, bool vsync) bool Window::setContext(int fsaa, bool vsync)
{ {
// We need to recreate the context if FSAA changes, // We would normally only need to recreate the context if FSAA changes or
// or if the existing context has been invalidated. // SDL_GL_MakeCurrent is unsuccessful, but in Windows MakeCurrent can
if (context && (fsaa != curMode.flags.fsaa || SDL_GL_MakeCurrent(window, context) < 0)) // sometimes claim success but the context will actually be trashed.
if (context)
{ {
SDL_GL_DeleteContext(context); SDL_GL_DeleteContext(context);
context = 0; context = 0;
} }
// Create a new OpenGL context. // Make sure the proper attributes are set.
if (!context)
{
setWindowGLAttributes(fsaa); setWindowGLAttributes(fsaa);
context = SDL_GL_CreateContext(window); context = SDL_GL_CreateContext(window);
@@ -233,7 +232,6 @@ bool Window::setContext(int fsaa, bool vsync)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
context = SDL_GL_CreateContext(window); context = SDL_GL_CreateContext(window);
} }
}
if (!context) if (!context)
{ {