evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::IXrPlatform Class Referenceabstract

OpenXR platform implementation. More...

#include <headers/evan/openxr/IXrPlatform.hpp>

Inheritance diagram for evan::IXrPlatform:
Collaboration diagram for evan::IXrPlatform:

Public Member Functions

virtual ~IXrPlatform ()=default
 Virtual destructor.
 
virtual std::vector< std::string > getRequiredInstanceExtensions () const override=0
 Get the required instance extensions for the OpenXR platform.
 
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.
 
virtual const XrBaseInStructure * getInstanceCreateInfo () const =0
 Retrieves the Android-specific instance creation information.
 
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.
 

Protected Member Functions

void processSessionStateChangedEvent (const XrEventDataSessionStateChanged &eventData, XrDeviceBackend &xrDeviceBackend)
 Process an OpenXR session state change event.
 
- Protected Member Functions inherited from evan::IPlatform
virtual std::filesystem::path getDefaultCacheRoot () const =0
 Get the platform-specific cache root directory.
 

Protected Attributes

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

OpenXR platform implementation.

This class provides an implementation of the IPlatform interface for OpenXR. It handles platform-specific functionality related to OpenXR.

Definition at line 26 of file IXrPlatform.hpp.

Constructor & Destructor Documentation

◆ ~IXrPlatform()

virtual evan::IXrPlatform::~IXrPlatform ( )
virtualdefault

Virtual destructor.

Ensures proper cleanup of derived class resources.

Member Function Documentation

◆ createDeviceBackend()

std::shared_ptr< evan::ADeviceBackend > evan::IXrPlatform::createDeviceBackend ( ) const
overridevirtual

Create a device context for the OpenXR platform.

This function creates and returns a shared pointer to a DeviceContext that is compatible with the OpenXR platform. The created device context should be initialized with the necessary resources and configurations required for rendering and interacting with the OpenXR runtime.

Returns
A shared pointer to the created DeviceContext for the OpenXR platform.

Implements evan::IPlatform.

Definition at line 66 of file IXrPlatform.cpp.

◆ createSwapchainContext()

std::shared_ptr< evan::ASwapchainContext > evan::IXrPlatform::createSwapchainContext ( const DeviceContext &  deviceContext) const
overridevirtual

Create a swapchain context for the OpenXR platform.

This function creates and returns a shared pointer to an ASwapchainContext that is compatible with the OpenXR platform. The created swapchain context should be initialized with the necessary resources and configurations required for rendering to the OpenXR runtime's swapchain.

Parameters
deviceContextA reference to the DeviceContext that may be used for initializing the swapchain context with the appropriate device resources.
Returns
A shared pointer to the created ASwapchainContext for the OpenXR platform.

Implements evan::IPlatform.

Definition at line 72 of file IXrPlatform.cpp.

◆ getInstanceCreateInfo()

virtual const XrBaseInStructure * evan::IXrPlatform::getInstanceCreateInfo ( ) const
pure virtual

Retrieves the Android-specific instance creation information.

This function returns a pointer to the Android-specific instance creation structure, cast to a generic XrBaseInStructure pointer. This is typically used when creating an OpenXR instance on an Android platform.

Returns
A pointer to the Android-specific instance creation information as an XrBaseInStructure.

Implemented in evan::AndroidXrPlatform, and evan::LinuxXrPlatform.

◆ getOpenXrOptions() [1/2]

OpenXrOptions & evan::IXrPlatform::getOpenXrOptions ( )
inline

Retrieves the user-configurable OpenXR options (mutable).

Applications may configure options through the concrete platform before handing it to the engine. Subclasses may also override the defaults in their constructors.

Returns
A mutable reference to the OpenXR options owned by this platform.

Definition at line 155 of file IXrPlatform.hpp.

◆ getOpenXrOptions() [2/2]

const OpenXrOptions & evan::IXrPlatform::getOpenXrOptions ( ) const
inline

Retrieves the user-configurable OpenXR options (read-only).

Returns
A const reference to the OpenXR options owned by this platform.

Definition at line 140 of file IXrPlatform.hpp.

◆ getRequiredInstanceExtensions()

virtual std::vector< std::string > evan::IXrPlatform::getRequiredInstanceExtensions ( ) const
overridepure virtual

Get the required instance extensions for the OpenXR platform.

This function returns a vector of strings representing the required instance extensions for the OpenXR platform. These extensions are necessary for proper functionality and compatibility with the OpenXR runtime on the target platform.

Returns
A vector of strings containing the required instance extensions for the OpenXR platform.

Implements evan::IPlatform.

Implemented in evan::AndroidXrPlatform, and evan::LinuxXrPlatform.

◆ pollEvents()

std::vector< std::shared_ptr< utility::event::Event > > evan::IXrPlatform::pollEvents ( ADeviceBackend &  deviceBackend)
overridevirtual

Poll for OpenXR events and handle them accordingly.

This function polls for events from the OpenXR runtime and processes them. It handles events such as session state changes, input events, and other relevant OpenXR events. The function may update internal state based on the events received, such as setting the shouldClose flag when a session state change indicates that the application should exit.

Parameters
deviceBackendA reference to the ADeviceBackend, which may be used for handling device-specific operations related to the events being processed.
Note
This function should be called regularly in the main application loop to ensure that events are processed in a timely manner.
Returns
A vector of shared pointers to Event objects representing the events that were polled from the OpenXR platform. Each Event object contains information about the type of event, such as input events.

Implements evan::IPlatform.

Definition at line 23 of file IXrPlatform.cpp.

◆ processSessionStateChangedEvent()

void evan::IXrPlatform::processSessionStateChangedEvent ( const XrEventDataSessionStateChanged &  eventData,
evan::XrDeviceBackend &  xrDeviceBackend 
)
protected

Process an OpenXR session state change event.

This function handles the XrEventDataSessionStateChanged event, updating the internal state of the XrPlatform based on the new session state. It may set flags such as shouldClose or sessionRunning based on the session state received in the event data.

Parameters
eventDataThe event data containing information about the session state change.
xrDeviceBackendThe OpenXR device backend associated with the event.
Note
This function is typically called from within the pollEvents method when a session state change event is received. It is responsible for ensuring that the XrPlatform responds appropriately to changes in the OpenXR session state.

Definition at line 95 of file IXrPlatform.cpp.

◆ shouldClose()

bool evan::IXrPlatform::shouldClose ( ) const
overridevirtual

Check if the OpenXR platform should close.

This function checks the internal state of the XrPlatform to determine if it should close. This is typically based on events such as session state changes or user input that indicates the application should exit.

Returns
true if the platform should close, false otherwise.

Implements evan::IPlatform.

Definition at line 17 of file IXrPlatform.cpp.

Member Data Documentation

◆ _options

OpenXrOptions evan::IXrPlatform::_options
protected

User-configurable OpenXR options applied by the device backend and swapchain context created from this platform.

Definition at line 194 of file IXrPlatform.hpp.

◆ _shouldClose

bool evan::IXrPlatform::_shouldClose = false
protected

Flag to indicate if the platform should close.

OpenXR specific.

Definition at line 188 of file IXrPlatform.hpp.


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