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
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    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 Lord
    Join Date
    Mar 2015
    Posts
    6,674
    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
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    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 Lord
    Join Date
    Mar 2015
    Posts
    6,674
    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.

Similar Threads

  1. GLSL version doesn't match OpenGL version
    By Susano2018 in forum OpenGL: Drivers
    Replies: 0
    Last Post: 11-13-2018, 06:35 PM
  2. picking a glsl version
    By shultays in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-12-2017, 03:48 PM
  3. glGetStringi how make it work?
    By ewerton in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 01-06-2013, 02:33 PM
  4. GLSL version 1.4 or greater
    By lobbel in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 08-16-2010, 04:58 AM
  5. GLSL Version 1.30 not available
    By McNopper in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-25-2008, 03:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean