diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-27 21:11:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-27 21:11:31 +0100 |
commit | 9d3a9b3e7dff8a3645fbb7fe95cd1e8141ba1802 (patch) | |
tree | 82f38092786aa73b6566627e5c884a47d358d29f /modules/webxr | |
parent | 69f77e83bf6430f1d76a3551d2787668646f9d76 (diff) | |
parent | 39e022e01c958e6fe56fe5220a146e4774333376 (diff) |
Merge pull request #45444 from dsnopek/webxr-master-mono
Support mono devices in WebXR
Diffstat (limited to 'modules/webxr')
-rw-r--r-- | modules/webxr/godot_webxr.h | 1 | ||||
-rw-r--r-- | modules/webxr/native/library_godot_webxr.js | 9 | ||||
-rw-r--r-- | modules/webxr/webxr_interface_js.cpp | 5 |
3 files changed, 12 insertions, 3 deletions
diff --git a/modules/webxr/godot_webxr.h b/modules/webxr/godot_webxr.h index 5e50ffde28..41a690f473 100644 --- a/modules/webxr/godot_webxr.h +++ b/modules/webxr/godot_webxr.h @@ -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); diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js index 3041c16c79..764656712d 100644 --- a/modules/webxr/native/library_godot_webxr.js +++ b/modules/webxr/native/library_godot_webxr.js @@ -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 () { diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 6594553146..7cfaf31495 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -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 { |