diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-27 14:32:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-27 14:32:48 +0200 |
commit | 6e577a5b805121b3725defc45220d75fcbc6442b (patch) | |
tree | dead74b7030611a969af4f4067bd9a2b4f724af9 /platform | |
parent | 3e87022ecce3a56e43324236561ecf13316517dc (diff) | |
parent | 0b286a287ca35275988f22a60f307521c5b08437 (diff) |
Merge pull request #40755 from Faless/js/fix_and_cancel_swap
Cancel/OK swap on HTML5 platform, small fixes.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/display_server_javascript.cpp | 17 | ||||
-rw-r--r-- | platform/javascript/display_server_javascript.h | 3 | ||||
-rw-r--r-- | platform/javascript/javascript_main.cpp | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index 2f0a2faa83..2fd1f45939 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -829,6 +829,19 @@ DisplayServer *DisplayServerJavaScript::create_func(const String &p_rendering_dr } DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { + r_error = OK; // Always succeeds for now. + + /* clang-format off */ + swap_cancel_ok = EM_ASM_INT({ + const win = (['Windows', 'Win64', 'Win32', 'WinCE']); + const plat = navigator.platform || ""; + if (win.indexOf(plat) !== -1) { + return 1; + } + return 0; + }) == 1; + /* clang-format on */ + RasterizerDummy::make_current(); // TODO GLES2 in Godot 4.0... or webgpu? #if 0 EmscriptenWebGLContextAttributes attributes; @@ -1181,6 +1194,10 @@ int DisplayServerJavaScript::get_current_video_driver() const { return 1; } +bool DisplayServerJavaScript::get_swap_cancel_ok() { + return swap_cancel_ok; +} + void DisplayServerJavaScript::swap_buffers() { //emscripten_webgl_commit_frame(); } diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h index b149665d67..6569ef1e42 100644 --- a/platform/javascript/display_server_javascript.h +++ b/platform/javascript/display_server_javascript.h @@ -56,6 +56,8 @@ class DisplayServerJavaScript : public DisplayServer { int last_width = 0; int last_height = 0; + bool swap_cancel_ok = false; + // utilities static Point2 compute_position_in_canvas(int p_x, int p_y); static void focus_canvas(); @@ -195,6 +197,7 @@ public: virtual void set_icon(const Ref<Image> &p_icon); // others + virtual bool get_swap_cancel_ok(); virtual void swap_buffers(); static void register_javascript_driver(); diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index f697887f08..a30d84a52c 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -34,6 +34,7 @@ #include "platform/javascript/os_javascript.h" #include <emscripten/emscripten.h> +#include <stdlib.h> static OS_JavaScript *os = nullptr; static uint64_t target_ticks = 0; |