Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopenglversionfunctionsfactory.cpp
Go to the documentation of this file.
1// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3/***************************************************************************
4** This file was generated by glgen version 0.1
5** Command line was: glgen
6**
7** glgen is Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
8**
9** This is an auto-generated file.
10** Do not edit! All changes made to it will be lost.
11**
12****************************************************************************/
13
16
17#if !QT_CONFIG(opengles2)
44#else
46#endif
47
49
51{
52#if !QT_CONFIG(opengles2)
53 const int major = versionProfile.version().first;
54 const int minor = versionProfile.version().second;
55
56 if (versionProfile.hasProfiles()) {
57 switch (versionProfile.profile()) {
59 if (major == 4 && minor == 5)
61 else if (major == 4 && minor == 4)
63 else if (major == 4 && minor == 3)
65 else if (major == 4 && minor == 2)
67 else if (major == 4 && minor == 1)
69 else if (major == 4 && minor == 0)
71 else if (major == 3 && minor == 3)
73 else if (major == 3 && minor == 2)
75 break;
76
78 if (major == 4 && minor == 5)
80 else if (major == 4 && minor == 4)
82 else if (major == 4 && minor == 3)
84 else if (major == 4 && minor == 2)
86 else if (major == 4 && minor == 1)
88 else if (major == 4 && minor == 0)
90 else if (major == 3 && minor == 3)
92 else if (major == 3 && minor == 2)
94 break;
95
97 default:
98 break;
99 };
100 } else {
101 if (major == 3 && minor == 1)
102 return new QOpenGLFunctions_3_1;
103 else if (major == 3 && minor == 0)
104 return new QOpenGLFunctions_3_0;
105 else if (major == 2 && minor == 1)
106 return new QOpenGLFunctions_2_1;
107 else if (major == 2 && minor == 0)
108 return new QOpenGLFunctions_2_0;
109 else if (major == 1 && minor == 5)
110 return new QOpenGLFunctions_1_5;
111 else if (major == 1 && minor == 4)
112 return new QOpenGLFunctions_1_4;
113 else if (major == 1 && minor == 3)
114 return new QOpenGLFunctions_1_3;
115 else if (major == 1 && minor == 2)
116 return new QOpenGLFunctions_1_2;
117 else if (major == 1 && minor == 1)
118 return new QOpenGLFunctions_1_1;
119 else if (major == 1 && minor == 0)
120 return new QOpenGLFunctions_1_0;
121 }
122 return nullptr;
123#else
124 Q_UNUSED(versionProfile);
125 return new QOpenGLFunctions_ES2;
126#endif
127}
128
198{
199 if (!context)
201
202 if (!context) {
203 qWarning("versionFunctions: No OpenGL context");
204 return nullptr;
205 }
206
207#if !QT_CONFIG(opengles2)
208 if (context->isOpenGLES()) {
209 qWarning("versionFunctions: Not supported on OpenGL ES");
210 return nullptr;
211 }
212#endif // !QT_CONFIG(opengles2)
213
214 const QSurfaceFormat f = context->format();
215
216 // Ensure we have a valid version and profile. Default to context's if none specified
217 QOpenGLVersionProfile vp = versionProfile;
218 if (!vp.isValid())
220
221 // Check that context is compatible with requested version
222 const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
223 if (v < vp.version())
224 return nullptr;
225
226 // If this context only offers core profile functions then we can't create
227 // function objects for legacy or compatibility profile requests
228 if (((vp.hasProfiles() && vp.profile() != QSurfaceFormat::CoreProfile) || vp.isLegacyVersion())
229 && f.profile() == QSurfaceFormat::CoreProfile)
230 return nullptr;
231
232 // Create object if suitable one not cached
234 // TODO: replace with something else
236 auto it = data->functions.constFind(vp);
237 if (it == data->functions.constEnd()) {
239 if (funcs) {
240 funcs->setOwningContext(context);
241 data->functions.insert(vp, funcs);
242 }
243 } else {
244 funcs = it.value();
245 }
246
248 funcs->initializeOpenGLFunctions();
249
250 return funcs;
251}
252
static QOpenGLContextVersionData * forContext(QOpenGLContext *context)
\inmodule QtGui
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
\inmodule QtOpenGL
static QAbstractOpenGLFunctions * get(const QOpenGLVersionProfile &versionProfile=QOpenGLVersionProfile(), QOpenGLContext *context=nullptr)
Returns a pointer to an object that provides access to all functions for the versionProfile of the co...
QSurfaceFormat::OpenGLContextProfile profile() const
Returns the OpenGL profile.
bool isValid() const
Returns true if the version number is valid.
bool isLegacyVersion() const
Returns true is the OpenGL version returned by version() contains deprecated functions and does not s...
bool hasProfiles() const
Returns true if profiles are supported by the OpenGL version returned by version().
QPair< int, int > version() const
Returns a QPair<int,int> where the components represent the major and minor OpenGL version numbers re...
const_iterator constEnd() const noexcept
Definition qset.h:143
const_iterator constFind(const T &value) const
Definition qset.h:161
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
static VulkanServerBufferGlFunctions * funcs
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static void * context
#define qWarning
Definition qlogging.h:166
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
static QT_BEGIN_NAMESPACE QAbstractOpenGLFunctions * createFunctions(const QOpenGLVersionProfile &versionProfile)
QT_BEGIN_NAMESPACE constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
Definition qpair.h:19
#define Q_UNUSED(x)