Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/openxr/src/loader/loader_init_data.hpp
9917 views
1
// Copyright (c) 2017-2025 The Khronos Group Inc.
2
// Copyright (c) 2017-2019 Valve Corporation
3
// Copyright (c) 2017-2019 LunarG, Inc.
4
//
5
// SPDX-License-Identifier: Apache-2.0 OR MIT
6
//
7
// Initial Author: Mark Young <[email protected]>
8
//
9
10
#pragma once
11
12
#include <xr_dependencies.h>
13
#include <openxr/openxr_platform.h>
14
15
#ifdef XR_USE_PLATFORM_ANDROID
16
#include <json/value.h>
17
#include <android/asset_manager_jni.h>
18
#include "android_utilities.h"
19
#endif // XR_USE_PLATFORM_ANDROID
20
21
#ifdef XR_KHR_LOADER_INIT_SUPPORT
22
23
/*!
24
* Stores a copy of the data passed to the xrInitializeLoaderKHR function in a singleton.
25
*/
26
class LoaderInitData {
27
public:
28
/*!
29
* Singleton accessor.
30
*/
31
static LoaderInitData& instance() {
32
static LoaderInitData obj;
33
return obj;
34
}
35
36
#if defined(XR_USE_PLATFORM_ANDROID)
37
/*!
38
* Type alias for the platform-specific structure type.
39
*/
40
using StructType = XrLoaderInitInfoAndroidKHR;
41
/*!
42
* Native library path.
43
*/
44
std::string _native_library_path;
45
/*!
46
* Android asset manager.
47
*/
48
AAssetManager* _android_asset_manager;
49
#else
50
#error "Platform specific XR_KHR_loader_init structure is not defined for this platform."
51
#endif
52
53
/*!
54
* Get our copy of the data, casted to pass to the runtime's matching method.
55
*/
56
const XrLoaderInitInfoBaseHeaderKHR* getParam() const { return reinterpret_cast<const XrLoaderInitInfoBaseHeaderKHR*>(&_data); }
57
58
/*!
59
* Get the data via its real structure type.
60
*/
61
const StructType& getData() const { return _data; }
62
63
/*!
64
* Has this been correctly initialized?
65
*/
66
bool initialized() const noexcept { return _initialized; }
67
68
/*!
69
* Initialize loader data - called by InitializeLoaderInitData() and thus ultimately by the loader's xrInitializeLoaderKHR
70
* implementation. Each platform that needs this extension will provide an implementation of this.
71
*/
72
XrResult initialize(const XrLoaderInitInfoBaseHeaderKHR* info);
73
74
private:
75
//! Private constructor, forces use of singleton accessor.
76
LoaderInitData() = default;
77
//! Platform-specific init data
78
StructType _data = {};
79
//! Flag for indicating whether _data is valid.
80
bool _initialized = false;
81
};
82
83
//! Initialize loader init data, where required.
84
XrResult InitializeLoaderInitData(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo);
85
86
#ifdef XR_USE_PLATFORM_ANDROID
87
XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest);
88
std::string GetAndroidNativeLibraryDir();
89
void* Android_Get_Asset_Manager();
90
#endif // XR_USE_PLATFORM_ANDROID
91
92
#endif // XR_KHR_LOADER_INIT_SUPPORT
93
94