summaryrefslogtreecommitdiff
path: root/src/dispatch_common.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2018-02-23 16:46:55 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2018-02-23 19:58:36 +0000
commitd8726f265e53ce6a1d5f11a1d261e2f8957f7c62 (patch)
tree40b8d0257253568f92f6b83836e583f40a09b3e2 /src/dispatch_common.c
parenta7c3178f86afa016ddeed8ebbb668ec308b71122 (diff)
downloadlibepoxy-d8726f265e53ce6a1d5f11a1d261e2f8957f7c62.tar.gz
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
Diffstat (limited to 'src/dispatch_common.c')
-rw-r--r--src/dispatch_common.c33
1 files changed, 29 insertions, 4 deletions
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;
}
/**