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
25QT_BEGIN_NAMESPACE
26
27class QQuickWindow;
28class QQuickRenderControl;
29class QQuick3DNode;
30class QQuick3DViewport;
31class QQuick3DXrEyeCamera;
32class QQuick3DXrView;
33class QQuick3DXrOrigin;
34class QQuick3DXrInputManagerPrivate;
35class QRhiTexture;
36class QQuick3DXrAnimationDriver;
37
38class QQuick3DXrManagerPrivate;
39class QQuick3DXrInputManager;
40
41class QQuick3DXrManager : public QObject
42{
43 Q_OBJECT
44 Q_DECLARE_PRIVATE(QQuick3DXrManager)
45public:
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
81private Q_SLOTS:
82 void update();
83 void processSpatialEvents(const QJsonObject &events);
84
85Q_SIGNALS:
86 void initialized();
87 void sessionEnded();
88 void xrOriginChanged();
89 void frameReady();
90 void referenceSpaceChanged();
91 void multiViewRenderingEnabledChanged();
92
93protected:
94 bool event(QEvent *e) override;
95
96private:
97 friend class QQuick3DXrRuntimeInfo;
98 friend class QQuick3DXrView;
99
100 QQuick3DXrInputManager *getInputManager() const;
101
102 bool setupGraphics();
103
104 void processXrEvents();
105 void renderFrame();
106
107 void preSetupQuickScene();
108 bool setupQuickScene();
109
110 bool supportsPassthrough() const;
111
112 QQuickWindow *m_quickWindow = nullptr;
113 QQuickRenderControl *m_renderControl = nullptr;
114 QQuick3DViewport *m_vrViewport = nullptr;
115 QQuick3DXrOrigin *m_xrOrigin = nullptr;
116 QQuick3DXrAnimationDriver *m_animationDriver = nullptr;
117 bool m_xrOriginWarningShown = false;
118
119 std::unique_ptr<QQuick3DXrManagerPrivate> d_ptr;
120};
121
122QT_END_NAMESPACE
123
124#endif // QQUICK3DXRMANAGER_P_H
125

source code of qtquick3d/src/xr/quick3dxr/qquick3dxrmanager_p.h