Commit graph

683 commits

Author SHA1 Message Date
Luis Sanchez
40f26cb260 Fix files_dropped in HTML5 export.
(Ignore trailing slash when creating the temporary directory)
2021-12-03 20:21:39 +01:00
Fabio Alessandrelli
470496d8d4 [HTML5] Fix multi-touch input handling.
The code to populate the input data for WebAssembly was incorrectly
overriding values when multiple touches were present due to wrong
indexing.
2021-11-30 11:10:21 +01:00
Fabio Alessandrelli
eaedc92c61 [HTML5] Use absolute path for JS lib/pre/externs.
Ensure better compatibility when emcc which may run some tools from
different paths (e.g. closure compiler).

This fixes externs include issues with modern emcc using the closure
compiler.
2021-11-26 12:44:51 +01:00
Fabio Alessandrelli
63e2db2499 [HTML5] Fix focus (again) in Firefox's iframes.
This actually makes sense(?), when running inside an iframe the active
element might be our canvas, while the iframe itself is not active in
the parent window. Since we consume the event, the iframe does not get
focused in Firefox (but does in Chromium-based browsers), so we must
always call focus to handle such occasions.
2021-11-26 09:44:00 +01:00
Fabio Alessandrelli
46fdba5f8b [HTML5] Add WebGL2 (GLES3) support using the OpenGL renderer.
Note, the editor build requires the mbedtls module to be manually
enabled, as it is currently needed as a ResourceUID dependency.

This will need to be addressed in a separate PR.
2021-11-19 16:59:27 +01:00
Rémi Verschelde
fc9de5ba7f
Merge pull request #54499 from Faless/threads/4.x_work_pool_default 2021-11-19 09:39:21 +01:00
Fabio Alessandrelli
91dbc288cc [HTML5] Add checks to Gamepad API events.
In some conditions the events might be generated even when the `gamepad`
object is not accessible due to Security Context requirements.
This commit adds a check to avoid firing the handler in those cases.
2021-11-19 04:07:01 +01:00
Fabio Alessandrelli
f13c7fc83e [HTML5] Fix input not focusing canvas.
mousedown and touchstart should focus the canvas to ensure correct
application lifecycle.
2021-11-19 04:06:55 +01:00
Aaron Franke
3c0fdcc8ac
Use "enum class" for input enums 2021-11-12 15:37:54 -06:00
Rémi Verschelde
88c4380737
Modules: Make sure to include modules_enabled.gen.h where needed 2021-11-12 13:42:58 +01:00
Fabio Alessandrelli
4ed1d977fc [OS] Add ThreadWorkPool default size to OS.
Some platforms (*cough* web *cough*) have hard limits on the number of
threads that can be spawned.

Currently, ThreadPoolWork (mostly used in rendering/physics servers)
will spawn as many threads as CPUs available causing exception on
machines with high CPU count.

This commit adds a new overridable method to OS that returns the default
thread pool size (still the CPU count by default), and overrides it for
the JavaScript platform so it always allocate only one thread.

We can likely improve the whole ThreadPoolWork in the future to always
allocate X amount of threads, and assign jobs to them on the fly, but
that will require some more architectural changes.
2021-11-02 04:16:00 +01:00
Hugo Locurcio
665d29c16d
Fix new projects always being created with OpenGL
Only Vulkan is fully implemented for now, so OpenGL isn't available
in the project manager yet.

This also makes the rendering driver checks use lowercase names
everywhere for consistency.
2021-11-01 22:04:36 +01:00
Clay John
8a10bb7d0d
Use OpenGL 3.3 core profile instead of compatibility profile
- Rename OpenGL to GLES3 in the source code per community feedback.
  - The renderer is still exposed as "OpenGL 3" to the user.
- Hide renderer selection dropdown until OpenGL support is more mature.
  - The renderer can still be changed in the Project Settings or using
    the `--rendering-driver opengl` command line argument.
- Remove commented out exporter code.
- Remove some OpenGL/DisplayServer-related debugging prints.
2021-10-31 15:56:45 +01:00
Hugo Locurcio
ce97ddbcb1
Rename GLES2 driver to OpenGL to prepare for the upgrade to GLES3
- Use lowercase driver names for the `--rendering-driver`
  command line argument.
2021-10-30 02:05:49 +02:00
lawnjelly
e3491a3744
Add GLES2 2D renderer + Linux display manager
First implementation with Linux display manager.

- Add single-threaded mode for EditorResourcePreview (needed for OpenGL).

Co-authored-by: clayjohn <claynjohn@gmail.com>
Co-authored-by: Fabio Alessandrelli <fabio.alessandrelli@gmail.com>
2021-10-30 02:05:48 +02:00
Rémi Verschelde
3b11e33a09
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 15:19:35 +02:00
Rémi Verschelde
5f7bbc2b57
JS: Bump ansi-regex version for linter
Silences warning about a moderate security vulnerability (which doesn't affect us).
2021-10-22 23:35:51 +02:00
Rémi Verschelde
cd21cc683a
SCons: Set DEBUG_ENABLED and DEV_ENABLED in SConstruct
They're the same for all platforms so they don't need to be repeated in all
platform definitions.
2021-10-15 10:26:58 +02:00
Rémi Verschelde
e2dfb656f4
SCons: Add DEV_ENABLED defines for target=debug builds
This will allow adding developer checks which will be fully compiled out in
user builds, unlike `DEBUG_ENABLED` which is included in debug tempates and
the editor builds.

This define is not used yet, but we'll soon add code that uses it, and change
some existing `DEBUG_ENABLED` checks to be performed only in dev builds.

Related to godotengine/godot-proposals#3371.
2021-10-14 12:01:28 +02:00
Aaron Franke
7e51e4cb84
Fix some LGTM errors of "Multiplication result converted to larger type" 2021-10-12 00:17:27 -05:00
Rémi Verschelde
a7ba227631
Merge pull request #52711 from m4gr3d/provide_getter_for_project_data_dir_master 2021-10-05 21:02:27 +02:00
Fabio Alessandrelli
68616edcbc [HTML5] Refactor JS library listeners to OS. 2021-10-05 14:15:07 +02:00
Fabio Alessandrelli
c494e442bc [HTML5] Refactor display/input JS library code. 2021-10-05 14:15:07 +02:00
Fabio Alessandrelli
204822ed45 [HTML5] Implement Pointer Lock API in JS library.
Removes more emscripten HTML5 library dependencies.
2021-10-05 14:15:07 +02:00
Fabio Alessandrelli
7d6c1fdb32 [HTML5] Implement window blur in JS library.
Removes more emscripten HTML5 library dependencies.
2021-10-05 14:15:07 +02:00
Fabio Alessandrelli
b6315afc9a [HTML5] Implement fullscreenchange in JS library.
Removes more emscripten HTML5 library dependencies.
2021-10-05 14:15:07 +02:00
Fabio Alessandrelli
b2d30c725d [HTML5] Implement mouse/touch/key events in JS library.
This makes us more independent from emscripten libraries, giving us more
control on the application lifecycle.
2021-10-05 14:15:07 +02:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
Fabio Alessandrelli
e2e1a5099c
Merge pull request #52809 from selgesel/patch1
Release pressed events when the window is blurred on HTML5 platform
2021-09-29 13:09:59 +02:00
Rémi Verschelde
23b51a1708
HTML5: Fix minification error with Emscripten 1.39.9
It used an old vendored version of acorn.js which seems to choke on this
trailing comma. This is not a problem for more recent Emscripten versions.

We disable the `comma-dangle` check in ESLint to prevent this issue.
2021-09-29 09:11:11 +02:00
Selgesel
5d1d9f23de Release pressed events when the window is blurred on HTML5 platform 2021-09-23 16:44:31 +03:00
Rémi Verschelde
bd75235b8a
Merge pull request #52649 from Faless/js/4.x_audioworklet_nothreads_pr
[HTML5] Refactor audio drivers. Implement AudioWorklet w/o threads.
2021-09-21 10:44:08 +02:00
Rémi Verschelde
a507a50d16
Merge pull request #52720 from Faless/js/4.x_fix_wheel
[HTML5] Fix wheel/touch callback modifying event after parse.
2021-09-16 09:42:04 +02:00
ne0fhyk
69f890ff11 Provide a getter for the project data directory. 2021-09-15 12:52:03 -07:00
Fabio Alessandrelli
246334b836 [HTML5] Refactor audio drivers. Implement AudioWorklet w/o threads.
Performances are not great in general, bad on Firefox, on Chrome, well,
it could be an improvement. Leave it as a fallback for now, but can be
forced via project settings if desired (or custom JavaScript logic via
the "args" option).

I'm actually surprised this works, it involves so many allocations, but
there's no way around it when SharedArrayBuffer is not available :(.
2021-09-15 20:48:49 +02:00
Fabio Alessandrelli
e902347a8c
Merge pull request #52695 from Faless/js/4.x_audio_mix_rate
[HTML5] Use browser mix rate by default on the Web.
2021-09-15 20:33:42 +02:00
Fabio Alessandrelli
c3f5194861 [HTML5] Fix wheel/touch callback modifying event after parse.
The events should be duplicated or reinstantiated without
assuming that parse_input will consume them immediately.
2021-09-15 20:07:28 +02:00
Fabio Alessandrelli
ba08f39e47 [HTML5] Fix bug in AudioWorklet when reading output buffer.
Would attempt an out of bounds read, causing an exception.
2021-09-15 11:58:52 +02:00
Fabio Alessandrelli
d187bb4e11 [HTML5] Use browser mix rate by default on the Web.
Browsers doesn't really like forcing the mix rate, e.g. Firefox does not
allow input (microphone) if the mix rate is not the default one, Chrom*
will exhibit worse performances, etc.
2021-09-15 11:56:21 +02:00
Fabio Alessandrelli
76a7ee88d2
Merge pull request #52604 from Faless/js/4.x_input_fix
[HTML5] Fix input not working when buffered.
2021-09-14 11:47:40 +02:00
Fabio Alessandrelli
4c6845c095 [HTML5] Fix input not working when buffered.
After input buffering was reworked, input accumulation is now handled
outside of OS, and the JavaScript plaform never implemented that.
Additionally, the JavaScript platform is quite obnoxious about calling
specific APIs outside specific user triggered events.

This commit adds event flushing during the main iteration, and forces it
during keydown/keyup/mousedown/mouseup/touchstart/touchend/touchcanel
events (effectively only accumulating only "move" events).
2021-09-12 19:07:44 +02:00
Fabio Alessandrelli
490511fcfe [HTML5] Fix build error due to missing string cast. 2021-09-12 19:07:18 +02:00
Hugo Locurcio
1513aa9b26
Add logo attribution for Android, HTML5 and Linux platform icons
- Tweak the Android platform logo to remove the Android wordmark,
  as it can't be used without explicit permission.
2021-09-11 19:34:10 +02:00
Hugo Locurcio
2daaf0fdc3
Make platform feature tag names lowercase
Feature tag names are still case-sensitive, but this makes built-in
feature tags more consistent.

- `Windows` -> `windows`
- `OSX` -> `osx`
- `LinuxBSD` -> `linuxbsd`
- `Android` -> `android`
- `iOS` -> `ios`
- `HTML5` -> `html5`
- `JavaScript` -> `javascript`
- `UWP` -> `uwp`
2021-08-31 20:34:44 +02:00
Fabio Alessandrelli
7ab78c4cad
Merge pull request #49598 from Calinou/web-editor-improve-download-project-source-zip-name
Improve the generated ZIP archive name when using Download Project Source
2021-08-31 02:36:02 +02:00
Rémi Verschelde
16f49d4b29
HTML5: Handle GODOT_VERSION_STATUS env var in @GODOT_VERSION@
Follow-up to #51002.
2021-08-19 15:01:30 +02:00
Fabio Alessandrelli
71fb2429a0 [CI] Upgrade Emscripten to 2.0.27.
Update Godot Javascript FS library to manually depend on ERRNO_CODES.
2021-08-18 10:30:50 +01:00
Hugo Locurcio
719ff68fdd
Improve the generated ZIP archive name when using Download Project Source
This makes for easier organization since downloading a project
several times (or several different projects) will result in more
meaningful file names.
2021-08-16 18:33:03 +02:00
Sergey Minakov
9f49255bee Split javascript export template into multiple files 2021-08-12 17:18:36 +03:00
Aaron Franke
fa3a32a2d6
Use Key enum instead of plain integers 2021-08-10 16:26:55 -05:00
luz paz
3564c16cb8
Fix various typos with codespell
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-25 11:21:51 +02:00
Aaron Franke
4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
bruvzg
618eb27e8b Move alert function from DisplayServer to OS. 2021-07-22 21:50:35 +03:00
reduz
6631f66c2a Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname.
* Subsequent usages use the cached version.
* Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time.
* Replaced all theme usages by this new macro.
* Replace all signal emission usages by this new macro.
* Replace all call_deferred usages by this new macro.

This is part of ongoing work to optimize GUI and the editor.
2021-07-18 21:20:02 -03:00
Hendrik Brucker
38578a8095 Modernize Display server to use override keyword 2021-07-16 21:39:13 +02:00
Fabio Alessandrelli
7431586286 [HTML5] Make threads build the default.
Non-threads build are broken anyway.
2021-07-15 15:33:39 +02:00
Fabio Alessandrelli
3d8acc7a54 [HTML5] Fix build (with module_webxr_enabled=no).
The XR API changed a bit, and it's not just a rename, though probably an
easy update for someone who is qualified :).
2021-07-15 14:37:21 +02:00
Rémi Verschelde
06568bbfdf
Misc cleanup of header includes
Was looking for misuse of module headers without checking that the module is
actually enabled and got carried away...
2021-07-15 00:46:43 +02:00
Fabio Alessandrelli
897c906ebf [HTML5] Raise default initial memory to 32 MiB.
The memory was resized in any case during start.

Mitigate Chromium issue:
https://bugs.chromium.org/p/v8/issues/detail?id=11863

Also fix a warning about SAFE_HEAP being a linker only flag.
2021-07-13 15:51:00 +02:00
reduz
5ad4f26659 Implement the ability to disable classes
* This PR adds the ability to disable classes when building.
* For now it's only possible to do this via command like:
  `scons disable_classes=RayCast2D,Area3D`
* Eventually, a proper UI will be implemented to create a build config file to do this at large scale, as well as detect what is used in the project.
2021-07-13 09:25:14 -03:00
Fabio Alessandrelli
d4e302a3a4 [HTML5] Fix JavaScript string parsing with new interface.
Strings are UTF-8 encoded and should be parsed as such, while it was
being parsed as a C string before.
2021-07-07 15:44:29 +02:00
Fabio Alessandrelli
c12fca57f4 [HTML5] Add option to focus canvas on start.
Enabled by default.
2021-06-25 19:07:17 +02:00
Haoyu Qiu
91477cd4a9 Strip query string when parsing HTTP request line for path 2021-06-25 00:20:28 +08:00
Fabio Alessandrelli
b00c4a4360 [Net] Makes HTTPClient a custom instance class. 2021-06-23 14:10:45 +02:00
Fabio Alessandrelli
421e771012 [Net] Unify HTTPClient request and request_raw. 2021-06-23 13:53:43 +02:00
Aaron Franke
0ce49800ac
Use mouse and joypad enums instead of plain integers
Also MIDIMessage
2021-06-20 11:54:24 -04:00
Lightning_A
e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Marcel Admiraal
2bafcd3422 Consolidate JSON, JSONParseResults and JSONParser into JSON
Renames JSON.parse_string() to parse()
Renames JSON.decode_data() to stringify()
2021-06-19 08:01:40 +01:00
Fabio Alessandrelli
ad5bdaf5aa [HTML5] JS callback functions now returns passed value.
JavaScript callbacks created via the `JavaScript.create_callback` method
used to always return void.

With this patch they return the value returned by the Godot function as
one would expect.
2021-06-18 17:47:48 +02:00
Rémi Verschelde
88e671e0b7
Merge pull request #49592 from Faless/js/4.x_fix_sigs
[HTML5] Fix build without eval, library functions signatures.
2021-06-15 00:01:54 +02:00
Fabio Alessandrelli
a1cbb6daa6 [HTML5] Update eslint and jsdoc dependencies. 2021-06-14 13:42:03 +02:00
Fabio Alessandrelli
049b5159f1 [HTML5] Fix JS build without eval.
Also fix download_buffer return type.
2021-06-14 12:32:53 +02:00
Fabio Alessandrelli
9b7b0a28b9 [HTML5] Fix some JS library signature. 2021-06-14 12:32:32 +02:00
Pedro J. Estébanez
04688b92ff Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
Rémi Verschelde
9e328bb5b7
Core: Move DirAccess and FileAccess to core/io
File handling APIs are typically considered part of I/O, and we did have most
`FileAccess` implementations in `core/io` already.
2021-06-11 14:52:39 +02:00
Arthur Bikmullin
ee2bea7a86
Fixed missed IDHandler dependency in GodotFetch 2021-06-08 00:20:24 +02:00
Aaron Franke
98aa3b669e
Add MOUSE_MODE_CONFINED_HIDDEN
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-06-03 11:44:28 -04:00
Fabio Alessandrelli
8cdef21d6c Move remaining dummy drivers to servers. 2021-06-01 16:50:32 +02:00
Fabio Alessandrelli
8594613f94 LinuxBSD now compiles without vulkan/x11. 2021-06-01 16:27:54 +02:00
reduz
0d2e02945b Implement shader caching
* Shader compilation is now cached. Subsequent loads take less than a millisecond.
* Improved game, editor and project manager startup time.
* Editor uses .godot/shader_cache to store shaders.
* Game uses user://shader_cache
* Project manager uses $config_dir/shader_cache
* Options to tweak shader caching in project settings.
* Editor path configuration moved from EditorSettings to new class, EditorPaths, so it can be available early on (before shaders are compiled).
* Reworked ShaderCompilerRD to ensure deterministic shader code creation (else shader may change and cache will be invalidated).
* Added shader compression with SMOLV: https://github.com/aras-p/smol-v
2021-05-31 10:13:09 +02:00
Marcel Admiraal
da5d7db610 Rename File::get_len() get_length() 2021-05-25 11:54:28 +01:00
Hugo Locurcio
87f503310b
Tweak dozens of editor property hints for consistency
- Update Viewport MSAA property hints to match the currently
  exposed values.
- Add some performance hints to property hints.
2021-05-25 02:50:35 +02:00
Rémi Verschelde
2362a59a11
Merge pull request #48928 from Faless/js/4.x_fix_build_after_rename
[HTML5] Fix build after KEY_CTRL rename.
2021-05-21 18:33:15 +02:00
Fabio Alessandrelli
923131ec28 [HTML5] Fix build after KEY_CTRL rename. 2021-05-21 15:53:23 +02:00
Fabio Alessandrelli
fdf66a21f1 [HTML5] Add easy to use download API.
New `JavaScript.download_buffer` method to create a prompt that let the
user download a file.
2021-05-21 15:31:23 +02:00
Rémi Verschelde
aa5552278d
Merge pull request #48719 from Faless/js/4.x_interfaces
[HTML5] Implement Godot <-> JavaScript interface.
2021-05-20 17:13:02 +02:00
Fabio Alessandrelli
9811035ebf [HTML5] Implement Godot <-> JavaScript interface. 2021-05-20 14:33:18 +02:00
Rémi Verschelde
4219a4cb6f
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:38:56 +02:00
Fabio Alessandrelli
14c057eab6 [HTML5] Fix GDNative compilation with emcc 2.0.19+
Add `WARN_ON_UNDEFINED_SYMBOLS=0` for the main module (which defines
`godot_js_main` as extern coming from the "side" module, i.e. the main
Godot binary).
2021-05-19 11:51:32 +02:00
Rémi Verschelde
6c367f8e0d
Merge pull request #48168 from LightningAA/control-to-ctrl-4.0 2021-05-17 17:38:02 +02:00
Pedro J. Estébanez
469fa47e06
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-17 15:06:19 +02:00
Rémi Verschelde
e743b6b24c
CI: Update JavaScript linter deps with known security vulnerabilities
jsdoc has no new release so I'm tracking this PR:
https://github.com/jsdoc/jsdoc/pull/1906
2021-05-12 10:32:38 +02:00
Fabio Alessandrelli
871d067aa9
Merge pull request #48543 from Faless/js/4.x_target_fps_fix
[HTML5] Fix target_fps when window loses focus.
2021-05-08 11:02:50 +02:00
Lightning_A
97fecd1b69 Rename "Control" key to "Ctrl" and add "_pressed" suffix to all InputEventWithModifiers properties/methods 2021-05-07 14:00:50 -06:00
Fabio Alessandrelli
a1fe6d6899 [HTML5] Fix target_fps when window loses focus.
We don't get updates when the window is unfocused/minimized, so we must
detect the situation where the counted ticks start drifting away
resulting in more frames drawn than needed.
This commit adds a check to ensure that the target ticks do not drift
away more than one second.
2021-05-07 21:51:14 +02:00
Rémi Verschelde
35ec0e9be7
OS: Remove native video API only implemented on iOS
See discussion in #43811, it was only implemented on iOS and even that
implementation was fairly limited. This would best be provided as plugins
for Android and iOS without cluttering the shared OS API.
2021-05-07 20:40:24 +02:00
Fabio Alessandrelli
6243835619 [HTML5] Use 64KiB chunk size in JS HTTPClient.
For consistency with the native one, and the documentation.
2021-05-06 14:00:52 +02:00
Hugo Locurcio
3f078c99f6
Rename IP_Unix, IP_Address and TCP_Server to remove underscores 2021-05-06 02:52:01 +02:00
Aaron Franke
0de9a7d803
Rename doubleclick to double_click 2021-05-04 04:38:08 -04:00
Fabio Alessandrelli
8e2c237008 [HTML5] Fix builds with recent emscripten versions
Library suffix should be `.a`, the `EXTRA_` in
`EXTRA_EXPORTED_RUNTIME_METHODS` is deprecated.
2021-04-30 08:01:26 +02:00