From d8726f265e53ce6a1d5f11a1d261e2f8957f7c62 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 23 Feb 2018 16:46:55 +0000 Subject: Add epoxy_glsl_version() Epoxy should provide a function that returns the version of the GL shading language in use, in the same vein as it allows to get the version of GL. Closes: #145 --- src/dispatch_common.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dispatch_common.c b/src/dispatch_common.c index a2c9154..c9bd27f 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -392,9 +392,9 @@ epoxy_is_desktop_gl(void) } static int -epoxy_internal_gl_version(int error_version) +epoxy_internal_gl_version(const char *version_string, int error_version) { - const char *version = (const char *)glGetString(GL_VERSION); + const char *version = (const char *)glGetString(version_string); GLint major, minor; int scanf_count; @@ -433,7 +433,7 @@ epoxy_internal_gl_version(int error_version) int epoxy_gl_version(void) { - return epoxy_internal_gl_version(0); + return epoxy_internal_gl_version(GL_VERSION, 0); } int @@ -442,7 +442,32 @@ epoxy_conservative_gl_version(void) if (api.begin_count) return 100; - return epoxy_internal_gl_version(100); + return epoxy_internal_gl_version(GL_VERSION, 100); +} + +/** + * @brief Returns the version of the GL Shading Language we are using + * + * The version is encoded as: + * + * ``` + * + * version = major * 10 + minor + * + * ``` + * + * So it can be easily used for version comparisons. + * + * @return The encoded version of the GL Shading Language we are using + */ +int +epoxy_glsl_version(void) +{ + if (epoxy_gl_version() >= 20 || + epoxy_has_gl_extension ("GL_ARB_shading_language_100")) + return epoxy_internal_gl_version(GL_SHADING_LANGUAGE_VERSION, 0); + + return 0; } /** -- cgit v1.2.1