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
qopenxrhelpers_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QOPENXRHELPERS_H
5#define QOPENXRHELPERS_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 <openxr/openxr.h>
20#include <QtQuick3DXr/qtquick3dxrglobal.h>
21#include <QQuaternion>
22#include <QString>
23#include <QVector3D>
24
25QT_BEGIN_NAMESPACE
26
28{
29QString getXrResultAsString(XrResult result, XrInstance instance);
30bool checkXrResult(XrResult result, XrInstance instance);
31bool resolveXrFunction(XrInstance instance, const char *name, PFN_xrVoidFunction *function);
32
33inline QQuaternion toQQuaternion(const XrQuaternionf &q)
34{
35 return { q.w, q.x, q.y, q.z };
36}
37
38inline QVector3D toQVector(const XrVector3f &v)
39{
40 return { v.x * 100, v.y * 100, v.z * 100 };
41}
42
43/*!
44 * \brief Safe call to OpenXR function
45 * \param f - OpenXR function pointer that returns a XrResult
46 * \param args - arguments for the function pointed to by f
47 * \return a XrResult indicating the result of the function call.
48 *
49 * \note This function is used to "safely" call OpenXR functions without having to check if the function pointer is nullptr.
50 * If the function pointer is nullptr XR_ERROR_FUNCTION_UNSUPPORTED is returned.
51 *
52 * \note If the function returns XR_ERROR_FUNCTION_UNSUPPORTED the caller should avoid calling the function again.
53 */
54
55template <typename T>
56[[nodiscard]] XrResult safeCall();
57template <typename... A>
58[[nodiscard]] XrResult safeCall(XrResult (XRAPI_PTR *f)(A...), A... args)
59{
61}
62
63}
64
65QT_END_NAMESPACE
66
67#endif // QOPENXRHELPERS_H
QQuaternion toQQuaternion(const XrQuaternionf &q)
bool checkXrResult(XrResult result, XrInstance instance)
bool resolveXrFunction(XrInstance instance, const char *name, PFN_xrVoidFunction *function)
XrResult safeCall(XrResult(XRAPI_PTR *f)(A...), A... args)
XrResult safeCall()
Safe call to OpenXR function.
QString getXrResultAsString(XrResult result, XrInstance instance)
QVector3D toQVector(const XrVector3f &v)