Skip to content

Commit

Permalink
Merge pull request #47660 from Faless/js/4.x_webgl_fallback
Browse files Browse the repository at this point in the history
[HTML5] Implement WebGL fallback.
  • Loading branch information
akien-mga authored Apr 6, 2021
2 parents 45f0b5d + 34fd48f commit 64e8eee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions platform/javascript/godot_js.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ extern int godot_js_display_fullscreen_exit();
extern void godot_js_display_compute_position(int p_x, int p_y, int32_t *r_x, int32_t *r_y);
extern void godot_js_display_window_title_set(const char *p_text);
extern void godot_js_display_window_icon_set(const uint8_t *p_ptr, int p_len);
extern int godot_js_display_has_webgl(int p_version);

// Display clipboard
extern int godot_js_display_clipboard_set(const char *p_text);
Expand Down
11 changes: 11 additions & 0 deletions platform/javascript/js/libs/library_godot_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 64e8eee

Please sign in to comment.