File indexing completed on 2025-01-18 10:08:00
0001
0002
0003
0004 #ifndef QOPENGLCONTEXT_H
0005 #define QOPENGLCONTEXT_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008
0009 #ifndef QT_NO_OPENGL
0010
0011 #include <QtCore/qnamespace.h>
0012 #include <QtCore/qobject.h>
0013 #include <QtCore/qscopedpointer.h>
0014 #include <QtCore/qset.h>
0015 #include <QtCore/qnativeinterface.h>
0016
0017 #include <QtGui/QSurfaceFormat>
0018
0019 #ifdef __GLEW_H__
0020 #if defined(Q_CC_GNU)
0021 #warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
0022 #warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
0023 #endif
0024 #endif
0025
0026 #include <QtGui/qopengl.h>
0027
0028 #include <QtCore/qvariant.h>
0029
0030 QT_BEGIN_NAMESPACE
0031
0032 class QDebug;
0033 class QOpenGLContextPrivate;
0034 class QOpenGLContextGroupPrivate;
0035 class QOpenGLFunctions;
0036 class QOpenGLExtraFunctions;
0037 class QPlatformOpenGLContext;
0038
0039 class QScreen;
0040 class QSurface;
0041
0042 class Q_GUI_EXPORT QOpenGLContextGroup : public QObject
0043 {
0044 Q_OBJECT
0045 Q_DECLARE_PRIVATE(QOpenGLContextGroup)
0046 public:
0047 ~QOpenGLContextGroup();
0048
0049 QList<QOpenGLContext *> shares() const;
0050
0051 static QOpenGLContextGroup *currentContextGroup();
0052
0053 private:
0054 QOpenGLContextGroup();
0055
0056 friend class QOpenGLContext;
0057 friend class QOpenGLContextPrivate;
0058 friend class QOpenGLContextGroupResourceBase;
0059 friend class QOpenGLSharedResource;
0060 friend class QOpenGLMultiGroupSharedResource;
0061 };
0062
0063
0064 class QOpenGLTextureHelper;
0065
0066 class Q_GUI_EXPORT QOpenGLContext : public QObject
0067 {
0068 Q_OBJECT
0069 Q_DECLARE_PRIVATE(QOpenGLContext)
0070 public:
0071 explicit QOpenGLContext(QObject *parent = nullptr);
0072 ~QOpenGLContext();
0073
0074 void setFormat(const QSurfaceFormat &format);
0075 void setShareContext(QOpenGLContext *shareContext);
0076 void setScreen(QScreen *screen);
0077
0078 bool create();
0079 bool isValid() const;
0080
0081 QSurfaceFormat format() const;
0082 QOpenGLContext *shareContext() const;
0083 QOpenGLContextGroup *shareGroup() const;
0084 QScreen *screen() const;
0085
0086 GLuint defaultFramebufferObject() const;
0087
0088 bool makeCurrent(QSurface *surface);
0089 void doneCurrent();
0090
0091 void swapBuffers(QSurface *surface);
0092 QFunctionPointer getProcAddress(const QByteArray &procName) const;
0093 QFunctionPointer getProcAddress(const char *procName) const;
0094
0095 QSurface *surface() const;
0096
0097 static QOpenGLContext *currentContext();
0098 static bool areSharing(QOpenGLContext *first, QOpenGLContext *second);
0099
0100 QPlatformOpenGLContext *handle() const;
0101 QPlatformOpenGLContext *shareHandle() const;
0102
0103 QOpenGLFunctions *functions() const;
0104 QOpenGLExtraFunctions *extraFunctions() const;
0105
0106 QSet<QByteArray> extensions() const;
0107 bool hasExtension(const QByteArray &extension) const;
0108
0109 enum OpenGLModuleType {
0110 LibGL,
0111 LibGLES
0112 };
0113
0114 static OpenGLModuleType openGLModuleType();
0115
0116 bool isOpenGLES() const;
0117
0118 static bool supportsThreadedOpenGL();
0119 static QOpenGLContext *globalShareContext();
0120
0121 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QOpenGLContext)
0122
0123 Q_SIGNALS:
0124 void aboutToBeDestroyed();
0125
0126 private:
0127 friend class QOpenGLContextResourceBase;
0128 friend class QOpenGLPaintDevice;
0129 friend class QOpenGLGlyphTexture;
0130 friend class QOpenGLTextureGlyphCache;
0131 friend class QOpenGLEngineShaderManager;
0132 friend class QOpenGLFramebufferObject;
0133 friend class QOpenGLFramebufferObjectPrivate;
0134 friend class QOpenGL2PaintEngineEx;
0135 friend class QOpenGL2PaintEngineExPrivate;
0136 friend class QSGDistanceFieldGlyphCache;
0137 friend class QWidgetPrivate;
0138 friend class QAbstractOpenGLFunctionsPrivate;
0139 friend class QOpenGLTexturePrivate;
0140
0141 QOpenGLTextureHelper* textureFunctions() const;
0142 void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback);
0143
0144 void destroy();
0145
0146 Q_PRIVATE_SLOT(d_func(), void _q_screenDestroyed(QObject *object))
0147 };
0148
0149 #ifndef QT_NO_DEBUG_STREAM
0150 Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContext *ctx);
0151 Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContextGroup *cg);
0152 #endif
0153
0154 QT_END_NAMESPACE
0155
0156 #include <QtGui/qopenglcontext_platform.h>
0157
0158 #endif
0159
0160 #endif