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(QSurfaceFormat::CompatibilityProfile);
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) but without source code I can't see full picture to use the same technique.
How can I solve this problem?