7#include <openxr/openxr.h>
8#include <openxr/openxr_platform.h>
9#include <openxr/openxr_reflection.h>
25 inline std::string
PathToString(XrInstance instance, XrPath path) {
27 CHECK_XRCMD(xrPathToString(instance, path, 0, &count,
nullptr));
30 CHECK_XRCMD(xrPathToString(instance, path, count, &count,
string.data()));
32 string.resize(count - 1);
36 inline std::vector<XrPath>
StringsToPaths(XrInstance instance,
const std::vector<std::string>& strings) {
37 std::vector<XrPath> paths;
39 for (
auto string : strings) {
47 inline std::wstring utf8_to_wide(std::string_view utf8Text) {
48 if (utf8Text.empty()) {
52 std::wstring wideText;
53 const int wideLength = ::MultiByteToWideChar(CP_UTF8, 0, utf8Text.data(), (
int)utf8Text.size(),
nullptr, 0);
54 if (wideLength == 0) {
60 wideText.resize(wideLength, 0);
61 const int length = ::MultiByteToWideChar(CP_UTF8, 0, utf8Text.data(), (
int)utf8Text.size(), wideText.data(), wideLength);
62 if (length != wideLength) {
70 inline std::string wide_to_utf8(std::wstring_view wideText) {
71 if (wideText.empty()) {
75 std::string narrowText;
76 int narrowLength = ::WideCharToMultiByte(CP_UTF8, 0, wideText.data(), (
int)wideText.size(),
nullptr, 0,
nullptr,
nullptr);
77 if (narrowLength == 0) {
83 narrowText.resize(narrowLength, 0);
85 ::WideCharToMultiByte(CP_UTF8, 0, wideText.data(), (
int)wideText.size(), narrowText.data(), narrowLength,
nullptr,
nullptr);
86 if (length != narrowLength) {
The xr::DispatchTable struct contains all available PFN pointers to xr functions including those in a...
std::vector< XrPath > StringsToPaths(XrInstance instance, const std::vector< std::string > &strings)
std::string PathToString(XrInstance instance, XrPath path)
XrPath StringToPath(XrInstance instance, const char *str)