summaryrefslogtreecommitdiff
path: root/modules/webxr
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webxr')
-rw-r--r--modules/webxr/register_types.cpp2
-rw-r--r--modules/webxr/webxr_interface_js.cpp33
-rw-r--r--modules/webxr/webxr_interface_js.h3
3 files changed, 28 insertions, 10 deletions
diff --git a/modules/webxr/register_types.cpp b/modules/webxr/register_types.cpp
index 6df0234811..078a6547cf 100644
--- a/modules/webxr/register_types.cpp
+++ b/modules/webxr/register_types.cpp
@@ -34,7 +34,7 @@
#include "webxr_interface_js.h"
void register_webxr_types() {
- ClassDB::register_virtual_class<WebXRInterface>();
+ GDREGISTER_VIRTUAL_CLASS(WebXRInterface);
#ifdef JAVASCRIPT_ENABLED
Ref<WebXRInterfaceJS> webxr;
diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp
index 2eab0cdb07..099e769303 100644
--- a/modules/webxr/webxr_interface_js.cpp
+++ b/modules/webxr/webxr_interface_js.cpp
@@ -35,6 +35,7 @@
#include "core/os/os.h"
#include "emscripten.h"
#include "godot_webxr.h"
+#include "servers/rendering/renderer_compositor.h"
#include <stdlib.h>
void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) {
@@ -45,7 +46,7 @@ void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) {
ERR_FAIL_COND(interface.is_null());
String session_mode = String(p_session_mode);
- interface->emit_signal("session_supported", session_mode, p_supported ? true : false);
+ interface->emit_signal(SNAME("session_supported"), session_mode, p_supported ? true : false);
}
void _emwebxr_on_session_started(char *p_reference_space_type) {
@@ -57,7 +58,7 @@ void _emwebxr_on_session_started(char *p_reference_space_type) {
String reference_space_type = String(p_reference_space_type);
((WebXRInterfaceJS *)interface.ptr())->_set_reference_space_type(reference_space_type);
- interface->emit_signal("session_started");
+ interface->emit_signal(SNAME("session_started"));
}
void _emwebxr_on_session_ended() {
@@ -68,7 +69,7 @@ void _emwebxr_on_session_ended() {
ERR_FAIL_COND(interface.is_null());
interface->uninitialize();
- interface->emit_signal("session_ended");
+ interface->emit_signal(SNAME("session_ended"));
}
void _emwebxr_on_session_failed(char *p_message) {
@@ -81,7 +82,7 @@ void _emwebxr_on_session_failed(char *p_message) {
interface->uninitialize();
String message = String(p_message);
- interface->emit_signal("session_failed", message);
+ interface->emit_signal(SNAME("session_failed"), message);
}
void _emwebxr_on_controller_changed() {
@@ -202,8 +203,8 @@ int WebXRInterfaceJS::get_capabilities() const {
return XRInterface::XR_STEREO | XRInterface::XR_MONO;
};
-bool WebXRInterfaceJS::is_stereo() {
- return godot_webxr_get_view_count() == 2;
+uint32_t WebXRInterfaceJS::get_view_count() {
+ return godot_webxr_get_view_count();
};
bool WebXRInterfaceJS::is_initialized() const {
@@ -376,6 +377,22 @@ void WebXRInterfaceJS::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_targ
return;
}
godot_webxr_commit_for_eye(p_eye);
+}
+
+Vector<BlitToScreen> WebXRInterfaceJS::commit_views(RID p_render_target, const Rect2 &p_screen_rect) {
+ Vector<BlitToScreen> blit_to_screen;
+
+ if (!initialized) {
+ return blit_to_screen;
+ }
+
+ // @todo Refactor this to be based on "views" rather than "eyes".
+ godot_webxr_commit_for_eye(XRInterface::EYE_LEFT);
+ if (godot_webxr_get_view_count() > 1) {
+ godot_webxr_commit_for_eye(XRInterface::EYE_RIGHT);
+ }
+
+ return blit_to_screen;
};
void WebXRInterfaceJS::process() {
@@ -425,7 +442,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
int *buttons = godot_webxr_get_controller_buttons(p_controller_id);
if (buttons) {
for (int i = 0; i < buttons[0]; i++) {
- input->joy_button(p_controller_id + 100, i, *((float *)buttons + (i + 1)));
+ input->joy_button(p_controller_id + 100, (JoyButton)i, *((float *)buttons + (i + 1)));
}
free(buttons);
}
@@ -436,7 +453,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
Input::JoyAxisValue joy_axis;
joy_axis.min = -1;
joy_axis.value = *((float *)axes + (i + 1));
- input->joy_axis(p_controller_id + 100, i, joy_axis);
+ input->joy_axis(p_controller_id + 100, (JoyAxis)i, joy_axis);
}
free(axes);
}
diff --git a/modules/webxr/webxr_interface_js.h b/modules/webxr/webxr_interface_js.h
index 723ab952cd..f9368582b7 100644
--- a/modules/webxr/webxr_interface_js.h
+++ b/modules/webxr/webxr_interface_js.h
@@ -83,12 +83,13 @@ public:
virtual void uninitialize() override;
virtual Size2 get_render_targetsize() override;
- virtual bool is_stereo() override;
+ virtual uint32_t get_view_count() override;
virtual Transform3D get_camera_transform() override;
virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;
virtual CameraMatrix get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override;
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;
+ virtual Vector<BlitToScreen> commit_views(RID p_render_target, const Rect2 &p_screen_rect) override;
virtual void process() override;
virtual void notification(int p_what) override;