6#include <QtGui/QOpenGLContext>
7#include <QtGui/QOffscreenSurface>
8#include <QtGui/QOpenGLFunctions>
9#include <QtGui/QWindow>
10#include <QtGui/QGuiApplication>
11#include <QtGui/QScreen>
12#include <QtGui/qpa/qplatformwindow.h>
13#include <QtGui/qpa/qplatformintegration.h>
14#include <QtOpenGL/QOpenGLFramebufferObject>
15#include <QtOpenGL/QOpenGLPaintDevice>
17#include <QtGui/private/qguiapplication_p.h>
18#include <QtGui/private/qopenglextensions_p.h>
19#include <QtGui/private/qfont_p.h>
20#include <QtGui/private/qopenglcontext_p.h>
21#include <QtOpenGL/private/qopenglframebufferobject_p.h>
22#include <QtOpenGL/private/qopenglpaintdevice_p.h>
24#include <QtWidgets/private/qwidget_p.h>
25#include <QtWidgets/private/qwidgetrepaintmanager_p.h>
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
452
453
454
455
456
459
460
461
462
463
464
467
468
469
470
471
474
475
476
477
478
481
482
483
484
485
486
487
488
489
490
491
492
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
540 Q_DECLARE_PUBLIC(QOpenGLWidget)
608 if (w->autoFillBackground()) {
609 QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
610 if (w->testAttribute(Qt::WA_TranslucentBackground)) {
611 f->glClearColor(0, 0, 0, 0);
613 QColor c = w->palette().brush(w->backgroundRole()).color();
614 float alpha = c.alphaF();
615 f->glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
617 f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
628 QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = 0;
640 if (QOpenGLContext::currentContext() != wd->context)
643 wd->fbos[wd->currentTargetBuffer]->bind();
647 QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = wd->fbos[wd->currentTargetBuffer]->handle();
657 return { wrapperTextures[QOpenGLWidget::LeftBuffer], wrapperTextures[QOpenGLWidget::RightBuffer] };
661#define GL_SRGB 0x8C40
664#define GL_SRGB8 0x8C41
667#define GL_SRGB_ALPHA 0x8C42
669#ifndef GL_SRGB8_ALPHA8
670#define GL_SRGB8_ALPHA8 0x8C43
675 QPlatformTextureList::Flags flags = QWidgetPrivate::textureListFlags();
676 switch (textureFormat) {
681 flags |= QPlatformTextureList::TextureIsSrgb;
698 paintDevice =
nullptr;
734 emit q->aboutToResize();
736 context->makeCurrent(surface);
741 QOpenGLExtensions *extfuncs =
static_cast<QOpenGLExtensions *>(context->functions());
742 if (!extfuncs->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample))
745 QOpenGLFramebufferObjectFormat format;
746 format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
747 format.setSamples(samples);
749 format.setInternalTextureFormat(textureFormat);
751 const QSize deviceSize = q->size() * q->devicePixelRatio();
752 fbos[QOpenGLWidget::LeftBuffer] =
new QOpenGLFramebufferObject(deviceSize, format);
754 resolvedFbos[QOpenGLWidget::LeftBuffer] =
new QOpenGLFramebufferObject(deviceSize);
759 fbos[QOpenGLWidget::RightBuffer] =
new QOpenGLFramebufferObject(deviceSize, format);
761 resolvedFbos[QOpenGLWidget::RightBuffer] =
new QOpenGLFramebufferObject(deviceSize);
764 textureFormat = fbos[QOpenGLWidget::LeftBuffer]->format().internalTextureFormat();
766 currentTargetBuffer = QOpenGLWidget::LeftBuffer;
767 fbos[currentTargetBuffer]->bind();
768 context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
772 currentTargetBuffer = QOpenGLWidget::RightBuffer;
773 fbos[currentTargetBuffer]->bind();
774 context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
776 currentTargetBuffer = QOpenGLWidget::LeftBuffer;
781 paintDevice->setSize(deviceSize);
782 paintDevice->setDevicePixelRatio(q->devicePixelRatio());
791 QRhi *rhi = QWidgetPrivate::rhi();
794 if (rhi && rhi->backend() == QRhi::OpenGLES2) {
795 const QSize deviceSize = q->size() * q->devicePixelRatio();
796 if (!wrapperTextures[currentTargetBuffer] || wrapperTextures[currentTargetBuffer]->pixelSize() != deviceSize) {
797 const uint textureId = resolvedFbos[currentTargetBuffer] ?
798 resolvedFbos[currentTargetBuffer]->texture()
799 : (fbos[currentTargetBuffer] ? fbos[currentTargetBuffer]->texture() : 0);
800 if (!wrapperTextures[currentTargetBuffer])
801 wrapperTextures[currentTargetBuffer] = rhi->newTexture(QRhiTexture::RGBA8, deviceSize, 1, QRhiTexture::RenderTarget);
803 wrapperTextures[currentTargetBuffer]->setPixelSize(deviceSize);
804 if (!wrapperTextures[currentTargetBuffer]->createFrom({textureId, 0 }))
805 qWarning(
"QOpenGLWidget: Failed to create wrapper texture");
816 static_cast<QOpenGLExtensions *>(context->functions())->flushShared();
819 emit q->aboutToCompose();
825 emit q->frameSwapped();
836 QWidget *tlw = q->window();
842 requestedSamples = requestedFormat.samples();
843 requestedFormat.setSamples(0);
845 QRhi *rhi = QWidgetPrivate::rhi();
849 if (rhi && rhi->backend() != QRhi::OpenGLES2) {
850 qWarning(
"The top-level window is not using OpenGL for composition, '%s' is not compatible with QOpenGLWidget",
858 QOpenGLContext *contextFromRhi = rhi ?
static_cast<
const QRhiGles2NativeHandles *>(rhi->nativeHandles())->context :
nullptr;
860 context =
new QOpenGLContext;
861 context->setFormat(requestedFormat);
863 QOpenGLContext *shareContext = contextFromRhi ? contextFromRhi : QOpenGLContext::globalShareContext();
865 context->setShareContext(shareContext);
866 context->setScreen(shareContext->screen());
868 if (Q_UNLIKELY(!context->create())) {
869 qWarning(
"QOpenGLWidget: Failed to create context");
873 surface =
new QOffscreenSurface;
874 surface->setFormat(context->format());
875 surface->setScreen(context->screen());
878 if (Q_UNLIKELY(!context->makeCurrent(surface))) {
879 qWarning(
"QOpenGLWidget: Failed to make context current");
886 if (tlw->windowHandle()) {
887 QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
888 if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
891 tlwFormat.setSwapInterval(requestedFormat.swapInterval());
892 tlw->windowHandle()->setFormat(tlwFormat);
894 if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
895 tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
896 tlw->windowHandle()->setFormat(tlwFormat);
900 paintDevice =
new QOpenGLWidgetPaintDevice(q);
901 paintDevice->setSize(q->size() * q->devicePixelRatio());
902 paintDevice->setDevicePixelRatio(q->devicePixelRatio());
911 resolveSamplesForBuffer(QOpenGLWidget::LeftBuffer);
912 resolveSamplesForBuffer(QOpenGLWidget::RightBuffer);
918 if (resolvedFbos[targetBuffer]) {
919 q->makeCurrent(targetBuffer);
920 QRect rect(QPoint(0, 0), fbos[targetBuffer]->size());
921 QOpenGLFramebufferObject::blitFramebuffer(resolvedFbos[targetBuffer], rect, fbos[targetBuffer], rect);
933 setCurrentTargetBuffer(QOpenGLWidget::LeftBuffer);
935 QOpenGLContext *ctx = QOpenGLContext::currentContext();
937 qWarning(
"QOpenGLWidget: No current context, cannot render");
941 if (!fbos[QOpenGLWidget::LeftBuffer]) {
942 qWarning(
"QOpenGLWidget: No fbo, cannot render");
948 static bool warningGiven =
false;
949 if (!fbos[QOpenGLWidget::RightBuffer] && !warningGiven) {
950 qWarning(
"QOpenGLWidget: Stereo is enabled, but no right buffer. Using only left buffer");
955 if (updateBehavior == QOpenGLWidget::NoPartialUpdate && hasBeenComposed) {
958 if (stereo && fbos[QOpenGLWidget::RightBuffer]) {
959 setCurrentTargetBuffer(QOpenGLWidget::RightBuffer);
961 setCurrentTargetBuffer(QOpenGLWidget::LeftBuffer);
967 QOpenGLFunctions *f = ctx->functions();
968 f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio());
972 f->glDepthMask(GL_TRUE);
975 QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbos[currentTargetBuffer]->handle();
978 f->glBindBuffer(GL_ARRAY_BUFFER, 0);
979 f->glEnable(GL_BLEND);
982 if (updateBehavior == QOpenGLWidget::NoPartialUpdate)
985 if (stereo && fbos[QOpenGLWidget::RightBuffer]) {
986 setCurrentTargetBuffer(QOpenGLWidget::RightBuffer);
987 QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbos[currentTargetBuffer]->handle();
989 if (updateBehavior == QOpenGLWidget::NoPartialUpdate)
992 QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0;
1000 QOpenGLExtensions *f =
static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions());
1001 if (f->hasOpenGLExtension(QOpenGLExtensions::DiscardFramebuffer)) {
1002 const GLenum attachments[] = {
1003 gl_color_attachment0,
1004 gl_depth_attachment,
1005 gl_stencil_attachment,
1009 gl_depth_stencil_attachment
1012 f->discardFramebuffer(GL_FRAMEBUFFER, GLsizei(
std::size(attachments)), attachments);
1014 f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1020 QOpenGLExtensions *f =
static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions());
1021 if (f->hasOpenGLExtension(QOpenGLExtensions::DiscardFramebuffer)) {
1022 const GLenum attachments[] = {
1023 gl_depth_attachment,
1024 gl_stencil_attachment,
1028 gl_depth_stencil_attachment
1031 f->discardFramebuffer(GL_FRAMEBUFFER, GLsizei(
std::size(attachments)), attachments);
1037 delete fbos[QOpenGLWidget::LeftBuffer];
1038 fbos[QOpenGLWidget::LeftBuffer] =
nullptr;
1039 delete resolvedFbos[QOpenGLWidget::LeftBuffer];
1040 resolvedFbos[QOpenGLWidget::LeftBuffer] =
nullptr;
1042 delete fbos[QOpenGLWidget::RightBuffer];
1043 fbos[QOpenGLWidget::RightBuffer] =
nullptr;
1044 delete resolvedFbos[QOpenGLWidget::RightBuffer];
1045 resolvedFbos[QOpenGLWidget::RightBuffer] =
nullptr;
1052 return grabFramebuffer(QOpenGLWidget::LeftBuffer);
1065 if (targetBuffer == QOpenGLWidget::RightBuffer && !isStereoEnabled())
1066 targetBuffer = QOpenGLWidget::LeftBuffer;
1068 if (!fbos[targetBuffer])
1071 if (!inPaintGL && !paintDevice->paintingActive()) {
1077 const bool wasInBackingStorePaint = std::exchange(inBackingStorePaint,
false);
1078 const bool wasInPaintEvent = q->testAttribute(Qt::WA_WState_InPaintEvent);
1079 q->setAttribute(Qt::WA_WState_InPaintEvent);
1080 QPaintEvent e(q->rect());
1081 QCoreApplication::sendEvent(q, &e);
1082 q->setAttribute(Qt::WA_WState_InPaintEvent, wasInPaintEvent);
1089 setCurrentTargetBuffer(targetBuffer);
1090 if (resolvedFbos[targetBuffer]) {
1091 resolveSamplesForBuffer(targetBuffer);
1092 resolvedFbos[targetBuffer]->bind();
1095 const bool hasAlpha = q->format().hasAlpha();
1096 QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatio(), hasAlpha, hasAlpha);
1097 res.setDevicePixelRatio(q->devicePixelRatio());
1102 if (resolvedFbos[targetBuffer]) {
1103 setCurrentTargetBuffer(targetBuffer);
1114 q->setAutoFillBackground(
true);
1124 return q->format().stereo();
1129 return setCurrentTargetBuffer(currentTargetBuffer == QOpenGLWidget::LeftBuffer ?
1130 QOpenGLWidget::RightBuffer :
1131 QOpenGLWidget::LeftBuffer);
1140 if (!fbos[currentTargetBuffer] || q->size() * q->devicePixelRatio() != fbos[currentTargetBuffer]->size()) {
1147
1148
1149QOpenGLWidget::QOpenGLWidget(QWidget *parent, Qt::WindowFlags f)
1150 : QWidget(*(
new QOpenGLWidgetPrivate), parent, f)
1153 if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RhiBasedRendering)
1154 || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)))
1155 qWarning(
"QOpenGLWidget is not supported on this platform.");
1157 d->setRenderToTexture();
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177QOpenGLWidget::~QOpenGLWidget()
1190
1191
1192
1193void QOpenGLWidget::setUpdateBehavior(UpdateBehavior updateBehavior)
1196 d->updateBehavior = updateBehavior;
1200
1201
1202
1203QOpenGLWidget::UpdateBehavior QOpenGLWidget::updateBehavior()
const
1205 Q_D(
const QOpenGLWidget);
1206 return d->updateBehavior;
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226void QOpenGLWidget::setFormat(
const QSurfaceFormat &format)
1229 if (Q_UNLIKELY(d->initialized)) {
1230 qWarning(
"QOpenGLWidget: Already initialized, setting the format has no effect");
1234 d->requestedFormat = format;
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253QSurfaceFormat QOpenGLWidget::format()
const
1255 Q_D(
const QOpenGLWidget);
1256 return d->initialized ? d->context->format() : d->requestedFormat;
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275void QOpenGLWidget::setTextureFormat(GLenum texFormat)
1278 if (Q_UNLIKELY(d->initialized)) {
1279 qWarning(
"QOpenGLWidget: Already initialized, setting the internal texture format has no effect");
1283 d->textureFormat = texFormat;
1287
1288
1289
1290
1291
1292
1293
1294GLenum QOpenGLWidget::textureFormat()
const
1296 Q_D(
const QOpenGLWidget);
1297 return d->textureFormat;
1301
1302
1303
1304
1305bool QOpenGLWidget::isValid()
const
1307 Q_D(
const QOpenGLWidget);
1308 return d->initialized && d->context->isValid();
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321void QOpenGLWidget::makeCurrent()
1324 if (!d->initialized)
1327 d->context->makeCurrent(d->surface);
1329 if (d->fbos[d->currentTargetBuffer])
1330 d->fbos[d->currentTargetBuffer]->bind();
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348void QOpenGLWidget::makeCurrent(TargetBuffer targetBuffer)
1351 if (!d->initialized)
1355 if (targetBuffer == TargetBuffer::RightBuffer && !format().stereo())
1358 d->setCurrentTargetBuffer(targetBuffer);
1362
1363
1364
1365
1366
1367
1368void QOpenGLWidget::doneCurrent()
1371 if (!d->initialized)
1374 d->context->doneCurrent();
1378
1379
1380
1381
1382
1383
1384
1385QOpenGLContext *QOpenGLWidget::context()
const
1387 Q_D(
const QOpenGLWidget);
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403GLuint QOpenGLWidget::defaultFramebufferObject()
const
1405 Q_D(
const QOpenGLWidget);
1406 return d->fbos[TargetBuffer::LeftBuffer] ? d->fbos[TargetBuffer::LeftBuffer]->handle() : 0;
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425GLuint QOpenGLWidget::defaultFramebufferObject(TargetBuffer targetBuffer)
const
1427 Q_D(
const QOpenGLWidget);
1428 return d->fbos[targetBuffer] ? d->fbos[targetBuffer]->handle() : 0;
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444void QOpenGLWidget::initializeGL()
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459void QOpenGLWidget::resizeGL(
int w,
int h)
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498void QOpenGLWidget::paintGL()
1502 d->context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1506
1507
1508
1509
1510
1511
1512
1513
1514void QOpenGLWidget::resizeEvent(QResizeEvent *e)
1518 if (e->size().isEmpty()) {
1519 d->fakeHidden =
true;
1522 d->fakeHidden =
false;
1525 if (!d->initialized)
1532 resizeGL(width(), height());
1533 d->sendPaintEvent(QRect(QPoint(0, 0), size()));
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547void QOpenGLWidget::paintEvent(QPaintEvent *e)
1553 if (d->initialized) {
1554 d->ensureRhiDependentResources();
1555 if (updatesEnabled())
1561
1562
1563
1564
1565
1566QImage QOpenGLWidget::grabFramebuffer()
1569 return d->grabFramebuffer();
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583QImage QOpenGLWidget::grabFramebuffer(TargetBuffer targetBuffer)
1586 return d->grabFramebuffer(targetBuffer);
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599QOpenGLWidget::TargetBuffer QOpenGLWidget::currentTargetBuffer()
const
1601 Q_D(
const QOpenGLWidget);
1602 return d->currentTargetBuffer;
1606
1607
1608int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric)
const
1610 Q_D(
const QOpenGLWidget);
1611 if (d->inBackingStorePaint)
1612 return QWidget::metric(metric);
1614 auto window = d->windowHandle(QWidgetPrivate::WindowHandleMode::TopLevel);
1615 QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen();
1617 const float dpmx = qt_defaultDpiX() * 100. / 2.54;
1618 const float dpmy = qt_defaultDpiY() * 100. / 2.54;
1629 return width() * screen->physicalSize().width() / screen->geometry().width();
1631 return width() * 1000 / dpmx;
1634 return height() * screen->physicalSize().height() / screen->geometry().height();
1636 return height() * 1000 / dpmy;
1641 return qRound(screen->logicalDotsPerInchX());
1643 return qRound(dpmx * 0.0254);
1646 return qRound(screen->logicalDotsPerInchY());
1648 return qRound(dpmy * 0.0254);
1649 case PdmPhysicalDpiX:
1651 return qRound(screen->physicalDotsPerInchX());
1653 return qRound(dpmx * 0.0254);
1654 case PdmPhysicalDpiY:
1656 return qRound(screen->physicalDotsPerInchY());
1658 return qRound(dpmy * 0.0254);
1659 case PdmDevicePixelRatio:
1660 return QWidget::metric(metric);
1661 case PdmDevicePixelRatioScaled:
1662 return QWidget::metric(metric);
1663 case PdmDevicePixelRatioF_EncodedA:
1665 case PdmDevicePixelRatioF_EncodedB:
1666 return QWidget::metric(metric);
1668 qWarning(
"QOpenGLWidget::metric(): unknown metric %d", metric);
1674
1675
1676QPaintDevice *QOpenGLWidget::redirected(QPoint *p)
const
1678 Q_D(
const QOpenGLWidget);
1679 if (d->inBackingStorePaint)
1680 return QWidget::redirected(p);
1682 return d->paintDevice;
1686
1687
1688QPaintEngine *QOpenGLWidget::paintEngine()
const
1690 Q_D(
const QOpenGLWidget);
1694 if (d->inBackingStorePaint)
1695 return QWidget::paintEngine();
1697 if (!d->initialized)
1700 return d->paintDevice->paintEngine();
1708 if (targetBuffer == QOpenGLWidget::RightBuffer && !isStereoEnabled())
1711 currentTargetBuffer = targetBuffer;
1718
1719
1720bool QOpenGLWidget::event(QEvent *e)
1723 switch (e->type()) {
1724 case QEvent::WindowAboutToChangeInternal:
1725 d->resetRhiDependentResources();
1727 case QEvent::WindowChangeInternal:
1728 if (QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts))
1736 if (d->initialized && !d->wrapperTextures[d->currentTargetBuffer] && window()->windowHandle()) {
1739 if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts))
1743 if (!d->initialized && !size().isEmpty()) {
1745 if (d->initialized) {
1750 d->sendPaintEvent(QRect(QPoint(0, 0), size()));
1755 case QEvent::DevicePixelRatioChange:
1756 if (d->initialized && d->paintDevice->devicePixelRatio() != devicePixelRatio())
1762 return QWidget::event(e);
1767#include "moc_qopenglwidget.cpp"
Combined button and popup list for selecting options.