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
qopenglcontext.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPENGLCONTEXT_H
5#define QOPENGLCONTEXT_H
6
7#include <QtGui/qtguiglobal.h>
8
9#ifndef QT_NO_OPENGL
10
11#include <QtCore/qnamespace.h>
12#include <QtCore/qobject.h>
13#include <QtCore/qscopedpointer.h>
14#include <QtCore/qset.h>
15#include <QtCore/qnativeinterface.h>
16
17#include <QtGui/QSurfaceFormat>
18
19#ifdef __GLEW_H__
20#if defined(Q_CC_GNU)
21#warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
22#warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
23#endif
24#endif
25
26#include <QtGui/qopengl.h>
27
28#include <QtCore/qvariant.h>
29
31
32class QDebug;
38
39class QScreen;
40class QSurface;
41
42class Q_GUI_EXPORT QOpenGLContextGroup : public QObject
43{
45 Q_DECLARE_PRIVATE(QOpenGLContextGroup)
46public:
48
49 QList<QOpenGLContext *> shares() const;
50
51 static QOpenGLContextGroup *currentContextGroup();
52
53private:
55
56 friend class QOpenGLContext;
58 friend class QOpenGLContextGroupResourceBase;
61};
62
63
65
66class Q_GUI_EXPORT QOpenGLContext : public QObject
67{
69 Q_DECLARE_PRIVATE(QOpenGLContext)
70public:
71 explicit QOpenGLContext(QObject *parent = nullptr);
73
74 void setFormat(const QSurfaceFormat &format);
75 void setShareContext(QOpenGLContext *shareContext);
76 void setScreen(QScreen *screen);
77
78 bool create();
79 bool isValid() const;
80
81 QSurfaceFormat format() const;
82 QOpenGLContext *shareContext() const;
83 QOpenGLContextGroup *shareGroup() const;
84 QScreen *screen() const;
85
86 GLuint defaultFramebufferObject() const;
87
88 bool makeCurrent(QSurface *surface);
89 void doneCurrent();
90
91 void swapBuffers(QSurface *surface);
92 QFunctionPointer getProcAddress(const QByteArray &procName) const;
93 QFunctionPointer getProcAddress(const char *procName) const;
94
95 QSurface *surface() const;
96
97 static QOpenGLContext *currentContext();
98 static bool areSharing(QOpenGLContext *first, QOpenGLContext *second);
99
101 QPlatformOpenGLContext *shareHandle() const;
102
103 QOpenGLFunctions *functions() const;
104 QOpenGLExtraFunctions *extraFunctions() const;
105
106 QSet<QByteArray> extensions() const;
107 bool hasExtension(const QByteArray &extension) const;
108
111 LibGLES
112 };
113
114 static OpenGLModuleType openGLModuleType();
115
116 bool isOpenGLES() const;
117
118 static bool supportsThreadedOpenGL();
119 static QOpenGLContext *globalShareContext();
120
122
125
126private:
127 friend class QOpenGLContextResourceBase;
128 friend class QOpenGLPaintDevice;
137 friend class QWidgetPrivate;
140
141 QOpenGLTextureHelper* textureFunctions() const;
142 void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback);
143
144 void destroy();
145
146 Q_PRIVATE_SLOT(d_func(), void _q_screenDestroyed(QObject *object))
147};
148
149#ifndef QT_NO_DEBUG_STREAM
150Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContext *ctx);
151Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContextGroup *cg);
152#endif // !QT_NO_DEBUG_STREAM
153
155
156#include <QtGui/qopenglcontext_platform.h>
157
158#endif // QT_NO_OPENGL
159
160#endif // QOPENGLCONTEXT_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QOpenGLContextGroup class represents a group of contexts sharing OpenGL resources....
\inmodule QtGui
OpenGLModuleType
This enum defines the type of the underlying OpenGL implementation.
void aboutToBeDestroyed()
This signal is emitted before the underlying native OpenGL context is destroyed, such that users may ...
The QOpenGLExtraFunctions class provides cross-platform access to the OpenGL ES 3....
The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object.
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multip...
The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter.
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
\inmodule QtGui
Definition qsurface.h:21
EGLContext ctx
void extension()
[6]
Definition dialogs.cpp:230
widget setFormat(format)
Combined button and popup list for selecting options.
#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T)
Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContext *ctx)
GLuint64 GLenum void * handle
GLint first
GLint GLsizei GLsizei GLenum format
const void * getProcAddress
#define GLuint
QScreen * screen
[1]
Definition main.cpp:29
#define Q_OBJECT
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
view create()