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 QOPENGL_EXTENSIONS_P_H
41#define QOPENGL_EXTENSIONS_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists for the convenience
48// of the Qt OpenGL classes. This header file may change from
49// version to version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtGui/private/qtguiglobal_p.h>
55#include "qopenglextrafunctions.h"
56
57QT_BEGIN_NAMESPACE
58
59class QOpenGLExtensionsPrivate;
60
61class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLExtraFunctions
62{
63 Q_DECLARE_PRIVATE(QOpenGLExtensions)
64public:
65 QOpenGLExtensions();
66 QOpenGLExtensions(QOpenGLContext *context);
67 ~QOpenGLExtensions() {}
68
69 enum OpenGLExtension {
70 TextureRectangle = 0x00000001,
71 GenerateMipmap = 0x00000002,
72 TextureCompression = 0x00000004,
73 MirroredRepeat = 0x00000008,
74 FramebufferMultisample = 0x00000010,
75 StencilTwoSide = 0x00000020,
76 StencilWrap = 0x00000040,
77 PackedDepthStencil = 0x00000080,
78 NVFloatBuffer = 0x00000100,
79 PixelBufferObject = 0x00000200,
80 FramebufferBlit = 0x00000400,
81 BGRATextureFormat = 0x00000800,
82 DDSTextureCompression = 0x00001000,
83 ETC1TextureCompression = 0x00002000,
84 PVRTCTextureCompression = 0x00004000,
85 ElementIndexUint = 0x00008000,
86 Depth24 = 0x00010000,
87 SRGBFrameBuffer = 0x00020000,
88 MapBuffer = 0x00040000,
89 GeometryShaders = 0x00080000,
90 MapBufferRange = 0x00100000,
91 Sized8Formats = 0x00200000,
92 DiscardFramebuffer = 0x00400000,
93 Sized16Formats = 0x00800000,
94 TextureSwizzle = 0x01000000,
95 StandardDerivatives = 0x02000000,
96 };
97 Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension)
98
99 OpenGLExtensions openGLExtensions();
100 bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const;
101
102 GLvoid *glMapBuffer(GLenum target, GLenum access);
103 void glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data);
104 void glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
105
106 void flushShared();
107
108 QOpenGLExtensionsPrivate *d() const;
109
110private:
111 static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != nullptr; }
112};
113
114Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLExtensions::OpenGLExtensions)
115
116class QOpenGLExtensionsPrivate : public QOpenGLExtraFunctionsPrivate
117{
118public:
119 explicit QOpenGLExtensionsPrivate(QOpenGLContext *ctx);
120
121 GLvoid* (QOPENGLF_APIENTRYP MapBuffer)(GLenum target, GLenum access);
122 void (QOPENGLF_APIENTRYP GetBufferSubData)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data);
123 void (QOPENGLF_APIENTRYP DiscardFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum *attachments);
124
125 bool flushVendorChecked;
126 bool flushIsSufficientToSyncContexts;
127};
128
129inline QOpenGLExtensionsPrivate *QOpenGLExtensions::d() const
130{
131 return static_cast<QOpenGLExtensionsPrivate *>(d_ptr);
132}
133
134inline GLvoid *QOpenGLExtensions::glMapBuffer(GLenum target, GLenum access)
135{
136 Q_D(QOpenGLExtensions);
137 Q_ASSERT(QOpenGLExtensions::isInitialized(d));
138 GLvoid *result = d->MapBuffer(target, access);
139 Q_OPENGL_FUNCTIONS_DEBUG
140 return result;
141}
142
143inline void QOpenGLExtensions::glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data)
144{
145 Q_D(QOpenGLExtensions);
146 Q_ASSERT(QOpenGLExtensions::isInitialized(d));
147 d->GetBufferSubData(target, offset, size, data);
148 Q_OPENGL_FUNCTIONS_DEBUG
149}
150
151
152inline void QOpenGLExtensions::glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments)
153{
154 Q_D(QOpenGLExtensions);
155 Q_ASSERT(QOpenGLExtensions::isInitialized(d));
156 d->DiscardFramebuffer(target,numAttachments, attachments);
157 Q_OPENGL_FUNCTIONS_DEBUG
158}
159QT_END_NAMESPACE
160
161#endif // QOPENGL_EXTENSIONS_P_H
162