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 QGLXINTEGRATION_H |
5 | #define QGLXINTEGRATION_H |
6 | |
7 | #include "qxcbwindow.h" |
8 | #include "qxcbscreen.h" |
9 | |
10 | #include <qpa/qplatformopenglcontext.h> |
11 | #include <qpa/qplatformoffscreensurface.h> |
12 | #include <QtGui/QSurfaceFormat> |
13 | |
14 | #include <QtCore/QMutex> |
15 | |
16 | #include <GL/glx.h> |
17 | |
18 | QT_BEGIN_NAMESPACE |
19 | |
20 | class QGLXContext : public QPlatformOpenGLContext, |
21 | public QNativeInterface::QGLXContext |
22 | { |
23 | public: |
24 | QGLXContext(Display *display, QXcbScreen *screen, const QSurfaceFormat &format, QPlatformOpenGLContext *share); |
25 | QGLXContext(Display *display, GLXContext context, void *visualInfo, QPlatformOpenGLContext *share); |
26 | ~QGLXContext(); |
27 | |
28 | bool makeCurrent(QPlatformSurface *surface) override; |
29 | void doneCurrent() override; |
30 | void swapBuffers(QPlatformSurface *surface) override; |
31 | QFunctionPointer getProcAddress(const char *procName) override; |
32 | |
33 | QSurfaceFormat format() const override; |
34 | bool isSharing() const override; |
35 | bool isValid() const override; |
36 | |
37 | GLXContext nativeContext() const override { return glxContext(); } |
38 | |
39 | GLXContext glxContext() const { return m_context; } |
40 | GLXFBConfig glxConfig() const { return m_config; } |
41 | |
42 | static bool supportsThreading(); |
43 | static void queryDummyContext(); |
44 | |
45 | private: |
46 | Display *m_display = nullptr; |
47 | GLXFBConfig m_config = nullptr; |
48 | GLXContext m_context = nullptr; |
49 | GLXContext m_shareContext = nullptr; |
50 | QSurfaceFormat m_format; |
51 | bool m_isPBufferCurrent = false; |
52 | bool m_ownsContext = false; |
53 | GLenum (APIENTRY * m_getGraphicsResetStatus)() = nullptr; |
54 | bool m_lost = false; |
55 | static bool m_queriedDummyContext; |
56 | static bool m_supportsThreading; |
57 | }; |
58 | |
59 | |
60 | class QGLXPbuffer : public QPlatformOffscreenSurface |
61 | { |
62 | public: |
63 | explicit QGLXPbuffer(QOffscreenSurface *offscreenSurface); |
64 | ~QGLXPbuffer(); |
65 | |
66 | QSurfaceFormat format() const override { return m_format; } |
67 | bool isValid() const override { return m_pbuffer != 0; } |
68 | |
69 | GLXPbuffer pbuffer() const { return m_pbuffer; } |
70 | |
71 | private: |
72 | QXcbScreen *m_screen; |
73 | QSurfaceFormat m_format; |
74 | Display *m_display; |
75 | GLXPbuffer m_pbuffer; |
76 | }; |
77 | |
78 | QT_END_NAMESPACE |
79 | |
80 | #endif |
81 |