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.cpp
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// Qt-Security score:significant reason:default
4
5
7#include <QDebug>
8
10
11QString OpenXRHelpers::getXrResultAsString(XrResult result, XrInstance instance)
12{
13 QByteArray errorString(XR_MAX_RESULT_STRING_SIZE, 0);
14 xrResultToString(instance, result, errorString.data());
15 errorString.resize(qstrlen(errorString.constData()));
16 return QString::fromUtf8(errorString).trimmed();
17}
18
19bool OpenXRHelpers::checkXrResult(XrResult result, XrInstance instance)
20{
21 if (result != XrResult::XR_SUCCESS) {
22 qWarning().noquote().nospace() << "OpenXR call failed (" << result << "): " << getXrResultAsString(result, instance);
23 return false;
24 }
25 return true;
26}
27
28bool OpenXRHelpers::resolveXrFunction(XrInstance instance, const char *name, PFN_xrVoidFunction *function)
29{
30 XrResult result = xrGetInstanceProcAddr(instance, name, function);
31 if (!checkXrResult(result, instance)) {
32 qWarning("Failed to resolve OpenXR function %s", name);
33 *function = nullptr;
34 return false;
35 }
36 return true;
37}
38
39QT_END_NAMESPACE
bool checkXrResult(XrResult result, XrInstance instance)
bool resolveXrFunction(XrInstance instance, const char *name, PFN_xrVoidFunction *function)
Combined button and popup list for selecting options.