1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39#ifndef QSURFACEFORMAT_H
40#define QSURFACEFORMAT_H
41
42#include <QtGui/qtguiglobal.h>
43#include <QtCore/qpair.h>
44#include <QtCore/qobjectdefs.h>
45
46QT_BEGIN_NAMESPACE
47
48
49class QOpenGLContext;
50class QSurfaceFormatPrivate;
51
52class Q_GUI_EXPORT QSurfaceFormat
53{
54 Q_GADGET
55public:
56 enum FormatOption {
57 StereoBuffers = 0x0001,
58 DebugContext = 0x0002,
59 DeprecatedFunctions = 0x0004,
60 ResetNotification = 0x0008
61 };
62 Q_ENUM(FormatOption)
63 Q_DECLARE_FLAGS(FormatOptions, FormatOption)
64
65 enum SwapBehavior {
66 DefaultSwapBehavior,
67 SingleBuffer,
68 DoubleBuffer,
69 TripleBuffer
70 };
71 Q_ENUM(SwapBehavior)
72
73 enum RenderableType {
74 DefaultRenderableType = 0x0,
75 OpenGL = 0x1,
76 OpenGLES = 0x2,
77 OpenVG = 0x4
78 };
79 Q_ENUM(RenderableType)
80
81 enum OpenGLContextProfile {
82 NoProfile,
83 CoreProfile,
84 CompatibilityProfile
85 };
86 Q_ENUM(OpenGLContextProfile)
87
88 enum ColorSpace {
89 DefaultColorSpace,
90 sRGBColorSpace
91 };
92 Q_ENUM(ColorSpace)
93
94 QSurfaceFormat();
95 /*implicit*/ QSurfaceFormat(FormatOptions options);
96 QSurfaceFormat(const QSurfaceFormat &other);
97 QSurfaceFormat &operator=(const QSurfaceFormat &other);
98 ~QSurfaceFormat();
99
100 void setDepthBufferSize(int size);
101 int depthBufferSize() const;
102
103 void setStencilBufferSize(int size);
104 int stencilBufferSize() const;
105
106 void setRedBufferSize(int size);
107 int redBufferSize() const;
108 void setGreenBufferSize(int size);
109 int greenBufferSize() const;
110 void setBlueBufferSize(int size);
111 int blueBufferSize() const;
112 void setAlphaBufferSize(int size);
113 int alphaBufferSize() const;
114
115 void setSamples(int numSamples);
116 int samples() const;
117
118 void setSwapBehavior(SwapBehavior behavior);
119 SwapBehavior swapBehavior() const;
120
121 bool hasAlpha() const;
122
123 void setProfile(OpenGLContextProfile profile);
124 OpenGLContextProfile profile() const;
125
126 void setRenderableType(RenderableType type);
127 RenderableType renderableType() const;
128
129 void setMajorVersion(int majorVersion);
130 int majorVersion() const;
131
132 void setMinorVersion(int minorVersion);
133 int minorVersion() const;
134
135 QPair<int, int> version() const;
136 void setVersion(int major, int minor);
137
138 bool stereo() const;
139 void setStereo(bool enable);
140
141#if QT_DEPRECATED_SINCE(5, 2)
142 QT_DEPRECATED void setOption(QSurfaceFormat::FormatOptions opt);
143 QT_DEPRECATED bool testOption(QSurfaceFormat::FormatOptions opt) const;
144#endif
145
146 void setOptions(QSurfaceFormat::FormatOptions options);
147 void setOption(FormatOption option, bool on = true);
148 bool testOption(FormatOption option) const;
149 QSurfaceFormat::FormatOptions options() const;
150
151 int swapInterval() const;
152 void setSwapInterval(int interval);
153
154 ColorSpace colorSpace() const;
155 void setColorSpace(ColorSpace colorSpace);
156
157 static void setDefaultFormat(const QSurfaceFormat &format);
158 static QSurfaceFormat defaultFormat();
159
160private:
161 QSurfaceFormatPrivate *d;
162
163 void detach();
164
165 friend Q_GUI_EXPORT bool operator==(const QSurfaceFormat&, const QSurfaceFormat&);
166 friend Q_GUI_EXPORT bool operator!=(const QSurfaceFormat&, const QSurfaceFormat&);
167#ifndef QT_NO_DEBUG_STREAM
168 friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &);
169#endif
170};
171
172Q_GUI_EXPORT bool operator==(const QSurfaceFormat&, const QSurfaceFormat&);
173Q_GUI_EXPORT bool operator!=(const QSurfaceFormat&, const QSurfaceFormat&);
174
175#ifndef QT_NO_DEBUG_STREAM
176Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &);
177#endif
178
179Q_DECLARE_OPERATORS_FOR_FLAGS(QSurfaceFormat::FormatOptions)
180
181inline bool QSurfaceFormat::stereo() const
182{
183 return testOption(QSurfaceFormat::StereoBuffers);
184}
185
186QT_END_NAMESPACE
187
188#endif //QSURFACEFORMAT_H
189

source code of qtbase/src/gui/kernel/qsurfaceformat.h