From 4daa1905130eaa65c44629a425f6af89a1576f76 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 20 Aug 2015 20:34:53 -0300 Subject: [PATCH] Show the detected OpenGL version in the popup dialog when GL2.1 or GLES2 isn't available when the window is created. --- src/modules/window/sdl/Window.cpp | 10 ++++++++-- src/modules/window/sdl/Window.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 032984f85..ba777fb8a 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -132,7 +132,7 @@ void Window::setGLContextAttributes(const ContextAttribs &attribs) SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, contextflags); } -bool Window::checkGLVersion(const ContextAttribs &attribs) +bool Window::checkGLVersion(const ContextAttribs &attribs, std::string &outversion) { typedef unsigned char GLubyte; typedef unsigned int GLenum; @@ -149,6 +149,8 @@ bool Window::checkGLVersion(const ContextAttribs &attribs) if (!glversion) return false; + outversion = glversion; + int glmajor = 0; int glminor = 0; @@ -229,6 +231,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla } std::string windowerror; + std::string glversion; // Try each context profile in order. for (ContextAttribs attribs : attribslist) @@ -320,7 +323,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla } // Make sure the context's version is at least what we requested. - if (context && !checkGLVersion(attribs)) + if (context && !checkGLVersion(attribs, glversion)) { SDL_GL_DeleteContext(context); context = nullptr; @@ -354,6 +357,9 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla std::string title = "Unable to initialize OpenGL"; std::string message = "This program requires a graphics card and video drivers which support OpenGL 2.1 or OpenGL ES 2."; + if (!glversion.empty()) + message += " \n(Detected OpenGL version: " + glversion + ")"; + std::cerr << title << std::endl << message << std::endl; // Display a message box with the error, but only once. diff --git a/src/modules/window/sdl/Window.h b/src/modules/window/sdl/Window.h index 29b340201..1f83d9634 100644 --- a/src/modules/window/sdl/Window.h +++ b/src/modules/window/sdl/Window.h @@ -118,7 +118,7 @@ private: void setGLFramebufferAttributes(int msaa, bool sRGB); void setGLContextAttributes(const ContextAttribs &attribs); - bool checkGLVersion(const ContextAttribs &attribs); + bool checkGLVersion(const ContextAttribs &attribs, std::string &outversion); 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.