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
21QT_BEGIN_NAMESPACE
22
23class QOpenGLExtensionsPrivate;
24
25class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLExtraFunctions
26{
27 Q_DECLARE_PRIVATE(QOpenGLExtensions)
28public:
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 };
64 Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension)
65
66 OpenGLExtensions openGLExtensions();
67 bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const;
68
69 GLvoid *glMapBuffer(GLenum target, GLenum access);
70 void glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data);
71 void glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
72
73 void flushShared();
74
75 QOpenGLExtensionsPrivate *d() const;
76
77private:
78 static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != nullptr; }
79};
80
81Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLExtensions::OpenGLExtensions)
82
83class QOpenGLExtensionsPrivate : public QOpenGLExtraFunctionsPrivate
84{
85public:
86 explicit QOpenGLExtensionsPrivate(QOpenGLContext *ctx);
87
88 GLvoid* (QOPENGLF_APIENTRYP MapBuffer)(GLenum target, GLenum access);
89 void (QOPENGLF_APIENTRYP GetBufferSubData)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data);
90 void (QOPENGLF_APIENTRYP DiscardFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum *attachments);
91
92 bool flushVendorChecked;
93 bool flushIsSufficientToSyncContexts;
94};
95
96inline QOpenGLExtensionsPrivate *QOpenGLExtensions::d() const
97{
98 return static_cast<QOpenGLExtensionsPrivate *>(d_ptr);
99}
100
101inline GLvoid *QOpenGLExtensions::glMapBuffer(GLenum target, GLenum access)
102{
103 Q_D(QOpenGLExtensions);
104 Q_ASSERT(QOpenGLExtensions::isInitialized(d));
105 GLvoid *result = d->MapBuffer(target, access);
106 Q_OPENGL_FUNCTIONS_DEBUG
107 return result;
108}
109
110inline void QOpenGLExtensions::glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data)
111{
112 Q_D(QOpenGLExtensions);
113 Q_ASSERT(QOpenGLExtensions::isInitialized(d));
114 d->GetBufferSubData(target, offset, size, data);
115 Q_OPENGL_FUNCTIONS_DEBUG
116}
117
118
119inline void QOpenGLExtensions::glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments)
120{
121 Q_D(QOpenGLExtensions);
122 Q_ASSERT(QOpenGLExtensions::isInitialized(d));
123 d->DiscardFramebuffer(target,numAttachments, attachments);
124 Q_OPENGL_FUNCTIONS_DEBUG
125}
126QT_END_NAMESPACE
127
128#endif // QOPENGL_EXTENSIONS_P_H
129

source code of qtbase/src/gui/opengl/qopenglextensions_p.h