Skip to content

Commit

Permalink
Merge pull request #45444 from dsnopek/webxr-master-mono
Browse files Browse the repository at this point in the history
Support mono devices in WebXR
  • Loading branch information
akien-mga committed Jan 27, 2021
2 parents 69f77e8 + 39e022e commit 9d3a9b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/webxr/godot_webxr.h
Expand Up @@ -61,6 +61,7 @@ extern void godot_webxr_initialize(
GodotWebXRSimpleEventCallback p_on_simple_event);
extern void godot_webxr_uninitialize();

extern int godot_webxr_get_view_count();
extern int *godot_webxr_get_render_targetsize();
extern float *godot_webxr_get_transform_for_eye(int p_eye);
extern float *godot_webxr_get_projection_for_eye(int p_eye);
Expand Down
9 changes: 9 additions & 0 deletions modules/webxr/native/library_godot_webxr.js
Expand Up @@ -394,6 +394,15 @@ const GodotWebXR = {
GodotWebXR.pauseResumeMainLoop();
},

godot_webxr_get_view_count__proxy: 'sync',
godot_webxr_get_view_count__sig: 'i',
godot_webxr_get_view_count: function () {
if (!GodotWebXR.session || !GodotWebXR.pose) {
return 0;
}
return GodotWebXR.pose.views.length;
},

godot_webxr_get_render_targetsize__proxy: 'sync',
godot_webxr_get_render_targetsize__sig: 'i',
godot_webxr_get_render_targetsize: function () {
Expand Down
5 changes: 2 additions & 3 deletions modules/webxr/webxr_interface_js.cpp
Expand Up @@ -197,12 +197,11 @@ StringName WebXRInterfaceJS::get_name() const {
};

int WebXRInterfaceJS::get_capabilities() const {
return XRInterface::XR_STEREO;
return XRInterface::XR_STEREO | XRInterface::XR_MONO;
};

bool WebXRInterfaceJS::is_stereo() {
// @todo WebXR can be mono! So, how do we know? Count the views in the frame?
return true;
return godot_webxr_get_view_count() == 2;
};

bool WebXRInterfaceJS::is_initialized() const {
Expand Down

0 comments on commit 9d3a9b3

Please sign in to comment.