From f92c10f969a02e707a236cb364332bf079cdf4fc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 25 Nov 2013 17:22:12 +0200 Subject: [PATCH] Add function to check GLSL version --- source/extension.cpp | 12 ++++++++++++ source/extension.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/source/extension.cpp b/source/extension.cpp index 41b06b21..d0361665 100644 --- a/source/extension.cpp +++ b/source/extension.cpp @@ -103,6 +103,18 @@ const Version &get_gl_version() return version; } +inline Version _get_glsl_version() +{ + string glsl_ver = reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)); + return Version(glsl_ver.substr(0, glsl_ver.find(' '))); +} + +const Version &get_glsl_version() +{ + static Version version = _get_glsl_version(); + return version; +} + bool is_version_at_least(unsigned a, unsigned b) { return get_gl_version()>=Version(a, b); diff --git a/source/extension.h b/source/extension.h index df6bd78d..e0fe3eff 100644 --- a/source/extension.h +++ b/source/extension.h @@ -59,6 +59,9 @@ bool is_supported(const std::string &); /** Returns the OpenGL version number, as reported by the implementation. */ const Version &get_gl_version(); +/** Returns the GLSL version number, as reported by the implementation. */ +const Version &get_glsl_version(); + /** Indicates whether the OpenGL version is at least a.b. */ bool is_version_at_least(unsigned a, unsigned b); -- 2.45.2