VTK  9.7.1
Classes | Macros | Typedefs | Enumerations | Functions
vtkWebXR.h File Reference

Minimal WebXR Device API wrapper. More...

#include "vtkABINamespace.h"
Include dependency graph for vtkWebXR.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  WebXRRigidTransform
 WebXR rigid transform. More...
 
struct  WebXRView
 WebXR view. More...
 
struct  WebXRInputSource
 
struct  WebXRGamepadButton
 
struct  WebXRGamepad
 WebXR Gamepad see https://www.w3.org/TR/2024/WD-webxr-gamepads-module-1-20240409/#xr-standard-heading. More...
 

Macros

#define webxr_init   VTK_ABI_NAMESPACE_MANGLE(webxr_init)
 
#define webxr_is_session_supported   VTK_ABI_NAMESPACE_MANGLE(webxr_is_session_supported)
 
#define webxr_request_session   VTK_ABI_NAMESPACE_MANGLE(webxr_request_session)
 
#define webxr_request_exit   VTK_ABI_NAMESPACE_MANGLE(webxr_request_exit)
 
#define webxr_get_viewer_pose   VTK_ABI_NAMESPACE_MANGLE(webxr_get_viewer_pose)
 
#define webxr_get_views   VTK_ABI_NAMESPACE_MANGLE(webxr_get_views)
 
#define webxr_get_framebuffer_size   VTK_ABI_NAMESPACE_MANGLE(webxr_get_framebuffer_size)
 
#define webxr_get_framebuffer   VTK_ABI_NAMESPACE_MANGLE(webxr_get_framebuffer)
 
#define webxr_get_input_sources   VTK_ABI_NAMESPACE_MANGLE(webxr_get_input_sources)
 
#define webxr_get_input_pose   VTK_ABI_NAMESPACE_MANGLE(webxr_get_input_pose)
 
#define webxr_get_input_gamepad   VTK_ABI_NAMESPACE_MANGLE(webxr_get_input_gamepad)
 
#define WEBXR_SESSION_FEATURE_LOCAL   0x01
 WebXR 'XRSessionFeatures'. More...
 
#define WEBXR_SESSION_FEATURE_LOCAL_FLOOR   0x02
 
#define WEBXR_SESSION_FEATURE_BOUNDED_FLOOR   0x04
 
#define WEBXR_SESSION_FEATURE_UNBOUNDED   0x08
 
#define WEBXR_SESSION_FEATURE_HIT_TEST   0x10
 

Typedefs

typedef struct WebXRRigidTransform WebXRRigidTransform
 WebXR rigid transform. More...
 
typedef struct WebXRView WebXRView
 WebXR view. More...
 
typedef struct WebXRInputSource WebXRInputSource
 
typedef struct WebXRGamepadButton WebXRGamepadButton
 
typedef struct WebXRGamepad WebXRGamepad
 WebXR Gamepad see https://www.w3.org/TR/2024/WD-webxr-gamepads-module-1-20240409/#xr-standard-heading. More...
 
typedef void(* webxr_error_callback_func) (void *userData, int error)
 Callback for errors. More...
 
typedef void(* webxr_frame_callback_func) (void *userData, int time)
 Callback for frame rendering. More...
 
typedef void(* webxr_session_callback_func) (void *userData, int mode)
 Callback for VR session start. More...
 
typedef void(* webxr_session_supported_callback_func) (int mode, int supported)
 Callback for webxr_is_session_supported. More...
 

Enumerations

enum  WebXRError { WEBXR_ERR_API_UNSUPPORTED = -2, WEBXR_ERR_GL_INCAPABLE = -3, WEBXR_ERR_SESSION_UNSUPPORTED = -4 }
 Errors enum. More...
 
enum  WebXRHandedness { WEBXR_HANDEDNESS_NONE = -1, WEBXR_HANDEDNESS_LEFT = 0, WEBXR_HANDEDNESS_RIGHT = 1 }
 WebXR handedness. More...
 
enum  WebXRTargetRayMode { WEBXR_TARGET_RAY_MODE_GAZE = 0, WEBXR_TARGET_RAY_MODE_TRACKED_POINTER = 1, WEBXR_TARGET_RAY_MODE_SCREEN = 2 }
 WebXR target ray mode. More...
 
enum  WebXRSessionMode { WEBXR_SESSION_MODE_INLINE = 0, WEBXR_SESSION_MODE_IMMERSIVE_VR = 1, WEBXR_SESSION_MODE_IMMERSIVE_AR = 2 }
 WebXR 'XRSessionMode' enum. More...
 
enum  WebXRInputPoseMode { WEBXR_INPUT_POSE_GRIP = 0, WEBXR_INPUT_POSE_TARGET_RAY = 1 }
 WebXR 'XRSessionMode' enum. More...
 
enum  WebXRGamepadButtonMapping {
  WEBXR_BUTTON_PRIMARY_TRIGGER = 0, WEBXR_BUTTON_PRIMARY_SQUEEZE = 1, WEBXR_BUTTON_PRIMARY_TOUCHPAD = 2, WEBXR_BUTTON_PRIMARY_THUMBSTICK = 3,
  WEBXR_BUTTON_1 = 4, WEBXR_BUTTON_2 = 5, WEBXR_BUTTON_3 = 6, WEBXR_BUTTON_4 = 7,
  WEBXR_INTERNAL_HANDPOSE = 8
}
 
enum  WebXRGamepadAxisMapping {
  WEBXR_AXIS_PRIMARY_TOUCHPAD_X = 0, WEBXR_AXIS_PRIMARY_TOUCHPAD_Y = 1, WEBXR_AXIS_PRIMARY_THUMBSTICK_X = 2, WEBXR_AXIS_PRIMARY_THUMBSTICK_Y = 3,
  WEBXR_AXIS_1 = 4, WEBXR_AXIS_2 = 5, WEBXR_AXIS_3 = 6, WEBXR_AXIS_4 = 7
}
 

Functions

void webxr_init (webxr_frame_callback_func frameCallback, webxr_session_callback_func sessionStartCallback, webxr_session_callback_func sessionEndCallback, webxr_error_callback_func errorCallback, void *userData)
 Init WebXR rendering. More...
 
void webxr_is_session_supported (WebXRSessionMode mode, webxr_session_supported_callback_func supportedCallback)
 
void webxr_request_session (WebXRSessionMode mode, unsigned int requiredFeatures, unsigned int optionalFeatures)
 
void webxr_request_exit ()
 
bool webxr_get_viewer_pose (WebXRRigidTransform *pose)
 Get viewer (hmd) pose. More...
 
bool webxr_get_views (WebXRView *views, int *viewCount, int maxViews)
 Get views. More...
 
bool webxr_get_framebuffer_size (int *width, int *height)
 Get framebuffer width and height. More...
 
unsigned int webxr_get_framebuffer ()
 Get WebXR framebuffer ID. More...
 
int webxr_get_input_sources (WebXRInputSource *outArray, int max, int *outCount)
 WebXR Input. More...
 
int webxr_get_input_pose (WebXRInputSource *source, WebXRRigidTransform *outPose, WebXRInputPoseMode mode=WEBXR_INPUT_POSE_GRIP)
 Get input pose. More...
 
int webxr_get_input_gamepad (WebXRInputSource *source, WebXRGamepad *outGamepad)
 Get input gamepad. More...
 

Detailed Description

Minimal WebXR Device API wrapper.

Definition in file vtkWebXR.h.

Macro Definition Documentation

#define webxr_init   VTK_ABI_NAMESPACE_MANGLE(webxr_init)

Definition at line 18 of file vtkWebXR.h.

#define webxr_is_session_supported   VTK_ABI_NAMESPACE_MANGLE(webxr_is_session_supported)

Definition at line 19 of file vtkWebXR.h.

#define webxr_request_session   VTK_ABI_NAMESPACE_MANGLE(webxr_request_session)

Definition at line 20 of file vtkWebXR.h.

#define webxr_request_exit   VTK_ABI_NAMESPACE_MANGLE(webxr_request_exit)

Definition at line 21 of file vtkWebXR.h.

#define webxr_get_viewer_pose   VTK_ABI_NAMESPACE_MANGLE(webxr_get_viewer_pose)

Definition at line 22 of file vtkWebXR.h.

#define webxr_get_views   VTK_ABI_NAMESPACE_MANGLE(webxr_get_views)

Definition at line 23 of file vtkWebXR.h.

#define webxr_get_framebuffer_size   VTK_ABI_NAMESPACE_MANGLE(webxr_get_framebuffer_size)

Definition at line 24 of file vtkWebXR.h.

#define webxr_get_framebuffer   VTK_ABI_NAMESPACE_MANGLE(webxr_get_framebuffer)

Definition at line 25 of file vtkWebXR.h.

#define webxr_get_input_sources   VTK_ABI_NAMESPACE_MANGLE(webxr_get_input_sources)

Definition at line 26 of file vtkWebXR.h.

#define webxr_get_input_pose   VTK_ABI_NAMESPACE_MANGLE(webxr_get_input_pose)

Definition at line 27 of file vtkWebXR.h.

#define webxr_get_input_gamepad   VTK_ABI_NAMESPACE_MANGLE(webxr_get_input_gamepad)

Definition at line 28 of file vtkWebXR.h.

#define WEBXR_SESSION_FEATURE_LOCAL   0x01

WebXR 'XRSessionFeatures'.

Definition at line 68 of file vtkWebXR.h.

#define WEBXR_SESSION_FEATURE_LOCAL_FLOOR   0x02

Definition at line 69 of file vtkWebXR.h.

#define WEBXR_SESSION_FEATURE_BOUNDED_FLOOR   0x04

Definition at line 70 of file vtkWebXR.h.

#define WEBXR_SESSION_FEATURE_UNBOUNDED   0x08

Definition at line 71 of file vtkWebXR.h.

#define WEBXR_SESSION_FEATURE_HIT_TEST   0x10

Definition at line 72 of file vtkWebXR.h.

Typedef Documentation

WebXR rigid transform.

typedef struct WebXRView WebXRView

WebXR view.

typedef struct WebXRGamepad WebXRGamepad
typedef void(* webxr_error_callback_func) (void *userData, int error)

Callback for errors.

Parameters
userDataUser pointer passed to init_webxr()
errorError code

Definition at line 159 of file vtkWebXR.h.

typedef void(* webxr_frame_callback_func) (void *userData, int time)

Callback for frame rendering.

Parameters
userDataUser pointer passed to init_webxr()
timeCurrent frame time

Definition at line 167 of file vtkWebXR.h.

typedef void(* webxr_session_callback_func) (void *userData, int mode)

Callback for VR session start.

Parameters
userDataUser pointer passed to set_session_start_callback
modeThe session mode

Definition at line 175 of file vtkWebXR.h.

typedef void(* webxr_session_supported_callback_func) (int mode, int supported)

Callback for webxr_is_session_supported.

Parameters
modeThe session mode that was requested
supportedWhether given mode is supported by this device

Definition at line 183 of file vtkWebXR.h.

Enumeration Type Documentation

enum WebXRError

Errors enum.

Enumerator
WEBXR_ERR_API_UNSUPPORTED 

WebXR Device API not supported in this browser.

WEBXR_ERR_GL_INCAPABLE 

GL context cannot render WebXR.

WEBXR_ERR_SESSION_UNSUPPORTED 

given session mode not supported

Definition at line 36 of file vtkWebXR.h.

WebXR handedness.

Enumerator
WEBXR_HANDEDNESS_NONE 
WEBXR_HANDEDNESS_LEFT 
WEBXR_HANDEDNESS_RIGHT 

Definition at line 44 of file vtkWebXR.h.

WebXR target ray mode.

Enumerator
WEBXR_TARGET_RAY_MODE_GAZE 
WEBXR_TARGET_RAY_MODE_TRACKED_POINTER 
WEBXR_TARGET_RAY_MODE_SCREEN 

Definition at line 52 of file vtkWebXR.h.

WebXR 'XRSessionMode' enum.

Enumerator
WEBXR_SESSION_MODE_INLINE 
WEBXR_SESSION_MODE_IMMERSIVE_VR 
WEBXR_SESSION_MODE_IMMERSIVE_AR 

Definition at line 60 of file vtkWebXR.h.

WebXR 'XRSessionMode' enum.

Enumerator
WEBXR_INPUT_POSE_GRIP 
WEBXR_INPUT_POSE_TARGET_RAY 

Definition at line 75 of file vtkWebXR.h.

Enumerator
WEBXR_BUTTON_PRIMARY_TRIGGER 
WEBXR_BUTTON_PRIMARY_SQUEEZE 
WEBXR_BUTTON_PRIMARY_TOUCHPAD 
WEBXR_BUTTON_PRIMARY_THUMBSTICK 
WEBXR_BUTTON_1 
WEBXR_BUTTON_2 
WEBXR_BUTTON_3 
WEBXR_BUTTON_4 
WEBXR_INTERNAL_HANDPOSE 

Definition at line 114 of file vtkWebXR.h.

Enumerator
WEBXR_AXIS_PRIMARY_TOUCHPAD_X 
WEBXR_AXIS_PRIMARY_TOUCHPAD_Y 
WEBXR_AXIS_PRIMARY_THUMBSTICK_X 
WEBXR_AXIS_PRIMARY_THUMBSTICK_Y 
WEBXR_AXIS_1 
WEBXR_AXIS_2 
WEBXR_AXIS_3 
WEBXR_AXIS_4 

Definition at line 127 of file vtkWebXR.h.

Function Documentation

void webxr_init ( webxr_frame_callback_func  frameCallback,
webxr_session_callback_func  sessionStartCallback,
webxr_session_callback_func  sessionEndCallback,
webxr_error_callback_func  errorCallback,
void *  userData 
)

Init WebXR rendering.

Parameters
frameCallbackCallback called every frame
sessionStartCallbackCallback called when session is started
sessionEndCallbackCallback called when session ended
errorCallbackCallback called every frame
userDataUser data passed to the callbacks
void webxr_is_session_supported ( WebXRSessionMode  mode,
webxr_session_supported_callback_func  supportedCallback 
)
void webxr_request_session ( WebXRSessionMode  mode,
unsigned int  requiredFeatures,
unsigned int  optionalFeatures 
)
void webxr_request_exit ( )
bool webxr_get_viewer_pose ( WebXRRigidTransform *  pose)

Get viewer (hmd) pose.

bool webxr_get_views ( WebXRView *  views,
int *  viewCount,
int  maxViews 
)

Get views.

bool webxr_get_framebuffer_size ( int *  width,
int *  height 
)

Get framebuffer width and height.

unsigned int webxr_get_framebuffer ( )

Get WebXR framebuffer ID.

int webxr_get_input_sources ( WebXRInputSource *  outArray,
int  max,
int *  outCount 
)

WebXR Input.

Get input sources.

Parameters
outArrayWebXRInputSource array to fill.
maxSize of outArray (in elements).
outCountWill receive the number of input sources valid in outArray.
Returns
false if getting the input sources failed, true otherwise.
int webxr_get_input_pose ( WebXRInputSource *  source,
WebXRRigidTransform *  outPose,
WebXRInputPoseMode  mode = WEBXR_INPUT_POSE_GRIP 
)

Get input pose.

Can only be called during the frame callback.

Parameters
sourceThe source to get the pose for.
outPoseWhere to store the pose.
modeInput pose mode, whether WEBXR_INPUT_POSE_GRIP or WEBXR_INPUT_POSE_TARGET_RAY
Returns
false if updating the pose failed, true otherwise.
int webxr_get_input_gamepad ( WebXRInputSource *  source,
WebXRGamepad *  outGamepad 
)

Get input gamepad.

Can only be called during the frame callback.

Parameters
sourceThe source to get the gamepad for.
outGamepadWhere to store the gamepad.
Returns
false if updating the gamepad failed, true otherwise