evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::AndroidXrPlatform Class Reference

The AndroidXrPlatform class provides platform-specific implementations for OpenXR on Android devices. More...

#include <headers/evan/openxr/platform/AndroidXrPlatform.hpp>

Inheritance diagram for evan::AndroidXrPlatform:
Collaboration diagram for evan::AndroidXrPlatform:

Classes

struct  AndroidAppState
 Struct to track the current state of the Android application. This struct is used to manage the lifecycle of the Android application and ensure that the OpenXR session responds appropriately to changes in the application state, such as when the app is resumed, paused, or stopped. More...
 
struct  AndroidPlatformData
 Struct to hold Android-specific platform data for OpenXR initialization. More...
 

Public Member Functions

 AndroidXrPlatform (const AndroidPlatformData &platformData)
 Constructs an AndroidXrPlatform instance with the specified Android platform data.
 
 ~AndroidXrPlatform () override=default
 Destructor for AndroidXrPlatform.
 
std::vector< std::string > getRequiredInstanceExtensions () const override
 Retrieves the list of required OpenXR instance extensions for Android platform.
 
const XrBaseInStructure * getInstanceCreateInfo () const override
 Retrieves the Android-specific XR instance creation information.
 
- Public Member Functions inherited from evan::IXrPlatform
virtual ~IXrPlatform ()=default
 Virtual destructor.
 
bool shouldClose () const override
 Check if the OpenXR platform should close.
 
virtual std::vector< std::shared_ptr< utility::event::Event > > pollEvents (ADeviceBackend &deviceBackend) override
 Poll for OpenXR events and handle them accordingly.
 
std::shared_ptr< ADeviceBackend > createDeviceBackend () const override
 Create a device context for the OpenXR platform.
 
std::shared_ptr< ASwapchainContext > createSwapchainContext (const DeviceContext &deviceContext) const override
 Create a swapchain context for the OpenXR platform.
 
const OpenXrOptions & getOpenXrOptions () const
 Retrieves the user-configurable OpenXR options (read-only).
 
OpenXrOptions & getOpenXrOptions ()
 Retrieves the user-configurable OpenXR options (mutable).
 
- Public Member Functions inherited from evan::IPlatform
virtual ~IPlatform ()=default
 Virtual destructor.
 
virtual VkInstanceCreateFlags getInstanceCreateFlags () const
 Get platform-specific Vulkan instance creation flags.
 
virtual std::vector< std::string > getRequiredDeviceExtensions () const
 Get platform-specific required Vulkan device extensions.
 
virtual std::filesystem::path getPipelineCachePath () const
 Get the path where the Vulkan pipeline cache is persisted.
 
Error getLastError () const
 Get the last error recorded by the platform.
 

Public Attributes

AndroidAppState _appState = {}
 Tracks the current state of the Android application.
 

Protected Member Functions

std::filesystem::path getDefaultCacheRoot () const override
 Get the cache root directory of the Android application.
 
- Protected Member Functions inherited from evan::IXrPlatform
void processSessionStateChangedEvent (const XrEventDataSessionStateChanged &eventData, XrDeviceBackend &xrDeviceBackend)
 Process an OpenXR session state change event.
 

Additional Inherited Members

- Protected Attributes inherited from evan::IXrPlatform
bool _shouldClose = false
 
OpenXrOptions _options
 
- Protected Attributes inherited from evan::IPlatform
Error _lastError = Error::Ok
 Sticky error recorded by the platform while polling events.
 

Detailed Description

The AndroidXrPlatform class provides platform-specific implementations for OpenXR on Android devices.

This class implements the IXrPlatform interface to provide the necessary configurations and extensions required for creating an OpenXR instance on Android. It handles the retrieval of required instance extensions and provides the appropriate instance creation information for Android platforms.

Definition at line 26 of file AndroidXrPlatform.hpp.

Constructor & Destructor Documentation

◆ AndroidXrPlatform()

evan::AndroidXrPlatform::AndroidXrPlatform ( const AndroidPlatformData &  platformData)

Constructs an AndroidXrPlatform instance with the specified Android platform data.

Initializes the AndroidXrPlatform with the provided Android-specific data, which is necessary for creating an OpenXR instance on Android platforms.

Parameters
platformDataThe Android-specific platform data required for OpenXR initialization on Android devices.

Definition at line 132 of file AndroidXrPlatform.cpp.

◆ ~AndroidXrPlatform()

evan::AndroidXrPlatform::~AndroidXrPlatform ( )
overridedefault

Destructor for AndroidXrPlatform.

Ensures proper cleanup of resources used by the AndroidXrPlatform.

Member Function Documentation

◆ getDefaultCacheRoot()

std::filesystem::path evan::AndroidXrPlatform::getDefaultCacheRoot ( ) const
overrideprotectedvirtual

Get the cache root directory of the Android application.

Android applications may only write inside the directories the system gave them, so this method asks the Java activity for its cache directory (Context.getCacheDir()) through the Java VM stored in the platform data. This is where the Vulkan pipeline cache blob is persisted, so compiled pipelines are reused across launches.

Returns
The absolute path of the application cache directory, or an empty path when it cannot be resolved (which disables persistence).

Implements evan::IPlatform.

Definition at line 192 of file AndroidXrPlatform.cpp.

◆ getInstanceCreateInfo()

const XrBaseInStructure * evan::AndroidXrPlatform::getInstanceCreateInfo ( ) const
overridevirtual

Retrieves the Android-specific XR instance creation information.

This function returns a pointer to the platform-specific instance creation information structure used for OpenXR initialization on Android platforms.

Returns
A const pointer to the XrBaseInStructure containing Android XR instance creation parameters when compiled for Android; nullptr otherwise.
Note
This function is only functional on Android platforms. On other platforms, it returns nullptr.
See also
_instanceCreateInfoAndroid

Implements evan::IXrPlatform.

Definition at line 178 of file AndroidXrPlatform.cpp.

◆ getRequiredInstanceExtensions()

std::vector< std::string > evan::AndroidXrPlatform::getRequiredInstanceExtensions ( ) const
overridevirtual

Retrieves the list of required OpenXR instance extensions for Android platform.

This function returns a vector of extension name strings that must be enabled when creating an OpenXR instance on Android. The extensions include Vulkan2 support and Android-specific instance creation extensions.

Returns
std::vector<std::string> A vector containing the required OpenXR instance extension names for the Android platform, including:
  • XR_KHR_VULKAN_ENABLE2_EXTENSION_NAME: For Vulkan 2 graphics support
  • XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME: For Android-specific instance creation (when XR_USE_PLATFORM_ANDROID is defined)
Note
These extensions should be validated and enabled during OpenXR instance creation to ensure proper functionality on Android platforms.
See also
XrInstanceCreateInfo

Implements evan::IXrPlatform.

Definition at line 167 of file AndroidXrPlatform.cpp.

Member Data Documentation

◆ _appState

AndroidAppState evan::AndroidXrPlatform::_appState = {}

Tracks the current state of the Android application.

This variable is used to keep track of the current state of the Android application, such as whether it is in the foreground, paused, or stopped. It can be used to manage OpenXR session state and ensure that the application responds appropriately to changes in its lifecycle on Android devices.

Definition at line 175 of file AndroidXrPlatform.hpp.


The documentation for this class was generated from the following files: