GlGetString(GL_VERSION) returns a wrong opengl version!



  • 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);
    @



  • 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);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.