138
139
140
141
142
143
144
145
146
147
148
149
150
153
154
155
156
157
158
159
160
161
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
203
204
205
206
207
208QSurfaceFormat::QSurfaceFormat() : d(
new QSurfaceFormatPrivate)
213
214
215QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) :
216 d(
new QSurfaceFormatPrivate(options))
221
222
223void QSurfaceFormat::detach()
225 if (d->ref.loadRelaxed() != 1) {
226 QSurfaceFormatPrivate *newd =
new QSurfaceFormatPrivate(d);
234
235
236QSurfaceFormat::QSurfaceFormat(
const QSurfaceFormat &other)
243
244
245QSurfaceFormat &QSurfaceFormat::operator=(
const QSurfaceFormat &other)
257
258
259QSurfaceFormat::~QSurfaceFormat()
266
267
268
269
270
271
272
275
276
277
278
279
280
281
282
283
284
285void QSurfaceFormat::setStereo(
bool enable)
287 QSurfaceFormat::FormatOptions newOptions = d->opts;
288 newOptions.setFlag(QSurfaceFormat::StereoBuffers, enable);
290 if (
int(newOptions) !=
int(d->opts)) {
292 d->opts = newOptions;
297
298
299
300
301
302
303int QSurfaceFormat::samples()
const
305 return d->numSamples;
309
310
311
312
313
314void QSurfaceFormat::setSamples(
int numSamples)
316 if (d->numSamples != numSamples) {
318 d->numSamples = numSamples;
323
324
325
326
327
328
329
330
331
332void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)
334 if (
int(d->opts) !=
int(options)) {
341
342
343
344
345
346
347
348
349
350void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option,
bool on)
352 if (testOption(option) == on)
362
363
364
365
366
367
368bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option)
const
370 return d->opts & option;
374
375
376
377
378
379
380QSurfaceFormat::FormatOptions QSurfaceFormat::options()
const
386
387
388
389
390void QSurfaceFormat::setDepthBufferSize(
int size)
392 if (d->depthSize != size) {
399
400
401
402
403int QSurfaceFormat::depthBufferSize()
const
409
410
411
412
413
414
415void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
417 if (d->swapBehavior != behavior) {
419 d->swapBehavior = behavior;
424
425
426
427
428QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior()
const
430 return d->swapBehavior;
434
435
436
437
438
439bool QSurfaceFormat::hasAlpha()
const
441 return d->alphaBufferSize > 0;
445
446
447
448
449void QSurfaceFormat::setStencilBufferSize(
int size)
451 if (d->stencilSize != size) {
453 d->stencilSize = size;
458
459
460
461
462int QSurfaceFormat::stencilBufferSize()
const
464 return d->stencilSize;
468
469
470int QSurfaceFormat::redBufferSize()
const
472 return d->redBufferSize;
476
477
478int QSurfaceFormat::greenBufferSize()
const
480 return d->greenBufferSize;
484
485
486int QSurfaceFormat::blueBufferSize()
const
488 return d->blueBufferSize;
492
493
494int QSurfaceFormat::alphaBufferSize()
const
496 return d->alphaBufferSize;
500
501
502void QSurfaceFormat::setRedBufferSize(
int size)
504 if (d->redBufferSize != size) {
506 d->redBufferSize = size;
511
512
513void QSurfaceFormat::setGreenBufferSize(
int size)
515 if (d->greenBufferSize != size) {
517 d->greenBufferSize = size;
522
523
524void QSurfaceFormat::setBlueBufferSize(
int size)
526 if (d->blueBufferSize != size) {
528 d->blueBufferSize = size;
533
534
535void QSurfaceFormat::setAlphaBufferSize(
int size)
537 if (d->alphaBufferSize != size) {
539 d->alphaBufferSize = size;
544
545
546
547
548void QSurfaceFormat::setRenderableType(RenderableType type)
550 if (d->renderableType != type) {
552 d->renderableType = type;
557
558
559
560
561QSurfaceFormat::RenderableType QSurfaceFormat::renderableType()
const
563 return d->renderableType;
567
568
569
570
571
572void QSurfaceFormat::setProfile(OpenGLContextProfile profile)
574 if (d->profile != profile) {
576 d->profile = profile;
581
582
583
584
585
586QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile()
const
592
593
594void QSurfaceFormat::setMajorVersion(
int major)
596 if (d->major != major) {
603
604
605
606
607int QSurfaceFormat::majorVersion()
const
613
614
615
616
617void QSurfaceFormat::setMinorVersion(
int minor)
619 if (d->minor != minor) {
626
627
628int QSurfaceFormat::minorVersion()
const
634
635
636
637
638std::pair<
int,
int> QSurfaceFormat::version()
const
640 return std::pair(d->major, d->minor);
644
645
646
647
648void QSurfaceFormat::setVersion(
int major,
int minor)
650 if (d->minor != minor || d->major != major) {
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677void QSurfaceFormat::setSwapInterval(
int interval)
679 if (d->swapInterval != interval) {
681 d->swapInterval = interval;
686
687
688
689
690
691
692int QSurfaceFormat::swapInterval()
const
694 return d->swapInterval;
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718void QSurfaceFormat::setColorSpace(
const QColorSpace &colorSpace)
720 if (d->colorSpace != colorSpace) {
722 d->colorSpace = colorSpace;
726#if QT_DEPRECATED_SINCE(6
, 0
)
728
729
730
731
732
733
734
735
736
737void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
739 switch (colorSpace) {
740 case DefaultColorSpace:
741 setColorSpace(QColorSpace());
744 setColorSpace(QColorSpace::SRgb);
751
752
753
754
755
756
757const QColorSpace &QSurfaceFormat::colorSpace()
const
759 return d->colorSpace;
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781void QSurfaceFormat::setDefaultFormat(
const QSurfaceFormat &format)
785 QOpenGLContext *globalContext = qt_gl_global_share_context();
786 if (globalContext && globalContext->isValid()) {
787 qWarning(
"Warning: Setting a new default format with a different version or profile "
788 "after the global shared context is created may cause issues with context "
793 *qt_default_surface_format() = format;
797
798
799
800
801
802
803
804QSurfaceFormat QSurfaceFormat::defaultFormat()
806 return *qt_default_surface_format();
810
811
812
813
814
817
818
819
820
821
824
825
826bool QSurfaceFormat::equals(
const QSurfaceFormat& other)
const noexcept
828 return (d == other.d) || ((
int) d->opts == (
int) other.d->opts
829 && d->stencilSize == other.d->stencilSize
830 && d->redBufferSize == other.d->redBufferSize
831 && d->greenBufferSize == other.d->greenBufferSize
832 && d->blueBufferSize == other.d->blueBufferSize
833 && d->alphaBufferSize == other.d->alphaBufferSize
834 && d->depthSize == other.d->depthSize
835 && d->numSamples == other.d->numSamples
836 && d->swapBehavior == other.d->swapBehavior
837 && d->profile == other.d->profile
838 && d->major == other.d->major
839 && d->minor == other.d->minor
840 && d->swapInterval == other.d->swapInterval);
843#ifndef QT_NO_DEBUG_STREAM
847 QDebugStateSaver saver(dbg);
849 dbg.nospace() <<
"QSurfaceFormat("
851 <<
", options " << d->opts
859 <<
", swapBehavior " << d->swapBehavior
861 <<
", colorSpace " << d->colorSpace
862 <<
", profile " << d->profile
Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames, { { Qt::DisplayRole, "display" }, { Qt::DecorationRole, "decoration" }, { Qt::EditRole, "edit" }, { Qt::ToolTipRole, "toolTip" }, { Qt::StatusTipRole, "statusTip" }, { Qt::WhatsThisRole, "whatsThis" }, }) const QHash< int