skills/ar-vr/openxr/SKILL.md
OpenXR is an open standard API for building cross-platform AR and VR applications with hardware abstraction.
npx skillsauth add alphaonedev/openclaw-graph openxrInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
OpenXR provides a standardized API for developing AR and VR applications that work across different hardware platforms, abstracting low-level device specifics to enable cross-platform compatibility.
Use OpenXR when building AR/VR apps that must run on multiple devices (e.g., Oculus, HTC Vive, or Hololens) without rewriting code for each platform, or when you need hardware-agnostic input handling and rendering.
To use OpenXR, first initialize an instance with required extensions, then create a session for the target device, set up action maps for inputs, and enter a render loop. Always poll for events in the main loop and handle session state changes. For cross-platform builds, link against the OpenXR loader and specify the runtime via environment variables or configuration files.
Key OpenXR functions include:
xrCreateInstance: Create an instance with XrInstanceCreateInfo struct; specify extensions like "XR_KHR_vulkan_enable".
Example:
XrInstanceCreateInfo createInfo = { /* ... */ };
xrCreateInstance(&createInfo, &instance);
xrCreateSession: Start a session with a graphics binding; use XrSessionCreateInfo and bind to Vulkan via XrGraphicsBindingVulkanKHR.
Example:
XrSessionCreateInfo sessionCreateInfo = { /* ... */ };
xrCreateSession(instance, &sessionCreateInfo, &session);
xrPollEvents: Check for events like session state changes; call in your main loop with an XrEventDataBuffer.
Example:
XrEventDataBuffer eventData;
while (xrPollEvents(instance, &eventData) == XR_SUCCESS) { /* handle events */ }
Integrate OpenXR by including the OpenXR loader header and linking against libopenxr_loader. For graphics, use extension-specific bindings: for Vulkan, enable "XR_KHR_vulkan_enable" and provide a VkInstance; for OpenGL, use "XR_KHR_openGL_enable". Set the runtime path via the XR_RUNTIME_JSON environment variable (e.g., export XR_RUNTIME_JSON=/path/to/runtime.json). If authentication is needed for specific runtimes (rare), use $OPENXR_API_KEY in your environment.
Always check XrResult return codes from API calls; use XR_SUCCESS for success checks. Common errors include XR_ERROR_INITIALIZATION_FAILED (e.g., missing extensions) and XR_ERROR_SESSION_LOST (device disconnection). Handle them by logging details and attempting recovery, like recreating a session. Use xrGetInstanceProcAddr to dynamically load functions and check for NULL pointers.
Basic instance creation and session setup for a VR app:
XrInstance instance;
xrCreateInstance(...); // Initialize with required extensions
XrSession session;
xrCreateSession(instance, ...); // Bind to graphics API
Handling controller input in an AR game:
XrActionSet actionSet;
xrCreateActionSet(instance, ...); // Define actions for buttons
xrSuggestInteractionProfileBindings(...); // Bind to device paths
while (running) { xrSyncActions(session, ...); } // Poll and process inputs
tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui