Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

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

  1. #1
    Junior Member Newbie pixpaf's Avatar
    Join Date
    Nov 2012
    Posts
    3

    [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:

    Code :
     
     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.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    791
    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.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    791
    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?

  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  6. #6
    Junior Member Newbie pixpaf's Avatar
    Join Date
    Nov 2012
    Posts
    3
    Quote Originally Posted by Alfonse Reinheart View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •