summaryrefslogtreecommitdiff
path: root/platform/web/display_server_web.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/web/display_server_web.cpp')
-rw-r--r--platform/web/display_server_web.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp
index 2c1e87e663..f704124704 100644
--- a/platform/web/display_server_web.cpp
+++ b/platform/web/display_server_web.cpp
@@ -54,7 +54,15 @@ DisplayServerWeb *DisplayServerWeb::get_singleton() {
// Window (canvas)
bool DisplayServerWeb::check_size_force_redraw() {
- return godot_js_display_size_update() != 0;
+ bool size_changed = godot_js_display_size_update() != 0;
+ if (size_changed && !rect_changed_callback.is_null()) {
+ Variant size = Rect2i(Point2i(), window_get_size()); // TODO use window_get_position if implemented.
+ Variant *vp = &size;
+ Variant ret;
+ Callable::CallError ce;
+ rect_changed_callback.callp((const Variant **)&vp, 1, ret, ce);
+ }
+ return size_changed;
}
void DisplayServerWeb::fullscreen_change_callback(int p_fullscreen) {
@@ -758,10 +766,8 @@ DisplayServerWeb::DisplayServerWeb(const String &p_rendering_driver, WindowMode
godot_js_os_request_quit_cb(request_quit_callback);
#ifdef GLES3_ENABLED
- // TODO "vulkan" defaults to webgl2 for now.
- bool wants_webgl2 = p_rendering_driver == "opengl3" || p_rendering_driver == "vulkan";
- bool webgl2_init_failed = wants_webgl2 && !godot_js_display_has_webgl(2);
- if (wants_webgl2 && !webgl2_init_failed) {
+ bool webgl2_inited = false;
+ if (godot_js_display_has_webgl(2)) {
EmscriptenWebGLContextAttributes attributes;
emscripten_webgl_init_context_attributes(&attributes);
attributes.alpha = OS::get_singleton()->is_layered_allowed();
@@ -770,20 +776,17 @@ DisplayServerWeb::DisplayServerWeb(const String &p_rendering_driver, WindowMode
attributes.explicitSwapControl = true;
webgl_ctx = emscripten_webgl_create_context(canvas_id, &attributes);
- if (emscripten_webgl_make_context_current(webgl_ctx) != EMSCRIPTEN_RESULT_SUCCESS) {
- webgl2_init_failed = true;
- } else {
- if (!emscripten_webgl_enable_extension(webgl_ctx, "OVR_multiview2")) {
- // @todo Should we log this?
- }
- RasterizerGLES3::make_current();
- }
+ webgl2_inited = webgl_ctx && emscripten_webgl_make_context_current(webgl_ctx) == EMSCRIPTEN_RESULT_SUCCESS;
}
- if (webgl2_init_failed) {
+ if (webgl2_inited) {
+ if (!emscripten_webgl_enable_extension(webgl_ctx, "OVR_multiview2")) {
+ print_verbose("Failed to enable WebXR extension.");
+ }
+ RasterizerGLES3::make_current();
+
+ } else {
OS::get_singleton()->alert("Your browser does not seem to support WebGL2. Please update your browser version.",
"Unable to initialize video driver");
- }
- if (!wants_webgl2 || webgl2_init_failed) {
RasterizerDummy::make_current();
}
#else
@@ -908,7 +911,7 @@ ObjectID DisplayServerWeb::window_get_attached_instance_id(WindowID p_window) co
}
void DisplayServerWeb::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
- // Not supported.
+ rect_changed_callback = p_callable;
}
void DisplayServerWeb::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {