Commit graph

24 commits

Author SHA1 Message Date
Fabio Alessandrelli
34fd48f68d [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!
2021-04-06 12:57:24 +02:00
Fabio Alessandrelli
737ed0f66e [HTML5] Disable body_size in fetch.
We were using `Content-Length` from the server when `Content-Encoding`
was not set (i.e. response was not compressed).

Sadly, in CORS requests accessing headers is restricted, and while
`Content-Length` is enabled by default, `Content-Encoding` is not.

This results in the impossibility of knowing if the content was
compressed, unless the server explicitly enabled the encoding header
via `Access-Control-Expose-Headers`.

To keep maximum compatibility we must disable `body_size` completely.
2021-04-03 15:05:36 +02:00
Fabio Alessandrelli
01658adb30 [HTML5] Fix WM notifications not being called.
Regression from the library refactoring, binding and not calling is
pretty useless 'o_o.
2021-03-29 20:11:19 +02:00
Fabio Alessandrelli
f1e810adcb [HTML5] Drag and drop zip in project manager.
With a very nice hack, a new hidden configuration option that delays
dropped files removal at exit.

This still leaks while the project manager is running, but will clear
memory as soon as it exits or load something.
(reminder, dropped files are reguarly removed after the signal is
emitted specifically to avoid leaks, but I prefer hacking the HTML5
config then the project manager).
2021-03-12 10:16:02 +01:00
Fabio Alessandrelli
3416f7b521 [HTML5] Opt-in virtual keyboard support.
Added as an export option "Experimental Virtual Keyboard".
There is no zoom, so text/line edit must be in the top part of the
screen, or it will get hidden by the virtual keyboard.
UTF8/Latin-1 only (I think regular UTF-8 should work out of the box in
4.0 but I can't test it).
It uses an hidden textarea or input, based on the multiline variable,
and only gets activated if the device has a touchscreen.
This could cause problems on devices with both touchscreen and a real
keyboard (although input should still work in general with some minor
focus issues). I'm thinking of a system to detect the first physical
keystroke and disable it in case, but it might do more harm then good,
so it must be well thought.
2021-03-11 23:08:08 +01:00
Fabio Alessandrelli
3f059b90d6 [HTML5] Properly set canvas size during setup.
It used to be updated before the first iteration, causing the
window/viewport size values to be incorrect during the initialization
phase (e.g. during the first `_ready` notification).
2021-03-10 00:00:14 +01:00
Fabio Alessandrelli
f34c7982c5 [HTML5] Respect allow_hidpi option during setup
The option was forced to `true` before, unlike on other platforms.
2021-03-08 23:37:53 +01:00
Fabio Alessandrelli
0816011e86 [HTML5] Catch audio worklet errors on disconnect.
Which could happen if the worklet was not fully loaded, or the audio
context had already aborted.
2021-03-08 17:06:24 +01:00
Fabio Alessandrelli
fd76977183 [HTML5] Replace XMLHttpRequest with Fetch.
This has some advantages:
- Streaming/chunked response support.
- Broader headers support.
2021-03-06 11:44:07 +01:00
Fabio Alessandrelli
44a662a149 [HTML5] Rename heapCopy to heapSlice.
New heapCopy function copies a TypedArray to the heap.
2021-03-05 20:17:58 +01:00
Fabio Alessandrelli
65abf94675 [HTML5] Better fullscreen, canvas resizing.
Three canvas resize policies:
- `None`: Godot window settings are ignored.
- `Project`: Godot handles the canvas like a native app (resizing it
  when setting the window size).
- `Adaptive`: Canvas size will always adapt to browser window size.

Use `None` if you want to control the canvas size with custom JavaScript
code.
2021-02-19 05:12:32 +01:00
Fabio Alessandrelli
2972ea3229 [HTML5] Easier HTML templates, better deinit/cleanup. 2021-02-19 05:12:32 +01:00
Fabio Alessandrelli
26ec6ca576 [HTML5] Implement get_processor_count. 2021-02-17 13:03:52 +01:00
Fabio Alessandrelli
6cff589b5b [HTML5] Detect screen scale and DPI.
`OS.get_screen_scale` will now return the `window.devicePixelRatio`
value, `OS.get_screen_dpi` uses CSS media queries to find approximate
DPI value for the current display.
`OS.get_screen_size` also return the actual screen size (not the CSS
pixel size).
2021-02-12 12:01:44 +01:00
Rémi Verschelde
ab4c3ddf32
Merge pull request #45888 from Faless/js/4.x_xhr_fix
[HTML5] Fix HTTPClient request_raw.
2021-02-11 11:08:08 +01:00
Fabio Alessandrelli
75c4e2c5fa [HTML5] Fix HTTPClient request_raw.
Now send data according to the spec, properly handle null data.
Simplify JS code since we are at it.
2021-02-11 10:03:36 +01:00
Fabio Alessandrelli
3366122e1a [HTML5] Handle contextmenu, webglcontextlost internally.
This way they are automatically cleaned up when the engine exits,
landing a hand to browsers garbage collectors.
2021-02-11 07:56:10 +01:00
Fabio Alessandrelli
bab20c6e09 [HTML5] Custom Gamepad library to allow remapping.
No longer use emscripten functions for gamepads, implement them as
library functions in library_godot_display.js instead.
This allows us to do a better job at "guessing" vendorId, productId, OS,
etc. thus allowing us to better find the remapping for the controller.
2021-01-18 12:30:38 +01:00
Rémi Verschelde
b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Fabio Alessandrelli
eb2152538c [HTML5] Fix errors when Mic is not allowed. 2020-12-09 17:54:50 +01:00
Fabio Alessandrelli
1167ab96e9 [HTML5] Add function signatures to JS libraries. 2020-12-04 23:21:33 +01:00
Fabio Alessandrelli
742729ccfe [HTML5] Remove file flags from writeFile in setup.
Flags where deprecated and partly in removed in emscripten 2.0.9.
2020-11-30 12:07:20 +01:00
Fabio Alessandrelli
4617a7fa9c [HTML5] Run eslint --fix.
Should I write a poem about this whole new world? ;)
2020-11-23 12:15:18 +01:00
Fabio Alessandrelli
a82f70ea9f [HTML5] Libraries refactor for linting.
Initial work to make liniting easier.

This includes:
- Rename http_request.js to library_godot_http_request.js.
- Rename externs.js to engine.externs.js.
- New library_godot_runtime.js (GodotRuntime) wraps around emscripten
  functions.
- Refactor of XMLHttpRequest handler in engine/preloader.js.
- Few fixes to bugs spotted by early stage linting.
2020-11-21 14:22:40 +01:00