| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICK3DXRMANAGER_P_H |
| 5 | #define QQUICK3DXRMANAGER_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 <QtQuick3DXr/private/qtquick3dxrglobal_p.h> |
| 19 | |
| 20 | #include <QtCore/QObject> |
| 21 | #include <QtCore/QVersionNumber> |
| 22 | #include <QtQml/QQmlEngine> |
| 23 | #include <QtQml/QQmlComponent> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QQuickWindow; |
| 28 | class QQuickRenderControl; |
| 29 | class QQuick3DNode; |
| 30 | class QQuick3DViewport; |
| 31 | class QQuick3DXrEyeCamera; |
| 32 | class QQuick3DXrView; |
| 33 | class QQuick3DXrOrigin; |
| 34 | class QQuick3DXrInputManagerPrivate; |
| 35 | class QRhiTexture; |
| 36 | class QQuick3DXrAnimationDriver; |
| 37 | |
| 38 | class QQuick3DXrManagerPrivate; |
| 39 | class QQuick3DXrInputManager; |
| 40 | |
| 41 | class QQuick3DXrManager : public QObject |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | Q_DECLARE_PRIVATE(QQuick3DXrManager) |
| 45 | public: |
| 46 | explicit QQuick3DXrManager(QObject *parent = nullptr); |
| 47 | ~QQuick3DXrManager(); |
| 48 | |
| 49 | bool isReady() const; |
| 50 | |
| 51 | bool initialize(); |
| 52 | void teardown(); |
| 53 | |
| 54 | bool isValid() const; |
| 55 | |
| 56 | void setPassthroughEnabled(bool enabled); |
| 57 | bool isPassthroughEnabled() const; |
| 58 | |
| 59 | QtQuick3DXr::FoveationLevel getFixedFoveationLevel() const; |
| 60 | void setFixedFoveationLevel(QtQuick3DXr::FoveationLevel level); |
| 61 | |
| 62 | QtQuick3DXr::ReferenceSpace getReferenceSpace() const; |
| 63 | void setReferenceSpace(QtQuick3DXr::ReferenceSpace newReferenceSpace); |
| 64 | |
| 65 | bool isDepthSubmissionEnabled() const; |
| 66 | void setDepthSubmissionEnabled(bool enable); |
| 67 | |
| 68 | QString errorString() const; |
| 69 | |
| 70 | void setSamples(int samples); |
| 71 | |
| 72 | void setMultiViewRenderingEnabled(bool enable); |
| 73 | bool isMultiViewRenderingEnabled() const; |
| 74 | bool isMultiViewRenderingSupported() const; |
| 75 | static bool isMultiviewRenderingDisabled(); |
| 76 | |
| 77 | void setXROrigin(QQuick3DXrOrigin *origin); |
| 78 | |
| 79 | void getDefaultClipDistances(float &nearClip, float &farClip) const; |
| 80 | |
| 81 | private Q_SLOTS: |
| 82 | void update(); |
| 83 | |
| 84 | Q_SIGNALS: |
| 85 | void initialized(); |
| 86 | void sessionEnded(); |
| 87 | void xrOriginChanged(); |
| 88 | void frameReady(); |
| 89 | void referenceSpaceChanged(); |
| 90 | void multiViewRenderingEnabledChanged(); |
| 91 | |
| 92 | protected: |
| 93 | bool event(QEvent *e) override; |
| 94 | |
| 95 | private: |
| 96 | friend class QQuick3DXrRuntimeInfo; |
| 97 | friend class QQuick3DXrView; |
| 98 | |
| 99 | QQuick3DXrInputManager *getInputManager() const; |
| 100 | |
| 101 | bool setupGraphics(); |
| 102 | |
| 103 | void processXrEvents(); |
| 104 | void renderFrame(); |
| 105 | |
| 106 | void preSetupQuickScene(); |
| 107 | bool setupQuickScene(); |
| 108 | |
| 109 | bool supportsPassthrough() const; |
| 110 | |
| 111 | QQuickWindow *m_quickWindow = nullptr; |
| 112 | QQuickRenderControl *m_renderControl = nullptr; |
| 113 | QQuick3DViewport *m_vrViewport = nullptr; |
| 114 | QQuick3DXrOrigin *m_xrOrigin = nullptr; |
| 115 | QQuick3DXrAnimationDriver *m_animationDriver = nullptr; |
| 116 | bool m_xrOriginWarningShown = false; |
| 117 | |
| 118 | std::unique_ptr<QQuick3DXrManagerPrivate> d_ptr; |
| 119 | }; |
| 120 | |
| 121 | QT_END_NAMESPACE |
| 122 | |
| 123 | #endif // QQUICK3DXRMANAGER_P_H |
| 124 | |