Qt Quick 3D error: QSSG.internal_error: Can't find a suitable OpenGL version for QSurfaceFormat(version 2.1
Qt Quick 3D error: QSSG.internal_error: Can't find a suitable OpenGL version for QSurfaceFormat(version 2.1
尝试了一个简单的 Qt Quick 3D 示例(macOS,Qt 5.15.0)但出现此错误:
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代码:
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"
}
]
}
}
}
}
原来Qt Creator的'Qt Quick application (empty)'模板的main.cpp缺少这个行:
QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
创建 QGuiApplication
对象后。
尝试了一个简单的 Qt Quick 3D 示例(macOS,Qt 5.15.0)但出现此错误:
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代码:
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"
}
]
}
}
}
}
原来Qt Creator的'Qt Quick application (empty)'模板的main.cpp缺少这个行:
QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
创建 QGuiApplication
对象后。