Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[solved] Select an OpenGL 4 context on Mac OSX Maverick



  • Hi all,

    since some weeks I have troubles to select an OpenGL 4 context on Mac OSX 10.9 with QT when porting a cross plattform application. The format is set in the constructor of the main Window as shown in the following source:

    @QGLFormat glFormat;
    glFormat.setProfile( QGLFormat::CoreProfile );
    glFormat.setVersion( 4, 1 );

    QGLFormat::setDefaultFormat(glFormat);
    glWidget = new GLWidget(_pathToEarthFile,glFormat);

    QGLContext* glContext = (QGLContext *) glWidget->context();
    glContext->makeCurrent();
    this->setCentralWidget(glWidget);@

    Later on, I do the version output the following:

    @std::cout << "Widget OpenGl: " << glContext->format().majorVersion() << "." << glContext->format().minorVersion() << std::endl;
    std::cout << "Context valid: " << glContext->isValid() << std::endl;
    std::cout << "Really used OpenGl: " << glContext->format().majorVersion() << "." << glContext->format().minorVersion() << std::endl;
    std::cout << "OpenGl information: " << std::endl;
    std::cout << "VENDOR: " << (const char*)glGetString(GL_VENDOR) << std::endl;
    std::cout << "RENDERDER: " << (const char*)glGetString(GL_RENDERER) << std::endl;
    std::cout << "VERSION: " << (const char*)glGetString(GL_VERSION) << std::endl;
    std::cout << "GLSL VERSION: " << (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;

    qDebug() << "OpenGLVersionFlags(): " << QGLFormat::OpenGLVersionFlags();

    if((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_3_2) == 0)
    {
    std::cout << "GL 3.2 Not supported" << std::endl;
    }@

    and I get the following output:

    @Widget OpenGl: 1.0
    Context valid: 1
    Really used OpenGl: 1.0
    OpenGl information:
    VENDOR: ATI Technologies Inc.
    RENDERDER: ATI Radeon HD 5770 OpenGL Engine
    VERSION: 2.1 ATI-1.14.21
    GLSL VERSION: 1.20
    OpenGLVersionFlags(): QFlags()
    GL 3.2 Not supported @

    What I know:

    • My mac and the graphics card support 4.1, because the OpenGL Extension Viewer shows the 4.1. core profile.
    • It does not depend what version I use in glFormat.setVersion, the output is always 1.0 for the qt context.
    • sourcecode compiles with OpenGL 4.1 calls, which means, that the right OpenGL Framework is available while compilation (I included the OpenGL.framework in Xcode 5.01).
    • shaders do not compile with version 410 or something else higher than 120.

    Before christmas I tracked this down to the fact, that there was a wrong header included and that there is a fix in QT 5.2 beta. From then on I used the QT 5.2 build.

    Has anyone experienced the same issues or did anyone got a similar example running without objective-c and without using another windowing system? I also thought, that it must be possible to reset the GL_VERSION in OpenGL anyhow, but this depends on the windowing system, doesn't it?

    Cheers and thanks for the support!



  • Hi all,

    this is solved. Did not find the valid QT 5.2. packages in cmake, but it is working now.

    cheers


Log in to reply