diff options
Diffstat (limited to 'platform/javascript/os_javascript.cpp')
-rw-r--r-- | platform/javascript/os_javascript.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index b10ef821dd..e226ab6332 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -81,12 +81,6 @@ void OS_JavaScript::initialize_core() { FileAccess::make_default<FileAccessBufferedFA<FileAccessUnix> >(FileAccess::ACCESS_RESOURCES); } -void OS_JavaScript::set_opengl_extensions(const char *p_gl_extensions) { - - ERR_FAIL_COND(!p_gl_extensions); - gl_extensions = p_gl_extensions; -} - static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent *ui_event, void *user_data) { ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_RESIZE, false); @@ -436,16 +430,11 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, // can't fulfil fullscreen request due to browser security video_mode.fullscreen = false; /* clang-format off */ - bool resize_canvas_on_start = EM_ASM_INT_V( - return Module.resizeCanvasOnStart; - ); - /* clang-format on */ - if (resize_canvas_on_start) { + if (EM_ASM_INT_V({ return Module.resizeCanvasOnStart })) { + /* clang-format on */ set_window_size(Size2(video_mode.width, video_mode.height)); } else { - Size2 canvas_size = get_window_size(); - video_mode.width = canvas_size.width; - video_mode.height = canvas_size.height; + set_window_size(get_window_size()); } char locale_ptr[16]; @@ -975,7 +964,25 @@ int OS_JavaScript::get_power_percent_left() { bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) { - return p_feature == "web" || p_feature == "s3tc"; // TODO check for these features really being available + if (p_feature == "HTML5" || p_feature == "web") + return true; + +#ifdef JAVASCRIPT_EVAL_ENABLED + if (p_feature == "JavaScript") + return true; +#endif + + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context(); + // all extensions are already automatically enabled, this function allows + // checking WebGL extension support without inline JavaScript + if (p_feature == "s3tc" && emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_s3tc_srgb")) + return true; + if (p_feature == "etc" && emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_etc1")) + return true; + if (p_feature == "etc2" && emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_etc")) + return true; + + return false; } void OS_JavaScript::set_idbfs_available(bool p_idbfs_available) { @@ -992,7 +999,6 @@ OS_JavaScript::OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_us set_cmdline(p_execpath, get_cmdline_args()); main_loop = NULL; - gl_extensions = NULL; window_maximized = false; soft_fs_enabled = false; canvas_size_adjustment_requested = false; |