From df5630225d4cc57456259a06f8653c85f770b05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 4 Apr 2013 15:19:45 +0200 Subject: [PATCH] Platform: minor code cleanup in Sdl2Application. * Explicitly set multisample attributes in all cases (so the attributes are always properly set when creating another context). * Do both assign and test in `if` statement. --- src/Platform/Sdl2Application.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Platform/Sdl2Application.cpp b/src/Platform/Sdl2Application.cpp index d5f9a1850..4040a356e 100644 --- a/src/Platform/Sdl2Application.cpp +++ b/src/Platform/Sdl2Application.cpp @@ -70,15 +70,14 @@ void Sdl2Application::createContext(Configuration* configuration) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); /* Multisampling */ - if(configuration->sampleCount()) { - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configuration->sampleCount()); - } - - window = SDL_CreateWindow(configuration->title().c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - configuration->size().x(), configuration->size().y(), SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); - if(!window) { - Error() << "Cannot create window."; + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configuration->sampleCount() > 1 ? 1 : 0); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configuration->sampleCount()); + + if(!(window = SDL_CreateWindow(configuration->title().c_str(), + SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + configuration->size().x(), configuration->size().y(), + SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN))) { + Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window"; std::exit(2); }