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
macos/v1.5.9
Emmanuele Bassi 6 years ago
parent a7c3178f86
commit d8726f265e
  1. 1
      include/epoxy/gl.h
  2. 33
      src/dispatch_common.c

@ -91,6 +91,7 @@ EPOXY_BEGIN_DECLS
EPOXY_PUBLIC bool epoxy_has_gl_extension(const char *extension);
EPOXY_PUBLIC bool epoxy_is_desktop_gl(void);
EPOXY_PUBLIC int epoxy_gl_version(void);
EPOXY_PUBLIC int epoxy_glsl_version(void);
/*
* the type of the stub function that the failure handler must return;

@ -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;
}
/**

Loading…
Cancel
Save