QtBase  v6.3.1
qopenglcontext.h
Go to the documentation of this file.
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 
40 #ifndef QOPENGLCONTEXT_H
41 #define QOPENGLCONTEXT_H
42 
43 #include <QtGui/qtguiglobal.h>
44 
45 #ifndef QT_NO_OPENGL
46 
47 #include <QtCore/qnamespace.h>
48 #include <QtCore/QObject>
49 #include <QtCore/QScopedPointer>
50 #include <QtCore/qnativeinterface.h>
51 
52 #include <QtGui/QSurfaceFormat>
53 
54 #ifdef __GLEW_H__
55 #if defined(Q_CC_GNU)
56 #warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
57 #warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
58 #endif
59 #endif
60 
61 #include <QtGui/qopengl.h>
62 
63 #include <QtCore/qvariant.h>
64 
66 
67 class QDebug;
70 class QOpenGLFunctions;
73 
74 class QScreen;
75 class QSurface;
76 
77 class Q_GUI_EXPORT QOpenGLContextGroup : public QObject
78 {
79  Q_OBJECT
80  Q_DECLARE_PRIVATE(QOpenGLContextGroup)
81 public:
83 
84  QList<QOpenGLContext *> shares() const;
85 
86  static QOpenGLContextGroup *currentContextGroup();
87 
88 private:
90 
91  friend class QOpenGLContext;
92  friend class QOpenGLContextPrivate;
93  friend class QOpenGLContextGroupResourceBase;
94  friend class QOpenGLSharedResource;
96 };
97 
98 
100 
101 class Q_GUI_EXPORT QOpenGLContext : public QObject
102 {
103  Q_OBJECT
104  Q_DECLARE_PRIVATE(QOpenGLContext)
105 public:
106  explicit QOpenGLContext(QObject *parent = nullptr);
107  ~QOpenGLContext();
108 
109  void setFormat(const QSurfaceFormat &format);
110  void setShareContext(QOpenGLContext *shareContext);
111  void setScreen(QScreen *screen);
112 
113  bool create();
114  bool isValid() const;
115 
116  QSurfaceFormat format() const;
117  QOpenGLContext *shareContext() const;
118  QOpenGLContextGroup *shareGroup() const;
119  QScreen *screen() const;
120 
121  GLuint defaultFramebufferObject() const;
122 
123  bool makeCurrent(QSurface *surface);
124  void doneCurrent();
125 
126  void swapBuffers(QSurface *surface);
127  QFunctionPointer getProcAddress(const QByteArray &procName) const;
128  QFunctionPointer getProcAddress(const char *procName) const;
129 
130  QSurface *surface() const;
131 
132  static QOpenGLContext *currentContext();
133  static bool areSharing(QOpenGLContext *first, QOpenGLContext *second);
134 
136  QPlatformOpenGLContext *shareHandle() const;
137 
138  QOpenGLFunctions *functions() const;
139  QOpenGLExtraFunctions *extraFunctions() const;
140 
141  QSet<QByteArray> extensions() const;
142  bool hasExtension(const QByteArray &extension) const;
143 
146  LibGLES
147  };
148 
149  static OpenGLModuleType openGLModuleType();
150 
151  bool isOpenGLES() const;
152 
153  static bool supportsThreadedOpenGL();
154  static QOpenGLContext *globalShareContext();
155 
157 
158 Q_SIGNALS:
160 
161 private:
162  friend class QOpenGLContextResourceBase;
163  friend class QOpenGLPaintDevice;
164  friend class QOpenGLGlyphTexture;
169  friend class QOpenGL2PaintEngineEx;
171  friend class QSGDistanceFieldGlyphCache;
172  friend class QWidgetPrivate;
174  friend class QOpenGLTexturePrivate;
175 
176  QOpenGLTextureHelper* textureFunctions() const;
177  void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback);
178 
179  void destroy();
180 
181  Q_PRIVATE_SLOT(d_func(), void _q_screenDestroyed(QObject *object))
182 };
183 
184 #ifndef QT_NO_DEBUG_STREAM
185 Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContext *ctx);
186 Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContextGroup *cg);
187 #endif // !QT_NO_DEBUG_STREAM
188 
190 
191 #include <QtGui/qopenglcontext_platform.h>
192 
193 #endif // QT_NO_OPENGL
194 
195 #endif // QOPENGLCONTEXT_H
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:85
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
The QOpenGLContextGroup class represents a group of contexts sharing OpenGL resources....
The QOpenGLContext class represents a native OpenGL context, enabling OpenGL rendering on a QSurface.
void aboutToBeDestroyed()
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 QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter.
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition: qscreen.h:68
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
The QSurface class is an abstraction of renderable surfaces in Qt.
Definition: qsurface.h:57
widget setFormat(format)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T)
GLuint64 GLenum void * handle
GLint first
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
GLint GLsizei GLsizei GLenum format
const void * getProcAddress
Definition: qopenglext.h:11305
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_PRIVATE_SLOT(d, signature)
Definition: qtmetamacros.h:82
#define Q_SIGNALS
Definition: qtmetamacros.h:81
HB_EXTERN hb_font_get_glyph_func_t void hb_destroy_func_t destroy
QScreen * screen
[1]
Definition: main.cpp:76
view create()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent