This repo exists as an example of the Scene Graph interfering (flicking) with the Qt3D forward renderer.
The project is setup to build with CMake, i.e.
# Linux
cmake -DQt_VERSION_RELEASE=5 -DQt_VERSION_MAJOR=8 -DQt_VERSION_MINOR=0 -DQt_DIR=/opt/Qt5.8.0/5.8/gcc_64 ${SOURCE}
# Windows
cmake -DQt_VERSION_RELEASE=5 -DQt_VERSION_MAJOR=8 -DQt_VERSION_MINOR=0 -DQt_DIR=c:/opt/Qt5.8.0/5.8/msvc2013_64 %SOURCE%
Not all the Qt options above are required, the CMakeList does have defaults for them, but the explicit example above is good if you have a non-default installation.
Once CMake generates build files, the project should be able to build. The program will be output to ${BUILD_DIR}/app
.
The CMake files also included code to create an installer with the nullsoft scriptable install system (NSIS). Because the flicking issue only occurs on a Windows Surface, which in our case does not have a compiler, we run the installer and transfer it to the Surface.
The installer can be run in MSVC using the Install
and Package
targets.
Not relevant, but the Linux installer currently does not configure the rpath on
some of the build targets, so to run this example from an installed version in
Linux, the LD_LIBRARY_PATH
needs to be set.
The Qt3D renderer is implemented as:
- Off the root, a
Scene3d
is used, which instantiatesShipScene
ShipScene
creates aViewportFrameGraphs
and adds it as a componentViewportFrameGraphs
is modelled off the multi viewport example- The renderer calls
ClearBuffer
with a fully opaque colour
The scene graph, modelled after the Scene Graph - OpenGL Under QML example.
- In
main.qml
, aGround
object is created. This is just a wrapper toGroundModel
. GroundModel
, aQQuickItem
attaches to&QQuickWindow::afterRendering
which syncs its state toGroundRenderer
and callsGroundRenderer::paint
- In this example, the renderer does not clear before drawing.
Before setting up this example, I was connecting to
&QQuickWindow::beforeRendering
, calling clear in the scene graph, and
ClearBuffers with a transparent colour in ViewportFrameGraphs
. I felt that
this example though was simpler and displayed the same flickering issue.
Another weird eccentricity is that when the SceneGraph is simply initialized (not never drawn to), the QML displays the 3D model upsidedown. i.e. the Top camera shows the ship model from underneath, the back from the front, and the user camera from the bottom right instead of the top left. I haven't yet spent time debugging this though.