Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Getting OpenGL context > 2.1 on Mac OS X 10.10 (Yosemite)

    QML and Qt Quick
    2
    3
    3727
    Loading More Posts
    • 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.
    • J
      Jeanjean last edited by

      Hi.
      I have been trying to port my c++/qml/openGL project from linux to mac OS X 10.10 for several hours without any luck (it worked perfectly under linux). I'm using Qt 5.3.2. All of my shaders are rejected at compilation because they're made for a GLSL version greater than 3.0 (core profile). So, for debugging purpose, I took the basic "OpenGL under QML":http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html tutorial and tried it on my macbook to see if it works out of the box. Well, kind of : the very simple example scene works flawlessly but it is because it doesn't need more than a 2.1 openGL context.
      If I print out the current QOpenGLContext format I can see the current version is still 2.1. (I'm just using the example code without any modification)
      I tried declaring a new format:
      @
      QSurfaceFormat f(QOpenGLContext::currentContext()->format());
      f.setProfile(QSurfaceFormat::CoreProfile);
      f.setVersion(3,2); // I tried 3.0, 3.2, 3.3, 4.0, 4.3
      @

      and then

      @QOpenGLContext::currentContext()->setFormat(f)@

      No luck. Still 2.1 context.
      I then tried replacing the currentContext with a new one in the renderer (I store the QQuickWindow::window()):

      @
      QOpenGLContext * ctx = new QOpenGLContext;
      ctx->setFormat(f);
      ctx->makeCurrent(win);
      @

      Still 2.1 context with no profile, and if I print out the result of makeCurrent(), I get a beautiful "0", meaning it failed.
      So, this is where I am right now... any idea on what's actually going on?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        This "article":http://www.kdab.com/opengl-in-qt-5-1-part-1/ and the follows up might be of interest.

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • J
          Jeanjean last edited by

          Thank you for your reply (I had already read this article, very useful even if not exactly my case as I think this problem might be qtQuick/OSX specific).

          Ok so I managed to switch context (I forgot the
          @ctx->create()@

          ). Now if I print out the QOpenGLContext just after switching with my new one (I create it in the renderer's constructor) I have a core profile in its 4.1 version. Nice.

          But if I look at it when I'm in paint(), it's a 2.1 context again and I can't create FBOs. I thus tried to put my context switching code on top of paint() (very dirty, just a cheap temporary testing solution)... but my fbos still won't work ("missing attachment"), the display is all buggy and everything is very slow.

          Furthermore, I had to change all of my shaders because all of the keywords I used ("varying", "attribute", ...) were not recognized (I had to switch to a pure Core profile glsl). When building on Linux or Android with the exact same code (well, not with this context switch I'm adding now), everything worked perfectly.

          Is it me doing bad things here or is QOpenGLContext and/or openGL with QML under mac OS X broken ?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post