Qt 3D

Qt 3D is a different take on OpenGL rendering—another one! It offers both QML and C++ APIs, and provides a high-level OpenGL API, but it uses a frame graph instead of QML's scene graph for rendering.

The difference is that in QML, there is a hard-coded renderer for the scene graph, which renders the scene in a predefined way, optimized for 2D rendering and using rather standard rendering methods. However, there is a steady stream of innovations and new approaches in 3D rendering, and Qt 3D trying to design a framework that is both more flexible and more extensible.

As a result, the frame graph doesn't specify what objects are to be rendered as the QML scene graph does. Rather, the position of a node in the frame graph tree will determine when and where the subtree contained in that node will be the active configuration in the rendering pipeline. This allows you, for example, to specify the normal forward rendering scheme or a deferred rendering (that is, using shaders as a post-processing step) by building different frame graphs.

The following QML example shows a doubly-rotating sphere using the classic Phong lighting:

Entity {
id: sceneRoot

Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
aspectRatio: 16/9
position: Qt.vector3d( 0.0, 0.0, -40.0 )
...
}
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
clearColor: Qt.rgba(1, 1, 1, 1)
camera: camera
}
}
]
PhongMaterial {
id: material
}
SphereMesh {
id: mesh
radius: 10
}
Transform {
id: transform
property real userAngle: 0.0
matrix: {
var m = Qt.matrix4x4();
m.rotate(userAngle, Qt.vector3d(0, 1, 0));
m.translate(Qt.vector3d(10, 0, 0));
return m;
}
}
NumberAnimation {
target: transform
property: "userAngle"
... // standard animation
}
Entity {
id: sphere
components: [ mesh, material, transform ]
}
}

We see that the framework lets us specify the rendering type for the activeFrameGraph (here the traditional forward rendering), various OpenGL 3D parameters (Camera, Transform), and offers implementation of some nontrivial features (PhongMaterial, SphereMesh). Another effect we'd be able to implement using Qt 3D is displaying the same content from a different point of view in separate windows, just like the deprecated QGraphicView was able to do. Thus, the design goals of being reconfigurable and extendable seem to be met.

In a more realistic application, you would probably create your meshes using a 3D modelling software and load it from file using the Mesh item. So, if you are implementing your own 3D content, you might consider using the Qt 3D module, but be aware that you'll have to learn a new framework and won't be quite able to leverage your knowledge of the OpenGL API. On the other hand, given that the new 3D graphics APIs that emerged recently can be integrated in that model, the Qt 3D module will probably gain more prominence in future Qt versions!