1 | // Copyright (C) 2024 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QOPENXRGRAPHICSOPENGL_H |
5 | #define QOPENXRGRAPHICSOPENGL_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 | |
19 | #include <QtQuick3DXr/private/qabstractopenxrgraphics_p.h> |
20 | #include <QtQuick3DXr/private/qopenxrplatform_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class QRhiTexture; |
25 | |
26 | class QOpenXRGraphicsOpenGL : public QAbstractOpenXRGraphics |
27 | { |
28 | public: |
29 | QOpenXRGraphicsOpenGL(); |
30 | |
31 | bool isExtensionSupported(const QVector<XrExtensionProperties> &extensions) const override; |
32 | const char *extensionName() const override; |
33 | const XrBaseInStructure *handle() const override; |
34 | bool setupGraphics(const XrInstance &instance, XrSystemId &systemId, const QQuickGraphicsConfiguration &quickConfig) override; |
35 | bool finializeGraphics(QRhi *rhi) override; |
36 | int64_t colorSwapchainFormat(const QVector<int64_t> &swapchainFormats) const override; |
37 | int64_t depthSwapchainFormat(const QVector<int64_t> &swapchainFormats) const override; |
38 | QVector<XrSwapchainImageBaseHeader*> allocateSwapchainImages(int count, XrSwapchain swapchain) override; |
39 | QQuickRenderTarget (const XrSwapchainSubImage &subImage, const XrSwapchainImageBaseHeader *swapchainImage, |
40 | quint64 swapchainFormat, int samples, int arraySize, |
41 | const XrSwapchainImageBaseHeader *depthSwapchainImage, quint64 depthSwapchainFormat) const override; |
42 | void setupWindow(QQuickWindow *window) override; |
43 | QRhi *rhi() const override { return m_rhi; } |
44 | void releaseResources() override; |
45 | |
46 | private: |
47 | #ifdef XR_USE_PLATFORM_WIN32 |
48 | XrGraphicsBindingOpenGLWin32KHR m_graphicsBinding{}; |
49 | #elif defined(XR_USE_PLATFORM_XLIB) |
50 | XrGraphicsBindingOpenGLXlibKHR m_graphicsBinding{}; |
51 | #elif defined(XR_USE_PLATFORM_XCB) |
52 | XrGraphicsBindingOpenGLXcbKHR m_graphicsBinding{}; |
53 | #elif defined(XR_USE_PLATFORM_WAYLAND) |
54 | XrGraphicsBindingOpenGLWaylandKHR m_graphicsBinding{}; |
55 | #else |
56 | XrBaseInStructure m_graphicsBinding{}; // just so that the code compiles |
57 | #endif |
58 | QMap<XrSwapchain, QVector<XrSwapchainImageOpenGLKHR>> m_swapchainImageBuffer; |
59 | |
60 | XrGraphicsRequirementsOpenGLKHR m_graphicsRequirements{}; |
61 | QWindow *m_window = nullptr; |
62 | QRhi *m_rhi = nullptr; |
63 | mutable QRhiTexture *m_depthTexture = nullptr; |
64 | }; |
65 | |
66 | QT_END_NAMESPACE |
67 | |
68 | #endif // QOPENXRGRAPHICSOPENGL_H |
69 | |