Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmultimedia_gl_support_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QMULTIMEDIA_GL_SUPPORT_P_H
5#define QMULTIMEDIA_GL_SUPPORT_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 purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/private/qtmultimediaglobal_p.h>
19#include <QtGui/qopengl.h>
20#include <QtGui/qopenglextrafunctions.h>
21#include <QtGui/qopenglcontext.h>
22#include <QtCore/private/quniquehandle_p.h>
23#include <QtCore/qstring.h>
24
25// thanks X.h
26#pragma push_macro("Success")
27#ifdef Success
28# undef Success
29#endif
30
31#pragma push_macro("BadAccess")
32#ifdef BadAccess
33# undef BadAccess
34#endif
35
36#pragma push_macro("BadAlloc")
37#ifdef BadAlloc
38# undef BadAlloc
39#endif
40
41#pragma push_macro("BadMatch")
42#ifdef BadMatch
43# undef BadMatch
44#endif
45
46#if QT_CONFIG(egl)
47typedef void *EGLDisplay;
48typedef void *EGLImage;
49#endif
50
51QT_BEGIN_NAMESPACE
52
53class QDebug;
54class QRhi;
55
56namespace QtMultimediaPrivate {
57
58// Error codes returned by glGetError(), see
59// https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGetError.xhtml
60enum class GLError : unsigned int {
62 InvalidEnum = 0x0500,
63 InvalidValue = 0x0501,
65 StackOverflow = 0x0503,
67 OutOfMemory = 0x0505,
69};
70
71Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug debug, GLError error);
72
73template <typename Fn>
74Fn resolveGlFunction(QOpenGLContext *context, const char *fn)
75{
76 Q_ASSERT(context);
77 return reinterpret_cast<Fn>(context->getProcAddress(fn));
78}
79
80inline void clearGlErrors(QOpenGLExtraFunctions *f)
81{
82 while (GLError(f->glGetError()) != GLError::NoError) { }
83}
84
85inline void clearGlErrors(QOpenGLContext *context)
86{
87 clearGlErrors(context->extraFunctions());
88}
89
90#if QT_CONFIG(egl)
91
92// Error codes returned by eglGetError(), see
93// https://registry.khronos.org/EGL/sdk/docs/man/html/eglGetError.xhtml
94enum class EGLError : int {
95 Success = 0x3000,
96 NotInitialized = 0x3001,
97 BadAccess = 0x3002,
98 BadAlloc = 0x3003,
99 BadAttribute = 0x3004,
100 BadConfig = 0x3005,
101 BadContext = 0x3006,
102 BadCurrentSurface = 0x3007,
103 BadDisplay = 0x3008,
104 BadMatch = 0x3009,
105 BadNativePixmap = 0x300A,
106 BadNativeWindow = 0x300B,
107 BadParameter = 0x300C,
108 BadSurface = 0x300D,
109 ContextLost = 0x300E,
110};
111
113
115
116///////////////////////////////////////////////////////////////////////////////
117// (e)gl handle types
118
120{
121public:
122 EglImageDeleter() = default;
124 void operator()(EGLImage image) const noexcept;
125
126private:
127 EGLDisplay m_display = {}; // EGL_NO_DISPLAY;
128};
129
131{
132 using Type = EGLImage;
133 static Type invalidValue() { return nullptr; } // EGL_NO_IMAGE;
134};
136
137#endif // QT_CONFIG(egl)
138
139class Q_MULTIMEDIA_EXPORT GlTextureDeleter
140{
141public:
142 GlTextureDeleter() = default;
144 void operator()(GLuint texture) const noexcept;
145
146private:
147 QOpenGLContext *m_context = nullptr;
148};
149
151{
152 using Type = GLuint;
153 static Type invalidValue() { return 0; }
154};
156
157} // namespace QtMultimediaPrivate
158
159QT_END_NAMESPACE
160
161#pragma pop_macro("Success")
162#pragma pop_macro("BadAccess")
163#pragma pop_macro("BadAlloc")
164#pragma pop_macro("BadMatch")
165
166#endif
Combined button and popup list for selecting options.
static QString toString(GLError error)
void clearGlErrors(QOpenGLExtraFunctions *f)
Fn resolveGlFunction(QOpenGLContext *context, const char *fn)