From c9ce11a250c5f42926400c201b6ff4ebfca9f19f Mon Sep 17 00:00:00 2001 From: LRFLEW Date: Wed, 27 Jul 2016 16:26:33 -0500 Subject: [PATCH] Fix GetOpenGLVersion() This is in response to the research I did on #4047. The implementation currently in the code will not work based on what I saw. The `SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);` and `SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);` lines don't fetch the version retrieved, but the version requested. The solution I have here is the one I found worked consistently in my test case, and the one I suggested in [my comment](https://github.com/OpenRCT2/OpenRCT2/issues/4047#issuecomment-233268891). --- .../engines/opengl/OpenGLDrawingEngine.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 119729a808..bde79efaa4 100644 --- a/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -414,15 +414,13 @@ public: private: static OpenGLVersion GetOpenGLVersion() { - OpenGLVersion version; - if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &version.Major) == 0) - { - if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &version.Minor) == 0) - { - return version; - } - } - return { 0, 0 }; + CheckGLError(); // Clear Any Errors + OpenGLVersion version = { 0, 0 }; + glGetIntegerv(GL_MAJOR_VERSION, &version.Major); + if (glGetError() != GL_NO_ERROR) return { 0, 0 }; + glGetIntegerv(GL_MINOR_VERSION, &version.Minor); + if (glGetError() != GL_NO_ERROR) return { 0, 0 }; + return version; } void ConfigureBits(uint32 width, uint32 height, uint32 pitch)