Reputation: 5255
I'm writing crossplatform library on C++ and OpenGL. I want to know how to detect whether I running on OpenGL Desktop, or ES?
Maybe sowehow with glGetString(GL_SHADING_LANGUAGE_VERSION)?
Upvotes: 2
Views: 1960
Reputation: 5255
Inside Shader:
According to http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf (page 12) there should be GL_ES define. If it is 0, or absent - you using dektop implementation, otherwise - ES.
In other places:
GL_ES_VERSION_2_0 defined here http://www.khronos.org/registry/gles/api/GLES2/gl2.h. So if it defined - we're on ES system.
Wikibooks recommend it, also:
http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_03
Upvotes: 2
Reputation: 43319
Parsing version strings to tell anything about an OpenGL implementation has always been taboo. They are for human eyes only, otherwise there would be a stricter set of rules governing how the string had to be formatted and compliance guarantees before a version number could be reported.
That said, the GLES specification is stricter than GL on this matter so it could be possible:
The
GL_VERSION
string is laid out as follows:"OpenGL ES N.M vendor-specific information"
In OpenGL a compliant implementation will format its GL_VERSION
string this way:
The
GL_VERSION
andGL_SHADING_LANGUAGE_VERSION
strings are laid out as follows:
<version number><space><vendor-specific information>
[...]
The version number is either of the form major number.minor number or major number.minor number.release number, where the numbers all have one or more digits.
What this means is that in a compliant OpenGL ES implementation the version string will begin with OpenGL ES
where as in OpenGL it will begin with a number (though I would not assume that "number" is limited to the characters [0-9] given the vague language used). You could theoretically use this information to distinguish between the two.
But you should not infer that because an implementation reports a certain version number that it actually implements the required feature set for compliance - this was a huge issue back in the days of OpenGL 2.0.
Upvotes: 3