diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-04-06 12:46:33 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-04-06 12:57:24 +0200 |
commit | 34fd48f68d3c0e9ca60468ca4befb1a67d57fdf7 (patch) | |
tree | af871bf371c2d36104d63158ae39c1b35649f284 /platform/javascript/js | |
parent | 45f0b5db2847debacf24e4ca962338b237af19ae (diff) |
[HTML5] Implement WebGL fallback.
According to project settings and when WebGL2 is not available.
This does nothing in current master, as we have no rendering yet!
Diffstat (limited to 'platform/javascript/js')
-rw-r--r-- | platform/javascript/js/libs/library_godot_display.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/platform/javascript/js/libs/library_godot_display.js b/platform/javascript/js/libs/library_godot_display.js index 00e6a01679..91cab5eacc 100644 --- a/platform/javascript/js/libs/library_godot_display.js +++ b/platform/javascript/js/libs/library_godot_display.js @@ -719,6 +719,17 @@ const GodotDisplay = { GodotRuntime.setHeapValue(r_y, (y - rect.y) * rh, 'i32'); }, + godot_js_display_has_webgl__sig: 'ii', + godot_js_display_has_webgl: function (p_version) { + if (p_version !== 1 && p_version !== 2) { + return false; + } + try { + return !!document.createElement('canvas').getContext(p_version === 2 ? 'webgl2' : 'webgl'); + } catch (e) { /* Not available */ } + return false; + }, + /* * Canvas */ |