Search code examples
qtqmlqt-quickqt3d

Qt Quick 3D error: QSSG.internal_error: Can't find a suitable OpenGL version for QSurfaceFormat(version 2.1


Tried a simple Qt Quick 3D example (macOS, Qt 5.15.0) but get this error:

QSSG.internal_error: Can't find a suitable OpenGL version for QSurfaceFormat(version 2.1, options QFlagsQSurfaceFormat::FormatOption(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile QSurfaceFormat::NoProfile)

QML code:

import QtQuick 2.15
import QtQuick.Window 2.12
import QtQuick3D 1.15

Window {
    visible: true
    width: 640
    height: 480

    View3D {
        id: view
        anchors.fill: parent

        environment: SceneEnvironment {
            clearColor: "skyblue"
            backgroundMode: SceneEnvironment.Color
        }

        Node {
            id: scene

            DirectionalLight {
                eulerRotation.x: -30
                eulerRotation.y: -70
            }

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

            Model {
                id: cubeModel
                source: "#Cube" // #Cone, #Sphere, #Cylinder, #Rectangle

                materials: [
                    DefaultMaterial {
                        id: cubeMaterial
                        diffuseColor: "red"
                    }
                ]
            }
        }
    }
}

Solution

  • Turns out the main.cpp of the 'Qt Quick application (empty)' template of Qt Creator is missing this line:

    QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
    

    after the creation of the QGuiApplication object.