137
138
139
140
141
142
143
144
145
146
147
148
149
152
153
154
155
156
157
158
159
160
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
202
203
204
205
206
207QSurfaceFormat::QSurfaceFormat() : d(
new QSurfaceFormatPrivate)
212
213
214QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) :
215 d(
new QSurfaceFormatPrivate(options))
220
221
222void QSurfaceFormat::detach()
224 if (d->ref.loadRelaxed() != 1) {
225 QSurfaceFormatPrivate *newd =
new QSurfaceFormatPrivate(d);
233
234
235QSurfaceFormat::QSurfaceFormat(
const QSurfaceFormat &other)
242
243
244QSurfaceFormat &QSurfaceFormat::operator=(
const QSurfaceFormat &other)
256
257
258QSurfaceFormat::~QSurfaceFormat()
265
266
267
268
269
270
271
274
275
276
277
278
279
280
281
282
283
284void QSurfaceFormat::setStereo(
bool enable)
286 QSurfaceFormat::FormatOptions newOptions = d->opts;
287 newOptions.setFlag(QSurfaceFormat::StereoBuffers, enable);
289 if (
int(newOptions) !=
int(d->opts)) {
291 d->opts = newOptions;
296
297
298
299
300
301
302int QSurfaceFormat::samples()
const
304 return d->numSamples;
308
309
310
311
312
313void QSurfaceFormat::setSamples(
int numSamples)
315 if (d->numSamples != numSamples) {
317 d->numSamples = numSamples;
322
323
324
325
326
327
328
329
330
331void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options)
333 if (
int(d->opts) !=
int(options)) {
340
341
342
343
344
345
346
347
348
349void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option,
bool on)
351 if (testOption(option) == on)
361
362
363
364
365
366
367bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option)
const
369 return d->opts & option;
373
374
375
376
377
378
379QSurfaceFormat::FormatOptions QSurfaceFormat::options()
const
385
386
387
388
389void QSurfaceFormat::setDepthBufferSize(
int size)
391 if (d->depthSize != size) {
398
399
400
401
402int QSurfaceFormat::depthBufferSize()
const
408
409
410
411
412
413
414void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
416 if (d->swapBehavior != behavior) {
418 d->swapBehavior = behavior;
423
424
425
426
427QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior()
const
429 return d->swapBehavior;
433
434
435
436
437
438bool QSurfaceFormat::hasAlpha()
const
440 return d->alphaBufferSize > 0;
444
445
446
447
448void QSurfaceFormat::setStencilBufferSize(
int size)
450 if (d->stencilSize != size) {
452 d->stencilSize = size;
457
458
459
460
461int QSurfaceFormat::stencilBufferSize()
const
463 return d->stencilSize;
467
468
469int QSurfaceFormat::redBufferSize()
const
471 return d->redBufferSize;
475
476
477int QSurfaceFormat::greenBufferSize()
const
479 return d->greenBufferSize;
483
484
485int QSurfaceFormat::blueBufferSize()
const
487 return d->blueBufferSize;
491
492
493int QSurfaceFormat::alphaBufferSize()
const
495 return d->alphaBufferSize;
499
500
501void QSurfaceFormat::setRedBufferSize(
int size)
503 if (d->redBufferSize != size) {
505 d->redBufferSize = size;
510
511
512void QSurfaceFormat::setGreenBufferSize(
int size)
514 if (d->greenBufferSize != size) {
516 d->greenBufferSize = size;
521
522
523void QSurfaceFormat::setBlueBufferSize(
int size)
525 if (d->blueBufferSize != size) {
527 d->blueBufferSize = size;
532
533
534void QSurfaceFormat::setAlphaBufferSize(
int size)
536 if (d->alphaBufferSize != size) {
538 d->alphaBufferSize = size;
543
544
545
546
547void QSurfaceFormat::setRenderableType(RenderableType type)
549 if (d->renderableType != type) {
551 d->renderableType = type;
556
557
558
559
560QSurfaceFormat::RenderableType QSurfaceFormat::renderableType()
const
562 return d->renderableType;
566
567
568
569
570
571void QSurfaceFormat::setProfile(OpenGLContextProfile profile)
573 if (d->profile != profile) {
575 d->profile = profile;
580
581
582
583
584
585QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile()
const
591
592
593void QSurfaceFormat::setMajorVersion(
int major)
595 if (d->major != major) {
602
603
604
605
606int QSurfaceFormat::majorVersion()
const
612
613
614
615
616void QSurfaceFormat::setMinorVersion(
int minor)
618 if (d->minor != minor) {
625
626
627int QSurfaceFormat::minorVersion()
const
633
634
635
636
637std::pair<
int,
int> QSurfaceFormat::version()
const
639 return std::pair(d->major, d->minor);
643
644
645
646
647void QSurfaceFormat::setVersion(
int major,
int minor)
649 if (d->minor != minor || d->major != major) {
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676void QSurfaceFormat::setSwapInterval(
int interval)
678 if (d->swapInterval != interval) {
680 d->swapInterval = interval;
685
686
687
688
689
690
691int QSurfaceFormat::swapInterval()
const
693 return d->swapInterval;
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717void QSurfaceFormat::setColorSpace(
const QColorSpace &colorSpace)
719 if (d->colorSpace != colorSpace) {
721 d->colorSpace = colorSpace;
725#if QT_DEPRECATED_SINCE(6
, 0
)
727
728
729
730
731
732
733
734
735
736void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
738 switch (colorSpace) {
739 case DefaultColorSpace:
740 setColorSpace(QColorSpace());
743 setColorSpace(QColorSpace::SRgb);
750
751
752
753
754
755
756const QColorSpace &QSurfaceFormat::colorSpace()
const
758 return d->colorSpace;
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780void QSurfaceFormat::setDefaultFormat(
const QSurfaceFormat &format)
784 QOpenGLContext *globalContext = qt_gl_global_share_context();
785 if (globalContext && globalContext->isValid()) {
786 qWarning(
"Warning: Setting a new default format with a different version or profile "
787 "after the global shared context is created may cause issues with context "
792 *qt_default_surface_format() = format;
796
797
798
799
800
801
802
803QSurfaceFormat QSurfaceFormat::defaultFormat()
805 return *qt_default_surface_format();
809
810
811
812
813
816
817
818
819
820
823
824
825bool QSurfaceFormat::equals(
const QSurfaceFormat& other)
const noexcept
827 return (d == other.d) || ((
int) d->opts == (
int) other.d->opts
828 && d->stencilSize == other.d->stencilSize
829 && d->redBufferSize == other.d->redBufferSize
830 && d->greenBufferSize == other.d->greenBufferSize
831 && d->blueBufferSize == other.d->blueBufferSize
832 && d->alphaBufferSize == other.d->alphaBufferSize
833 && d->depthSize == other.d->depthSize
834 && d->numSamples == other.d->numSamples
835 && d->swapBehavior == other.d->swapBehavior
836 && d->profile == other.d->profile
837 && d->major == other.d->major
838 && d->minor == other.d->minor
839 && d->swapInterval == other.d->swapInterval);
842#ifndef QT_NO_DEBUG_STREAM
846 QDebugStateSaver saver(dbg);
848 dbg.nospace() <<
"QSurfaceFormat("
850 <<
", options " << d->opts
858 <<
", swapBehavior " << d->swapBehavior
860 <<
", colorSpace " << d->colorSpace
861 <<
", 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