Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding supported GLSL version

Tags:

opengl

glsl

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.

like image 662
Dolda2000 Avatar asked Sep 26 '13 07:09

Dolda2000


People also ask

How do I check my GLSL version?

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.

What is GLSL support?

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.

What is GLSL written in?

GLSL. Shaders are written in the C-like language GLSL.


1 Answers

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
like image 178
datenwolf Avatar answered Nov 11 '22 09:11

datenwolf