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
qopenglversionfunctions.cpp
Go to the documentation of this file.
1// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4/***************************************************************************
5** This file was generated by glgen version 0.1
6** Command line was: glgen
7**
8** glgen is Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB)
9**
10** This is an auto-generated file.
11** Do not edit! All changes made to it will be lost.
12**
13****************************************************************************/
14
17#include "qopenglcontext.h"
18#include "qdebug.h"
19
21
23{
24 for (auto *f : std::as_const(externalFunctions)) {
26 fp->owningContext = nullptr;
27 fp->initialized = false;
28 }
32}
33
35{
37 if (context_d->versionFunctions == nullptr)
38 context_d->versionFunctions = new QOpenGLContextVersionData;
39
40 return static_cast<QOpenGLContextVersionData *>(context_d->versionFunctions);
41}
42
43#define QT_OPENGL_COUNT_FUNCTIONS(ret, name, args) +1
44#define QT_OPENGL_FUNCTION_NAMES(ret, name, args) \
45 "gl"#name"\0"
46#define QT_OPENGL_IMPLEMENT(CLASS, FUNCTIONS) \
47void CLASS::init() \
48{ \
49 const char *names = FUNCTIONS(QT_OPENGL_FUNCTION_NAMES); \
50 const char *name = names; \
51 for (int i = 0; i < FUNCTIONS(QT_OPENGL_COUNT_FUNCTIONS); ++i) { \
52 functions[i] = context->getProcAddress(name); \
53 name += strlen(name) + 1; \
54 } \
55}
56
61
63{
64#if !QT_CONFIG(opengles2)
65 if (backends) {
66
67 int i = 0;
68
69#define DELETE_BACKEND(X) \
70 if (backends[i] && !--backends[i]->refs) \
71 delete static_cast<QOpenGLFunctions_##X##Backend*>(backends[i]); \
72 ++i;
73
75#undef DELETE_BACKEND
76 delete[] backends;
77 }
78#endif
79}
80
82{
83#if QT_CONFIG(opengles2)
85 Q_UNUSED(v);
86 return 0;
87#else
88 if (!backends) {
91 }
92 if (backends[v])
93 return backends[v];
94
95 switch(v) {
96#define VERSION_ENUM(X) QOpenGLVersionFunctionsBackend::OpenGL_##X
97#define CREATE_BACKEND(X) \
98 case VERSION_ENUM(X): \
99 backends[VERSION_ENUM(X)] = new QOpenGLFunctions_##X##Backend(context); \
100 break;
103 Q_UNREACHABLE();
104 }
105 // the storage keeps one ref
106 ++backends[v]->refs;
107 return backends[v];
108#endif
109}
110
116
122
128
243
248{
250 if (d->owningContext)
251 d->removeExternalFunctions(d->owningContext, this);
252 delete d_ptr;
253}
254
258{
260 d->initialized = true;
261
262 // For a subclass whose instance is not created via
263 // QOpenGLContext::versionFunctions() owningContext is not set. Set it now
264 // and register such instances to the context as external ones. These are
265 // not owned by the context but still need certain cleanup when the context
266 // is destroyed.
267 if (!d->owningContext) {
268 d->owningContext = QOpenGLContext::currentContext();
269 if (d->owningContext)
270 d->insertExternalFunctions(d->owningContext, this);
271 }
272
273 return true;
274}
275
279{
280 Q_D(const QAbstractOpenGLFunctions);
281 return d->initialized;
282}
283
287{
289 d->owningContext = const_cast<QOpenGLContext*>(context);
290}
291
295{
296 Q_D(const QAbstractOpenGLFunctions);
297 return d->owningContext;
298}
299
300#if !QT_CONFIG(opengles2)
301
304
321
324
332
333#else
334
335// No backends for OpenGL ES 2
336
337#endif // !QT_CONFIG(opengles2)
338
static QAbstractOpenGLFunctionsPrivate * get(QAbstractOpenGLFunctions *q)
static QOpenGLVersionFunctionsBackend * functionsBackend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v)
static void removeExternalFunctions(QOpenGLContext *context, QAbstractOpenGLFunctions *f)
static void insertExternalFunctions(QOpenGLContext *context, QAbstractOpenGLFunctions *f)
virtual ~QAbstractOpenGLFunctions()
Destroys a QAbstractOpenGLFunctions object.
QAbstractOpenGLFunctionsPrivate * d_ptr
QOpenGLContext * owningContext() const
void setOwningContext(const QOpenGLContext *context)
QAbstractOpenGLFunctions()
Constructs a QAbstractOpenGLFunctions object.
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
Definition qhash.h:951
static QOpenGLContextPrivate * get(QOpenGLContext *context)
QSet< QAbstractOpenGLFunctions * > externalFunctions
QHash< QOpenGLVersionProfile, QAbstractOpenGLFunctions * > functions
static QOpenGLContextVersionData * forContext(QOpenGLContext *context)
\inmodule QtGui
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QOpenGLVersionFunctionsBackend ** backends
QOpenGLVersionFunctionsBackend * backend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v)
void clear()
Definition qset.h:61
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
static void * context
GLsizei const GLfloat * v
[13]
GLfloat GLfloat f
#define QT_OPENGL_IMPLEMENT(CLASS, FUNCTIONS)
#define DELETE_BACKEND(X)
#define CREATE_BACKEND(X)
#define QT_OPENGL_1_4_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_3_1_FUNCTIONS(F)
#define QT_OPENGL_4_4_FUNCTIONS(F)
#define QT_OPENGL_4_5_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_3_0_FUNCTIONS(F)
#define QT_OPENGL_1_2_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_2_0_FUNCTIONS(F)
#define QT_OPENGL_2_1_FUNCTIONS(F)
#define QT_OPENGL_1_1_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_4_3_FUNCTIONS(F)
#define QT_OPENGL_3_0_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_1_5_FUNCTIONS(F)
#define QT_OPENGL_1_3_FUNCTIONS(F)
#define QT_OPENGL_1_4_FUNCTIONS(F)
#define QT_OPENGL_1_2_FUNCTIONS(F)
#define QT_OPENGL_1_1_FUNCTIONS(F)
#define QT_OPENGL_1_3_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_3_3_FUNCTIONS(F)
#define QT_OPENGL_4_5_FUNCTIONS(F)
#define QT_OPENGL_3_3_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_VERSIONS(F)
#define QT_OPENGL_2_0_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_4_1_FUNCTIONS(F)
#define QT_OPENGL_4_2_FUNCTIONS(F)
#define QT_OPENGL_3_2_FUNCTIONS(F)
#define QT_OPENGL_4_0_FUNCTIONS(F)
#define QT_OPENGL_1_0_DEPRECATED_FUNCTIONS(F)
#define QT_OPENGL_1_0_FUNCTIONS(F)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define fp
#define Q_UNUSED(x)
QObject::connect nullptr