Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GlGetString(GL_VERSION) returns a wrong opengl version!
QtWS25 Last Chance

GlGetString(GL_VERSION) returns a wrong opengl version!

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manishsharma
    wrote on last edited by
    #1

    I have build Qt5 on my windows7 machine using below command. I have OpenGL 4.3 (Quadro K1000M/PCIe/SSE2 with 333 ext.)

    @configure -developer-build -opensource -nomake examples -nomake tests -mp -opengl desktop@

    And when i try to get the opengl version using below code, it returns 2.1.2.

    @char *ver = (char *) glGetString(GL_VERSION);@

    When i debugged a little inside with a non Qt application, there also it behaves the same.
    @
    int attribs[] = {
    WGL_CONTEXT_MAJOR_VERSION_ARB, 2,//the major version
    WGL_CONTEXT_MINOR_VERSION_ARB, 0,// the minor version
    0};

    m_hglrc = wglCreateContextAttribsARB(m_hdc, 0, attribs);
    wglMakeCurrent(m_hdc, m_hglrc);// sets the handle to the OpenGL rendering context
    @

    And later query for GL_VERSION it returns 2.1.2

    Then i read http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt

    bq. The default values for WGL_CONTEXT_MAJOR_VERSION_ARB and
    WGL_CONTEXT_MINOR_VERSION_ARB are 1 and 0 respectively. In this
    case, implementations will typically return the most recent version
    of OpenGL they support which is backwards compatible with OpenGL 1.0
    (e.g. 3.0, 3.1 + GL_ARB_compatibility, or 3.2 compatibility profile)

    If we go with this documentation then Qt4.8 works perfectly as there QGLFormat defaults to 1.0 and hence we get the latest opengl version, but in case of Qt5 we are passing 2.0 as the required version which makes driver to return an older version just above 2.0 (I am not quite sure about the logic here)

    Problem is that in our application we are doing some opengl rendering in QQuickWindow::beforeRendering() which requires at least opengl 3.0, but if we reply on glGetString we can not draw. What could be a best possible approach?

    I am planning have something like below, please let me know if this is a correct way of getting the latest opengl version set for my app?

    @
    QQuickView *view = new QQuickView();
    QSurfaceFormat format;
    format.setVersion(1, 0); // same as in Qt4.8.
    view->setFormat(format);
    @

    1 Reply Last reply
    0
    • M Offline
      M Offline
      manishsharma
      wrote on last edited by
      #2

      To keep this post short: What is the best way to get the latest opengl verison while using Qt5?

      I am trying to use it like below which is working. Please let me know if this is right?

      @
      QQuickView *view = new QQuickView();
      QSurfaceFormat format;
      format.setVersion(1, 0); // same as in Qt4.8.
      view->setFormat(format);
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved