Skip to content
Snippets Groups Projects
Commit 4236927a authored by Oliver Behnke's avatar Oliver Behnke
Browse files

Fix up initial window and OpenGL context instantiation (incl. fallback logic)

parent 6b630d24
No related branches found
No related tags found
1 merge request!1Move macOS build to 64 bit
......@@ -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
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;
return false;
SDL_DestroyWindow(m_Window);
}
}
}
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment