How would one best do to find the version of GLSL that an OpenGL implementation supports, in a way that can be reliably used programmatically?
Is the best way to get the GL_SHADING_LANGUAGE_VERSION
string and try to parse it? Can it be relied upon to be returned in a well-defined format? My Intel driver returns 1.20
which is simple enough to parse, but my nVidia card returns 4.20 NVIDIA via Cg compiler
. Can it be trusted to be matched by the (\d+)\.(\d+)( .*)?
regex? This answer seems to indicate otherwise, returning OpenGL ES GLSL ES 1.0
.
Is any of this correct, and/or is there some other way? Specifically, I want to check so that at least GLSL 1.20 is supported.
At opengl.org/registry you can download the specifications of each OpenGL standard and associated specification standards (like GLSL) and each standard defines which version of OpenGL it has been written against.
GLSL supports function overloading (for both built-in functions and operators, and user-defined functions), so there might be multiple function definitions with the same name, having different number of parameters or parameter types. Each of them can have own independent return type.
GLSL. Shaders are written in the C-like language GLSL.
There's a specific mapping between OpenGL version and supported GLSL version:
GLSL Version OpenGL Version
1.10 2.0
1.20 2.1
1.30 3.0
1.40 3.1
1.50 3.2
3.30 3.3
4.00 4.0
4.10 4.1
4.20 4.2
4.30 4.3
4.40 4.4
4.50 4.5
There's a well defined API for querying the OpenGL version. Use the table above for mapping to GLSL versions (after OpenGL-3.3 it's very logical).
Furthermore the specification defines the format of the GL_VERSION and GL_SHADING_LANGUAGE_VERSION to
begin with a version number. The version number uses one of these forms:
major_number.minor_number | major_number.minor_number.release_number
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With