diff --git a/src/framework/WindowManager.cpp b/src/framework/WindowManager.cpp index e300e572c90e8f3f00376e48422bc705e905d13a..b6b0736d3ecb788b30b8f9a4279b8d043c0d2d1b 100644 --- a/src/framework/WindowManager.cpp +++ b/src/framework/WindowManager.cpp @@ -123,7 +123,7 @@ bool WindowManager::initialize(const int width, const int height, const int fram m_CurrentWidth = m_WindowedWidth; m_CurrentHeight = m_WindowedHeight; - // finally, get window + // create window m_Window = SDL_CreateWindow( "Einstein@Home", SDL_WINDOWPOS_CENTERED, @@ -135,6 +135,13 @@ bool WindowManager::initialize(const int width, const int height, const int fram if (m_Window == NULL) { cerr << "Could not acquire rendering surface (" << SDL_GetError() << "): will try fallback..." << endl; } + else { + // create OpenGL context + m_GLContext = SDL_GL_CreateContext(m_Window); + if (m_GLContext == NULL) { + cerr << "Could not acquire OpenGL context (" << SDL_GetError() << "): will try fallback..." << endl; + } + } // check if we got acceleration int accelerated = 0; @@ -142,7 +149,8 @@ bool WindowManager::initialize(const int width, const int height, const int fram cerr << "Could not ensure accelerated rendering surface. Assuming no acceleration..." << endl; } - if (m_Window == NULL || !accelerated) { + // handle fallback + if (m_Window == NULL || m_GLContext == NULL || !accelerated) { cerr << "Disabling high quality features..." << endl; // disable features that demand acceleration @@ -153,6 +161,7 @@ bool WindowManager::initialize(const int width, const int height, const int fram // note, requires to extend starsphere's constructor (uses its own BOINCClientAdapter!) // reset window + if (m_Window) SDL_DestroyWindow(m_Window); m_Window = SDL_CreateWindow( "Einstein@Home", SDL_WINDOWPOS_CENTERED, @@ -165,13 +174,14 @@ bool WindowManager::initialize(const int width, const int height, const int fram cerr << "Could not acquire window (" << SDL_GetError() << "): giving up!" << endl; return false; } - } - - // finally create OpenGL context - m_GLContext = SDL_GL_CreateContext(m_Window); - if (m_GLContext == NULL) { - cerr << "Could not acquire OpenGL context (" << SDL_GetError() << "): giving up!" << endl; - return false; + else { + // create OpenGL context + m_GLContext = SDL_GL_CreateContext(m_Window); + if (m_GLContext == NULL) { + cerr << "Could not acquire OpenGL context (" << SDL_GetError() << "): giving up!" << endl; + SDL_DestroyWindow(m_Window); + } + } } return true;