OPENXR Scol plugin
platform.cpp
1#include "sOpenXR.h"
2
3#define UNUSED_PARM(x) \
4 { (void)(x); }
5
6//Platforms descriptions
7
8#ifdef XR_USE_PLATFORM_WIN32
9struct Win32Platform : public IPlatform {
10 Win32Platform() { }
11 virtual ~Win32Platform() override { }
12 std::vector<std::string> GetInstanceExtensions() const override { return {}; }
13 XrBaseInStructure* GetInstanceCreateExtension() const override { return XR_NULL_HANDLE; }
14};
15std::shared_ptr<IPlatform> CreatePlatform_Win32()
16{
17 return std::make_shared<Win32Platform>();
18}
19#endif
20
21#ifdef XR_USE_PLATFORM_ANDROID
22
23struct AndroidPlatform : public IPlatform {
24 AndroidPlatform(const std::shared_ptr<PlatformData>& data)
25 {
26 instanceCreateInfoAndroid = { XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR };
27 instanceCreateInfoAndroid.applicationVM = data->applicationVM;
28 instanceCreateInfoAndroid.applicationActivity = data->applicationActivity;
29 }
30
31 std::vector<std::string> GetInstanceExtensions() const override { return { XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME }; }
32 XrBaseInStructure* GetInstanceCreateExtension() const override { return (XrBaseInStructure*)&instanceCreateInfoAndroid; }
33
34 XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid;
35};
36
37std::shared_ptr<IPlatform> CreatePlatform_Android(const std::shared_ptr<PlatformData>& data)
38{
39 return std::make_shared<AndroidPlatform>(data);
40}
41#endif
42
43std::shared_ptr<IPlatform> CreatePlatform(const std::shared_ptr<PlatformData>& data)
44{
45#if !defined(XR_USE_PLATFORM_ANDROID)
46 UNUSED_PARM(data);
47#endif
48
49#if defined(XR_USE_PLATFORM_WIN32)
50 return CreatePlatform_Win32();
51#elif defined(XR_USE_PLATFORM_ANDROID)
52 return CreatePlatform_Android(data);
53 /*
54#elif defined(XR_USE_PLATFORM_XLIB)
55 return CreatePlatform_Xlib();
56#elif defined(XR_USE_PLATFORM_XCB)
57 return CreatePlatform_Xcb();
58#elif defined(XR_USE_PLATFORM_WAYLAND)
59 return CreatePlatform_Wayland();
60 */
61#else
62#error Unsupported platform or no XR platform defined!
63#endif
64}