9# include <QtGui/qopenglcontext.h>
11#include <QtQuick/qquickwindow.h>
13#include <QtCore/qloggingcategory.h>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
73static QSurfaceFormat findIdealGLVersion(
int samples)
76 int defaultSamples = fmt.samples();
77 const bool multisampling = samples > 1;
78 fmt.setProfile(QSurfaceFormat::CoreProfile);
82 fmt.setSamples(multisampling ? samples : defaultSamples);
85 if (ctx.create() && ctx.format().version() >= qMakePair(4, 3)) {
86 qCDebug(lcQuick3D,
"Requesting OpenGL 4.3 core context succeeded");
91 fmt.setSamples(defaultSamples);
93 if (ctx.create() && ctx.format().version() >= qMakePair(4, 3)) {
94 qCDebug(lcQuick3D,
"Requesting OpenGL 4.3 core context succeeded without multisampling");
100 fmt.setVersion(3, 3);
101 fmt.setSamples(multisampling ? samples : defaultSamples);
103 if (ctx.create() && ctx.format().version() >= qMakePair(3, 3)) {
104 qCDebug(lcQuick3D,
"Requesting OpenGL 3.3 core context succeeded");
109 fmt.setSamples(defaultSamples);
111 if (ctx.create() && ctx.format().version() >= qMakePair(3, 3)) {
112 qCDebug(lcQuick3D,
"Requesting OpenGL 3.3 core context succeeded without multisampling");
118 fmt.setVersion(3, 0);
120 fmt.setProfile(QSurfaceFormat::NoProfile);
121 fmt.setSamples(multisampling ? samples : defaultSamples);
123 if (ctx.create() && ctx.format().version() >= qMakePair(3, 0)) {
124 qCDebug(lcQuick3D,
"Requesting OpenGL 3.0 context succeeded");
128 fmt.setSamples(defaultSamples);
130 if (ctx.create() && ctx.format().version() >= qMakePair(3, 0)) {
131 qCDebug(lcQuick3D,
"Requesting OpenGL 3.0 context succeeded without multisampling");
136 qCWarning(lcQuick3D,
"Unable to find ideal GL version.");
140static QSurfaceFormat findIdealGLESVersion(
int samples)
143 int defaultSamples = fmt.samples();
144 const bool multisampling = samples > 1;
147 fmt.setVersion(3, 1);
148 fmt.setRenderableType(QSurfaceFormat::OpenGLES);
149 fmt.setSamples(multisampling ? samples : defaultSamples);
158 qCDebug(lcQuick3D,
"Testing OpenGL ES 3.1");
159 if (ctx.create() && ctx.format().version() >= qMakePair(3, 1)) {
160 qCDebug(lcQuick3D,
"Requesting OpenGL ES 3.1 context succeeded");
164 fmt.setSamples(defaultSamples);
166 if (ctx.create() && ctx.format().version() >= qMakePair(3, 1)) {
167 qCDebug(lcQuick3D,
"Requesting OpenGL ES 3.1 context succeeded without multisampling");
173 fmt.setVersion(3, 0);
174 fmt.setSamples(multisampling ? samples : defaultSamples);
176 qCDebug(lcQuick3D,
"Testing OpenGL ES 3.0");
177 if (ctx.create() && ctx.format().version() >= qMakePair(3, 0)) {
178 qCDebug(lcQuick3D,
"Requesting OpenGL ES 3.0 context succeeded");
182 fmt.setSamples(defaultSamples);
184 if (ctx.create() && ctx.format().version() >= qMakePair(3, 0)) {
185 qCDebug(lcQuick3D,
"Requesting OpenGL ES 3.0 context succeeded without multisampling");
192 qCWarning(lcQuick3D,
"OpenGL ES 3.0 / WebGL 2 is required on WebAssembly.");
194 fmt.setVersion(2, 0);
195 fmt.setSamples(multisampling ? samples : defaultSamples);
197 qCDebug(lcQuick3D,
"Testing OpenGL ES 2.0");
199 qCDebug(lcQuick3D,
"Requesting OpenGL ES 2.0 context succeeded");
203 fmt.setSamples(defaultSamples);
206 qCDebug(lcQuick3D,
"Requesting OpenGL ES 2.0 context succeeded without multisampling");
211 qCWarning(lcQuick3D,
"Unable to find ideal GLES version.");
216
217
218
219QSurfaceFormat QQuick3D::idealSurfaceFormat(
int samples)
221 if (QQuickWindow::graphicsApi() != QSGRendererInterface::OpenGLRhi) {
222 QSurfaceFormat fmt = QSurfaceFormat::defaultFormat();
223 fmt.setSamples(samples);
227 static const QSurfaceFormat f = [samples] {
229 if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
230 fmt = findIdealGLVersion(samples);
232 fmt = findIdealGLESVersion(samples);
234 fmt.setDepthBufferSize(24);
235 fmt.setStencilBufferSize(8);
242 QSurfaceFormat f = QSurfaceFormat::defaultFormat();
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)