Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Quick 2 with OpenGL > 2.0
Forum Updated to NodeBB v4.3 + New Features

Qt Quick 2 with OpenGL > 2.0

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 1.3k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    LORDIF
    wrote on last edited by
    #1

    Good afternoon everybody. I faced with a problem which I can't solve myself.

    I want to use Qt Quick 2.x for my program but I can't make it work with OpenGL > 2.0

    I have main.qml:

    @ /* imports */
    Window {
    ...
    Scene {
    ...
    }
    ...
    }@

    In Scene I'm using OpenGL > 2.0 so my shaders aren't working.

    I've tried to add this line qobject_cast<QQuickWindow*>(engine.rootObjects().first())->setFormat(format_3_3); in main.cpp but that didn't help.

    @int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QSurfaceFormat format_3_3;
        format_3_3.setMajorVersion(3);
        format_3_3.setMinorVersion(3);
        format_3_3.setProfile&#40;QSurfaceFormat::CompatibilityProfile&#41;;
    
        qmlRegisterType<Scene>("SceneGL", 1, 0, "Scene");
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        qobject_cast<QQuickWindow*>(engine.rootObjects().first())->setFormat(format_3_3);
    
        return app.exec();
    }@
    

    My Scene class:

    @class Scene : public QQuickItem
    {
        ...
    }@
    

    I found a solution "here (47 minute)":http://www.youtube.com/watch?v=GYa5DLV6ADQ: but without source code I can't see full picture to use the same technique.

    How can I solve this problem? Thanks for your answers.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Are you running this on Windows with ANGLE, by any chance?

      (Z(:^

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LORDIF
        wrote on last edited by
        #3

        Nope, MAC OS X 10.10

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Torgeir
          wrote on last edited by
          #4

          A QWindow's surface format must be set before the window is created. In Qt version including 5.3.2 you'll need to create the Window from the C++ side by using a QQuickView.

          In Qt 5.4 you can call QSurfaceFormat::setDefaultFormat to set a default format that the QtQuick Window element also will use.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            LORDIF
            wrote on last edited by
            #5

            Thanks, that helped but now I faced with another problem: "problem":http://qt-project.org/forums/viewthread/49501/

            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