[OpenGL 3.2] How to get GLSL version with glGetStringi ?

Hello,

I find annoying to extract version of GLSL with glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);

So i dig more in the documentation, and found glGestStringi, which makes it easier to extract parts of strings.

I’d thought of doing something like this:



 int major = atoi( (const char *) glGetStringi(GL_SHADING_LANGUAGE_VERSION_ARB, 0) );
 int minor = atoi( (const char *) glGetStringi(GL_SHADING_LANGUAGE_VERSION_ARB, 1) );


But it doesn’t work.
GlGetError returns invalid enumerant .

So, what could i use for indexing ? I’m sure i’ve missed a thing in the documentation, but couldn’t find the place where the indexes are listed.

Thank you.

Only GL_EXTENSIONS is supported with glGetStringi (see glGetString). It is not meant to give you arbitrary parts of strings, but rather for those strings that contain many values (i.e. all supported extensions) to allow you to pick just one. You’ll have to do the parsing of the GLSL version by hand.

Only GL_EXTENSIONS is supported with glGetStringi (see glGetString).

Technically, that’s not true in GL 4.3. There was a (pure-core) addition that allows you to query GL_NUM_SHADING_LANGUAGE_VERSIONS (the number of supported versions) with glGetIntegerv, and then enumerate those versions with glGetStringi.

Ah, thanks for the info. I had only looked at the 3.x man pages and it seems the 4.x man page for glGetString is not updated with this information yet. Anyway, I guess you’d still get complete GLSL version numbers (like “4.3”) not individual major/minor numbers (like “4”, “3”) though, right?

Yes. But really, is parsing around a . that big of an issue? It can’t possibly take you much longer than a couple of minutes to write a function to do that.

Yes of course, parsing numbers with a dot separator is not a big deal.

Indeed, i had read too fast the spec:

<version number><space><vendor-specific information>

and i falsely believed that there were a space between each elements.
That’s why i didn’t understood when i saw a dot instead of the awaited space.

The only minor difficulty is that we can have two forms of answer, for the version number:
minor.major or minor.major.release

thanks for answering.