From 171a20cb6d63161da2d1f73099ac5476b25709a3 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Mon, 28 May 2018 18:40:29 -0500 Subject: [PATCH] Use some more compatible OpenGL version checking. --- shaders/shader_helpers.cpp | 8 ++++---- win32/COpenGL.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/shaders/shader_helpers.cpp b/shaders/shader_helpers.cpp index e329ea33..ca80df7f 100644 --- a/shaders/shader_helpers.cpp +++ b/shaders/shader_helpers.cpp @@ -35,14 +35,14 @@ bool gl_version_at_least (int maj, int min) if (major_version < 0 || minor_version < 0) { - glGetIntegerv (GL_MAJOR_VERSION, &major_version); - glGetIntegerv (GL_MINOR_VERSION, &minor_version); + const char *version_string = (const char *) glGetString (GL_VERSION); + sscanf (version_string, "%d.%d", &major_version, &minor_version); } - if (maj > major_version) + if (major_version > maj) return true; - if (maj == major_version && min >= minor_version) + if (maj == major_version && minor_version >= min) return true; return false; diff --git a/win32/COpenGL.cpp b/win32/COpenGL.cpp index ff71a9b3..91b45a60 100644 --- a/win32/COpenGL.cpp +++ b/win32/COpenGL.cpp @@ -953,12 +953,13 @@ bool COpenGL::ShaderAailable() bool COpenGL::NPOTAvailable() { const char *extensions = (const char *)glGetString(GL_EXTENSIONS); + const char *version = (const char *)glGetString(GL_VERSION); if (!extensions) return false; int glVersionMajor = 0; - glGetIntegerv(GL_MAJOR_VERSION, &glVersionMajor); + glVersionMajor = atoi (version); if (glVersionMajor >= 2) return true;