0

I am trying to render a Qt Quick 3D scene to an image buffer without any window at all (ideally, this has to run on a headless server).

I found that class QQuickRenderControl is designed for this purpose (accelerated rendering, no window), and the example quick/rendercontrol is an example of using it.

The example renders the Qt Quick Scene Graph contained in demo.qml (a Qt Quick scene with text and particles) onto a texture, and applies the texture on a rotating cube in OpenGL.

When I change demo.qml to use Qt Quick 3D:

import QtQuick
import QtQuick3D

View3D {
    id: view
    anchors.fill: parent

    PerspectiveCamera {
        position: Qt.vector3d(0, 200, 300)
        eulerRotation.x: -30
    }

    DirectionalLight {
        eulerRotation.x: -30
    }

    Model {
        id: cube
        source: "#Cube"
        materials: DefaultMaterial {
            diffuseColor: Qt.rgba(1, 0, 0, 1)
        }
        eulerRotation.y: 90

        Vector3dAnimation on eulerRotation {
            loops: Animation.Infinite
            duration: 5000
            from: Qt.vector3d(0, 0, 0)
            to: Qt.vector3d(360, 0, 360)
        }
    }
}

the texture onto which the 3D scene should be rendered is white and the following error is printed:

No GLSL shader code found (versions tried: QList(120) ) in baked shader QShader(stage=0 shaders=QList(ShaderKey(0 Version(100 QFlags()) 0), ShaderKey(1 Version(100 QFlags(0x1)) 0), ShaderKey(1 Version(130 QFlags()) 0), ShaderKey(1 Version(140 QFlags()) 0), ShaderKey(1 Version(300 QFlags(0x1)) 0), ShaderKey(1 Version(330 QFlags()) 0), ShaderKey(2 Version(50 QFlags()) 0), ShaderKey(4 Version(12 QFlags()) 0)) desc.isValid=true)

How to render a Qt Quick 3D scene to texture in an efficient way (i.e. not via QQuickWindow::grabWindow()) and without windows (e.g. using QQuickRenderControl)?

fferri
  • 18,285
  • 5
  • 46
  • 95

0 Answers0