| 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 QOPENGL_EXTENSIONS_P_H |
| 5 | #define QOPENGL_EXTENSIONS_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of the Qt OpenGL classes. This header file may change from |
| 13 | // version to version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtGui/private/qtguiglobal_p.h> |
| 19 | #include "qopenglextrafunctions.h" |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QOpenGLExtensionsPrivate; |
| 24 | |
| 25 | class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLExtraFunctions |
| 26 | { |
| 27 | Q_DECLARE_PRIVATE(QOpenGLExtensions) |
| 28 | public: |
| 29 | QOpenGLExtensions(); |
| 30 | QOpenGLExtensions(QOpenGLContext *context); |
| 31 | ~QOpenGLExtensions() {} |
| 32 | |
| 33 | enum OpenGLExtension { |
| 34 | TextureRectangle = 0x00000001, |
| 35 | GenerateMipmap = 0x00000002, |
| 36 | TextureCompression = 0x00000004, |
| 37 | MirroredRepeat = 0x00000008, |
| 38 | FramebufferMultisample = 0x00000010, |
| 39 | StencilTwoSide = 0x00000020, |
| 40 | StencilWrap = 0x00000040, |
| 41 | PackedDepthStencil = 0x00000080, |
| 42 | NVFloatBuffer = 0x00000100, |
| 43 | PixelBufferObject = 0x00000200, |
| 44 | FramebufferBlit = 0x00000400, |
| 45 | BGRATextureFormat = 0x00000800, |
| 46 | DDSTextureCompression = 0x00001000, |
| 47 | ETC1TextureCompression = 0x00002000, |
| 48 | PVRTCTextureCompression = 0x00004000, |
| 49 | ElementIndexUint = 0x00008000, |
| 50 | Depth24 = 0x00010000, |
| 51 | SRGBFrameBuffer = 0x00020000, |
| 52 | MapBuffer = 0x00040000, |
| 53 | GeometryShaders = 0x00080000, |
| 54 | MapBufferRange = 0x00100000, |
| 55 | Sized8Formats = 0x00200000, |
| 56 | DiscardFramebuffer = 0x00400000, |
| 57 | Sized16Formats = 0x00800000, |
| 58 | TextureSwizzle = 0x01000000, |
| 59 | StandardDerivatives = 0x02000000, |
| 60 | ASTCTextureCompression = 0x04000000, |
| 61 | ETC2TextureCompression = 0x08000000, |
| 62 | HalfFloatVertex = 0x10000000, |
| 63 | MultiView = 0x20000000, |
| 64 | MultiViewExtended = 0x40000000 |
| 65 | }; |
| 66 | Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) |
| 67 | |
| 68 | OpenGLExtensions openGLExtensions(); |
| 69 | bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const; |
| 70 | |
| 71 | GLvoid *glMapBuffer(GLenum target, GLenum access); |
| 72 | void glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data); |
| 73 | |
| 74 | void flushShared(); |
| 75 | void discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments); |
| 76 | |
| 77 | QOpenGLExtensionsPrivate *d() const; |
| 78 | |
| 79 | private: |
| 80 | static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != nullptr; } |
| 81 | }; |
| 82 | |
| 83 | Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLExtensions::OpenGLExtensions) |
| 84 | |
| 85 | class QOpenGLExtensionsPrivate : public QOpenGLExtraFunctionsPrivate |
| 86 | { |
| 87 | public: |
| 88 | explicit QOpenGLExtensionsPrivate(QOpenGLContext *ctx); |
| 89 | |
| 90 | GLvoid* (QOPENGLF_APIENTRYP MapBuffer)(GLenum target, GLenum access); |
| 91 | void (QOPENGLF_APIENTRYP GetBufferSubData)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data); |
| 92 | void (QOPENGLF_APIENTRYP DiscardFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum *attachments); |
| 93 | |
| 94 | bool flushVendorChecked; |
| 95 | bool flushIsSufficientToSyncContexts; |
| 96 | }; |
| 97 | |
| 98 | inline QOpenGLExtensionsPrivate *QOpenGLExtensions::d() const |
| 99 | { |
| 100 | return static_cast<QOpenGLExtensionsPrivate *>(d_ptr); |
| 101 | } |
| 102 | |
| 103 | inline GLvoid *QOpenGLExtensions::glMapBuffer(GLenum target, GLenum access) |
| 104 | { |
| 105 | Q_D(QOpenGLExtensions); |
| 106 | Q_ASSERT(QOpenGLExtensions::isInitialized(d)); |
| 107 | GLvoid *result = d->MapBuffer(target, access); |
| 108 | Q_OPENGL_FUNCTIONS_DEBUG |
| 109 | return result; |
| 110 | } |
| 111 | |
| 112 | inline void QOpenGLExtensions::glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data) |
| 113 | { |
| 114 | Q_D(QOpenGLExtensions); |
| 115 | Q_ASSERT(QOpenGLExtensions::isInitialized(d)); |
| 116 | d->GetBufferSubData(target, offset, size, data); |
| 117 | Q_OPENGL_FUNCTIONS_DEBUG |
| 118 | } |
| 119 | |
| 120 | QT_END_NAMESPACE |
| 121 | |
| 122 | #endif // QOPENGL_EXTENSIONS_P_H |
| 123 | |