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