Commit graph

560 commits

Author SHA1 Message Date
Fabio Alessandrelli 1e7bd3d08b [HTML5] Allow selecting the export type.
Available types:
- Regular
- GDNative (support dynamic linking and thus GDNative WASM files)
- Threads (uses WebAssembly Threads)
2020-12-05 00:55:11 +01:00
Fabio Alessandrelli 611c4998e8 [HTML5] EditorRunNative works with GDNative.
This "breaks" our loading bar logic (libraries are not counted).
Fixing it is non trivial and probably deserves investigating a different
strategy.
2020-12-05 00:55:07 +01:00
Fabio Alessandrelli ca34b5e57a [HTML5] GDNative support via SIDE_MODULE.
Working with emscripten >= 2.0.10
2020-12-05 00:52:43 +01:00
Fabio Alessandrelli 1167ab96e9 [HTML5] Add function signatures to JS libraries. 2020-12-04 23:21:33 +01:00
Fabio Alessandrelli 178546ac3e [HTML5] Fix broken layout on load in HiDPI screens
This was caused by the devicePixelRatio being applied twice, once by the
HTML code, once by the OS code.
More specifically, OS.get_window_size() would return the canvas element
size, while OS.set_window_size() would set the element size to the
specified value times the devicePixelRatio.
Calling OS.set_window_size(OS.get_window_size()) would reapply the
devicePixelRatio every time.
This commit changes the behaviour so that OS.set_window_size() do not
apply the devicePixelRatio to the canvas element size, by it divides the
CSS size instead.
2020-11-30 12:07:20 +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
bruvzg b9f441e81e
[Complex Text Layouts] Add third-party TextServer dependencies (ICU, HarfBuzz, Graphite). 2020-11-26 13:55:27 +02: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 c38984d286 [HTML5] Enforce JavaScript style with eslint.
Applies to javascript files inside the platform library folder, the
exposed Engine code, and any javascript files in modules.

Files ending with ".externs.js" will be ignored, you can create a
".eslintignore" file to specify extra files to be ignored.
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
Rémi Verschelde 504efc5f9b
Export: Reorder options for consistency across platforms 2020-11-20 11:17:50 +01:00
Rémi Verschelde 2e4bff1cfe
SCons: Remove unnecessary $LINK overrides
As of SCons 4.0.1, the default value for $LINK is $SMARTLINK, which itself
is a function that will use $CXX as linker for C++:

https://github.com/SCons/scons/blob/4.0.1/SCons/Tool/link.py#L327-L328
https://github.com/SCons/scons/blob/4.0.1/SCons/Tool/link.py#L54-L76

So we don't need to manually specify the same value as $CXX for $LINK.
2020-11-19 16:48:03 +01:00
Marcel Admiraal f42284ed07 Add missing javascript semi-colons. 2020-11-17 18:18:46 +00:00
Aaron Franke 02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Fabio Alessandrelli 179ec3ca0e [HTML5] AudioWorklet API implementation.
Rewrote AudioDriverJavaScript to support multiple processor nodes.
The old (and deprecated) ScriptProcessorNode when threads are not
available, and the new AudioWorklet API when threads are enabled.

The new implementation uses two ring buffers and a shared state to
communicated with the AudioWorklet thread.

The audio.worklet.js JavaScript file is always added to the export
template, but only really used (and downloaded) in the thread build.
2020-11-10 18:56:21 +01:00
Fabio Alessandrelli e2083871eb [HTML5] Port JavaScript inline code to libraries.
The API is implemented in javascript, and generates C functions that can
be called from godot.
This allows much cleaner code replacing all `EM_ASM` calls in our C++
code with plain C function calls.
This also gets rid of few hacks and comes with few optimizations (e.g.
custom cursor shapes should be much faster now).
2020-11-10 11:42:51 +01:00
Fabio Alessandrelli 54cda5c3b8 [HTML5] Update syntax for lto. 2020-11-10 11:42:51 +01:00
reduz 127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
Fabio Alessandrelli b3453e866b [HTML5] Fix audio buffer size and latency hint.
The size of the audio buffer was incorrectly doubled when creating the
script processor.
latencyHint is expressed in seconds, not milliseconds.
Additionally, on some browsers it actually affect the performance and
stability of the audio driver.
For this reason it has been completely disabled (interactive) and a not
has been left for future reference.
2020-11-06 15:38:47 +01:00
reduz ee06a70ea6 Refactor MethodBind to use variadic templates
Removed make_binders and the old style generated binders.
2020-10-18 12:28:44 +02:00
Fabio Alessandrelli c54de7f589 [HTML5] Add JavaScriptToolsEditorPlugin.
A new editor plugin, specific to HTML5, that provide some extra features
needed to make the editor usable on that platform.

For now, it adds a "Download project sources" option in the "Tool" menu,
so the user can download the work done as a zip file (from the browser
storage).
2020-10-14 12:31:20 +02:00
Fabio Alessandrelli 3dfb769115 Add JavaScript editor html file. 2020-10-14 11:20:50 +02:00
Fabio Alessandrelli ec396c7707 [HTML5] Close IDBFS database on exit.
This should be made available in emscripten in a decent way.
Possibly after unmount, to free the database lock and allow performing
operations on it from javascript after the Emscripten Runtime has
exited.
2020-10-14 11:20:37 +02:00
Fabio Alessandrelli 6769dd64fc [HTML5] Expose request_quit via Engine class.
So it can be called when closure compiler is enabled.
2020-10-14 11:15:24 +02:00
Fabio Alessandrelli c3b7c5cc2d Increase HTML5 THREADPOOL size.
This fixes a "random" deadlock when quitting the editor.
I still haven't figure out the root cause, but having a bigger seems to
greatly mitigate the issue.
The new pool size (pre-allocated threads) is now 8.
2020-10-14 11:13:12 +02:00
Fabio Alessandrelli 7998745237 [HTML5] Scons now expects "emcc" to be in PATH.
No longer parse emscripten/emsdk config to detect emcc/node paths.
Use WhereIs to find "emcc" and "node", look for "node_modules" in "emcc"
path.
2020-10-04 14:26:44 +02:00
Fabio Alessandrelli a618535628 [HTML5] Run Audio process in thread when available
This should fix some of the audio stuttering issues when the HTML5
export is compiled with threads support.
The API should be ported to AudioWorklet to (hopefully) be perfect.
That though, cannot be backported to 3.2 due to extra restriction of
AudioWorklet (which only runs in SecureContext, and needs a polyfill for
Safari).
2020-10-02 14:28:20 +02:00
Fabio Alessandrelli 80b34ccee1 Add extra suffix for HTML5 thread builds. 2020-10-02 13:35:03 +02:00
Fabio Alessandrelli 5261e5df85 Add COOP/COEP headers to HTML5 "run" server.
This allow the page to be considered a SecureContext if the address is
localhost (127.0.0.1/::1) and let Firefox (and future Chrome versions)
enable extra features needed for the HTML5 threaded export.
2020-10-02 13:35:03 +02:00
Fabio Alessandrelli dccd71c7a3 JS synchronous start, better persistent FS sync.
The engine now expects to emscripten FS to be setup and sync-ed before
main is called. This is exposed via `Module["initFS"]` which also allows
to setup multiple persistence paths (internal use only for now).

Additionally, FS syncing is done **once** for every loop if at least one
file in a persistent path was open for writing and closed, and if the FS
is not syncing already.

This should potentially fix issues reported by users where "autosave"
would not work on the web (never calling `syncfs` because of too many
writes).
2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 53f04aa1b9 Make canvas resize optional in HTML5. 2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 806edcae5b Better HiDPI support in HTML5. 2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 7d0896e763 Window event listener do not use capture. 2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 48aa0b5b03 Small refactor to JavaScript handlers.
Crated helper class in native/utils.js.
Simplify code in OS/DisplayServer.
2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 7d045b8543 Expose request_quit method to JS in HTML5 export. 2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 27ab97501b [HTML5] Add override keyword, cleanup methods. 2020-09-18 18:48:59 +02:00
Rémi Verschelde 3e78963bb9
Fix typos with codespell
Using codespell 1.17.1.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
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
```
2020-09-18 13:44:25 +02:00
Marcel Admiraal 64095245ee Explicitly add implicitly added semicolons. 2020-09-09 15:30:57 +01:00
Rémi Verschelde 6e577a5b80
Merge pull request #40755 from Faless/js/fix_and_cancel_swap
Cancel/OK swap on HTML5 platform, small fixes.
2020-07-27 14:32:48 +02:00
Fabio Alessandrelli 0b286a287c Implement HTML5 cancel/ok button swap on Windows.
Platform is detected on init via the `navigator.platform` string.
2020-07-27 14:17:10 +02:00
Fabio Alessandrelli 3e96ba220e Correctly include <stdlib.h> in javascript main.
Already fixed in 3.2, this header is needed since it's where setenv
is declared and we should not assume it to be already included.
2020-07-27 14:17:10 +02:00
Fabio Alessandrelli 757af6a69f Properly set HTML5 DisplayServer init error value.
Checked in main.cpp, would cause the engine to not load.
2020-07-27 14:17:10 +02:00
RevoluPowered 579342810f t Add unit testing to Godot using DocTest and added to GitHub Actions CI
Implements exit codes into the engine so tests can return their statuses.
Ideally we don't do this, and we use FIXUP logic to 'begin' and 'end' the engine execution for tests specifically.

Since realistically we're initialising the engine here we don't want to do that, since String should not require an engine startup to test a single header.

This lowers the complexity of running the unit tests and even for
physics should be possible to implement such a fix.
2020-07-24 13:05:33 +01:00
Marcel Admiraal 26fcf2b04c Add override keywords. 2020-07-10 13:56:54 +01:00
Fabio Alessandrelli 7a5e10b8a9 Use dummy driver when JS AudioContext is unavailable. 2020-07-01 17:16:13 +02:00
Fabio Alessandrelli 1a637b07b1 Limit FPS in JS by skipping iterations. 2020-07-01 17:16:13 +02:00
Fabio Alessandrelli 07d4513886 [JS] Check canvas size each loop, force redraw.
Fix compatibility issues, achieve smoother resizing.
2020-07-01 17:16:13 +02:00
Fabio Alessandrelli a1c4c1d318 More static methods in DisplayServerJavaScript.
Were static functions in cpp file, polluting global namespace.
2020-07-01 17:16:03 +02:00
Fabio Alessandrelli fd92270b0a Refactor canvas ID and locale handling. 2020-07-01 13:10:05 +02:00
Fabio Alessandrelli 5b1cc2d1fc Fix FS error on JS startup due to existing folder. 2020-07-01 13:10:05 +02:00
Fabio Alessandrelli 5c75cb0133 Immediately run first iteration after JS FS sync.
Which is now run inside an animation frame.
This avoid a 1 frame black screen when setting up the canvas.
2020-06-14 16:04:45 +02:00
Fabio Alessandrelli 0a35b97b62 Swtich HTML5 key detection from keyCode to code.
The value of this, does not include the layout.
The code has extra logic to map the unicode value to our keylist,
supporting ASCII and Latin-1.
Also add support for `physical_keycode` in HTML5 platform.
2020-06-04 21:15:05 +02:00
Fabio Alessandrelli 57bdb4cc35 Fix JS audioContext parameters.
Were not passed along correctly.
`latencyHint` is supposed to be in seconds, not milliseconds.
2020-05-25 15:33:19 +02:00
Fabio Alessandrelli 90c7102b51 Move mix_rate, ouput_latency to AudioDriverManager
Each driver used to define the (same) project settings values
`audio/mix_rate` and `audio/output_latency`, but the setting names are
not driver specific.
Overriding is still possible via platform tags.
2020-05-18 13:02:06 +02:00
Fabio Alessandrelli 245c179bd3 AudioDriverJavaScript now compute buffer size.
Based on mix rate and expected latency.
2020-05-18 13:02:06 +02:00
Rémi Verschelde 0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde 07bc4e2f96 Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
  -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
  -o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```

This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.

This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 710b34b702 Style: Fix missing/invalid copyright headers 2020-05-14 16:54:54 +02:00
Rémi Verschelde 1f6f364a56 Port member initialization from constructor to declaration (C++11)
Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
2020-05-14 10:01:56 +02:00
Marcel Admiraal e7fee711b3 Update game controller enums. 2020-05-13 10:33:32 +01:00
Fabio Alessandrelli 3097c2da96 Add WebSocket debugger, use it for Javascript. 2020-05-12 15:09:13 +02:00
Fabio Alessandrelli 6a49b83e39 Add drop files function 2020-05-10 18:22:48 +02:00
Fabio Alessandrelli d2eef39731 Fix Closure compiler build, python style.
Move copyToFS into utils.js library included with '--pre-js'.
2020-05-10 18:22:48 +02:00
Fabio Alessandrelli 7411e7fd37 DisplayServerJavaScript implementation. 2020-05-10 18:22:48 +02:00
Fabio Alessandrelli ee99cd42d5 [HTML5] Locale, input fix, context, exit.
Add missing semicolumns in engine.js
Add optional extra args to JS Engine.startGame
Remove loader.js, explicit noExitRuntime.
Also add onExit callback (undocumented in emscripten)
2020-05-10 18:19:23 +02:00
Rémi Verschelde 69de7ce38c Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine
Part of #33027.
2020-05-10 13:13:54 +02:00
Fabio Alessandrelli c7e662199f
Merge pull request #37414 from Schroedi/fix_html_mouse_input
Move wheel handlers from window to canvas element in HTML
2020-05-01 12:51:35 +02:00
Rémi Verschelde fdf58a5858 Rename InputFilter back to Input
It changed name as part of the DisplayServer and input refactoring
in #37317, with the rationale that input no longer goes through the
main loop, so the previous Input singleton now only does filtering.

But the gains in consistency are quite limited in the renaming, and
it breaks compatibility for all scripts and tutorials that access
the Input singleton via the scripting language. A temporary option
was suggested to keep the scripting singleton named `Input` even if
its type is `InputFilter`, but that adds inconsistency and breaks C#.

Fixes godotengine/godot-proposals#639.
Fixes #37319.
Fixes #37690.
2020-04-28 15:19:49 +02:00
Christoph Schröder b1e8ac7b08 Move mouse wheel handler from window to canvas element in HTML
Similar to https://github.com/godotengine/godot/pull/36557

At least in chrome, the following error is printed for each mouse wheel
rotation:
[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312

This PR moves the handler to the canvas and thereby fixes the error.

Tested on: Chrome and Firefox (MacOS), Firefox, Chrome(Android), Safari (IPad + MacOS)
2020-04-28 08:42:41 +02:00
Hugo Locurcio eecce139ea Set the title tag in the HTML5 export immediately
This makes the project title display without having to wait for
the project to finish loading.
2020-04-22 11:31:14 +02:00
lupoDharkael 95a1400a2a Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rémi Verschelde cd4e46ee65 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.
2020-03-30 09:05:53 +02:00
Juan Linietsky a6f3bc7c69 Renaming of servers for coherency.
VisualServer -> RenderingServer
PhysicsServer -> PhysicsServer3D
Physics2DServer -> PhysicsServer2D
NavigationServer -> NavigationServer3D
Navigation2DServer -> NavigationServer2D

Also renamed corresponding files.
2020-03-27 15:21:27 -03:00
Juan Linietsky 8e6960a69e Refactored input, goes all via windows now.
Also renamed Input to InputFilter because all it does is filter events.
2020-03-26 15:49:39 +01:00
Juan Linietsky 4396e98834 Refactored Input, create DisplayServer and DisplayServerX11 2020-03-26 15:49:32 +01:00
Rajat Goswami 2ecf928ae3 Adding missing include guards to header files identified by LGTM.
This addresses the issue godotengine/godot#37143
2020-03-23 04:52:36 -04:00
Rémi Verschelde cb282c6ef0 Style: Set clang-format Standard to Cpp11
For us, it practically only changes the fact that `A<A<int>>` is now
used instead of the C++03 compatible `A<A<int> >`.

Note: clang-format 10+ changed the `Standard` arguments to fully
specified `c++11`, `c++14`, etc. versions, but we can't use `c++17`
now if we want to preserve compatibility with clang-format 8 and 9.
`Cpp11` is still supported as deprecated alias for `Latest`.
2020-03-17 07:36:24 +01:00
Fabio Alessandrelli 919bbf8077 [HTML5] Refactor JS, threads support, closures.
- Refactored the Engine code, splitted across files.
- Use MODULARIZE option to build emscripten code into it's own closure.
- Enable lto support (saves ~2MiB in release).
- Enable optional closure compiler pass for JS and generated code.
- Enable optional pthreads support.
- Can now build with tools=yes (not much to see yet).
- Dropped some deprecated code for older toolchains.
2020-03-11 16:09:31 +01:00
Fabio Alessandrelli bd04ede5ad AudioDriverJavascript uses IDHandler.
This makes closure compiler happy, avoiding globals and potentially
undefined variables.
2020-03-11 11:34:32 +01:00
Fabio Alessandrelli aa8c825855 OS_Javascript temporarly uses dummy rasterizer. 2020-03-08 03:35:13 +01:00
Fabio Alessandrelli fd035c931d Fix Javascript platform after PoolVector removal.
Eval should be rechecked.
2020-03-08 03:35:13 +01:00
Fabio Alessandrelli 80582ffa66
Merge pull request #36557 from Schroedi/fix_html_touch
Fixes touch events for HTML
2020-03-03 16:08:18 +01:00
Rémi Verschelde e2b66cacf7
Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodes
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
2020-03-01 23:00:42 +01:00
Pedro J. Estébanez 18fbdbb456 Reimplement Mutex with C++'s <mutex>
Main:
- It's now implemented thanks to `<mutex>`. No more platform-specific implementations.
- `BinaryMutex` (non-recursive) is added, as an alternative for special cases.
- Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes.
- Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts.
- A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this.
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- Thread-safe utilities are therefore simpler now.

Misc.:
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
- Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock).
- `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-26 20:40:10 +01:00
Christoph Schroeder 5134317afc Fixes touch events for HTML
Without this patch, the following exception is thrown when the touch
screen is used: TypeError: e.getBoundingClientRect is not a function.
No touch events arrive in the engine.

From my testing, this PR fixes the issue and behaves as expected.

Tested with godot-demo-projects/misc/multitouch_view/, emscripten 1.39.8
and Firefox mobile emulator as well as FF on Android
2020-02-26 12:04:18 +01:00
Juan Linietsky 33b5c57199 Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.

Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.

For Variant, the float datatype is always 64 bits, and exposed as `float`.

We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.

Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 12:55:53 +01:00
bruvzg 1af06d3d46
Rename scancode to keycode.
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap.
Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
2020-02-25 12:30:33 +02:00
Juan Linietsky 3205a92ad8 PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are
sugar for `Vector<Type>`.
2020-02-18 10:10:36 +01:00
Rémi Verschelde 3dea5fd631 Remove incomplete battery status/power API
It was initially implemented in #5871 for Godot 3.0, but never really
completed or thoroughly tested for most platforms. It then stayed in
limbo and nobody seems really keen to finish it, so it's better to
remove it in 4.0, and re-add eventually (possibly with a different API)
if there's demand and an implementation confirmed working on all
platforms.

Closes #8770.
2020-02-14 13:43:32 +01:00
Rémi Verschelde 386968ea97 Remove obsolete GLES3 backend
Due to the port to Vulkan and complete redesign of the rendering backend,
the `drivers/gles3` code is no longer usable in this state and is not
planned to be ported to the new architecture.

The GLES2 backend is kept (while still disabled and non-working) as it
will eventually be ported to serve as the low-end renderer for Godot 4.0.

Some GLES3 features might be selectively ported to the updated GLES2
backend if there's a need for them, and extensions we can use for that.

So long, OpenGL driver bugs!
2020-02-13 10:36:44 +01:00
Relintai cb29ce8a3b Fix startGame's logic in engine.js. 2020-02-12 23:13:53 +01:00
Juan Linietsky 0586e18449 Custom material support seems complete. 2020-02-11 11:53:29 +01:00
Juan Linietsky 3f335ce3d4 Texture refactor
-Texture renamed to Texture2D
-TextureLayered as base now inherits 2Darray, cubemap and cubemap array
-Removed all references to flags in textures (they will go in the shader)
-Texture3D gone for now (will come back later done properly)
-Create base rasterizer for RenderDevice, RasterizerRD
2020-02-11 11:53:26 +01:00
muiroc e51c6a0d28 Allow per pixel transparency in javascript platform 2020-02-10 14:27:30 +01:00
Fabio Alessandrelli 343b29a651 Merge pull request #35381 from Calinou/html5-export-favicon
Export and reference the icon as favicon when exporting to HTML5
2020-02-08 04:45:53 +01:00
muiroc e563b47dbe Fix javascript platform build 2020-02-07 01:46:15 +01:00
Marcel Admiraal 5af3b4ca27 Remove duplicate ERR_PRINT macro. 2020-02-05 11:13:24 +01:00
Hugo Locurcio 4492cf856b
Export and reference the icon as favicon when exporting to HTML5
This makes the project icon display immediately as a favicon when
opening the page, without having to wait for the project to finish
loading.
2020-02-01 10:33:23 +01:00
Rémi Verschelde 8eef6d280b
Merge pull request #35451 from Calinou/html5-web-environment-only
Only emit the JavaScript support code for Web when building for HTML5
2020-01-31 18:36:29 +01:00
Hugo Locurcio e818b51f32
Only emit the JavaScript support code for Web when building for HTML5
Excluding other unused environments like Node.js makes the support code
about 4 KB smaller.
2020-01-31 12:33:16 +01:00
Rémi Verschelde 68eae6b6e9 Fix some URLs to use HTTPS when available 2020-01-29 02:48:10 +01:00
Hugo Locurcio 90a1f8d8a7
Make OS.execute() blocking by default if not specified
This makes `OS.execute()` calls quicker to set up when calling programs
in a blocking fashion.
2020-01-23 01:26:32 +01:00
Rémi Verschelde b711c09bc8 Revert "Fix audio capture naming in Javascript"
This reverts commit 69f7263cd8.

Follow-up to #35359.
2020-01-20 21:35:19 +01:00
Fabio Alessandrelli 4a50f5ff65 HTML5 callbacks rework.
Fixes compatibility with emscripten 1.39.5+ .
Most input callbacks now require a target and no longer support NULL
defaults.

This commit changes all required null targets to the expected default in
the binding phase.
Since for canvas-related callbacks there is no default, the "#canvas"
selector is used instead.
Additionally, since canvasX and canvasY event properties are no longer
supported, event positions are computed from "clientX" and "clientY" and
the "#canvas" bounding client rect.
2020-01-17 21:42:36 +01:00
Rémi Verschelde 435f86cf87 HTML5: Address removal of 'timestamp' in Emscripten 1.39.5
It was removed as noted in the changelog:
https://github.com/emscripten-core/emscripten/blob/1.39.5/ChangeLog.md#v1395-12202019

> Removed `timestamp` field from mouse, wheel, devicemotion and
> deviceorientation events. The presence of a `timestamp` on these
> events was slightly arbitrary, and populating this field caused
> a small profileable overhead that all users might not care about.
> It is easy to get a timestamp of an event by calling
> `emscripten_get_now()` or `emscripten_performance_now()` inside
> the event handler function of any event.

Fixes #34648.
2020-01-17 14:10:52 +01:00
Fabio Alessandrelli 14a58560e1 Properly close files served by debug HTTP server. 2020-01-14 17:07:06 +01:00
Fabio Alessandrelli 1798496ea7 Add mime type to responses from debug HTTP server.
Get rid of warnings in firefox mentioning performance loss when no mime
type is given for wasm files.
2020-01-14 17:07:06 +01:00
Rémi Verschelde 5011afcb6a Export: Improve usability of command line interface
I'm barely scratching the surface of the changes needed to make the
--export command line interface easy to use, but this should already
improve things somewhat.

- Streamline `can_export()` templates check in all platforms, checking
  first for the presence of official templates, then of any defined
  custom template, and reporting on the absence of any.
  Shouldn't change the actual return value much which is still true if
  either release or debug is usable - we might want to change that
  eventually and better validate against the requested target.

- Fix discrepancy between platforms using `custom_package/debug` and
  `custom_template/debug` (resp. `release`).
  All now use `custom_template`, which will break compatibility for
  `export_presets.cfg` with earlier projects (but is easy to fix).

- Use `can_export()` when attempting a command line export and report
  the same errors that would be shown in the editor.

- Improve error reporting after a failed export attempt, handling
  missing template and invalid path more gracefully.

- Cleanup of unused stuff in EditorNode around the export workflow.

- Improve --export documentation in --help a bit.

Fixes #16949 (at least many of the misunderstandings listed there).
Fixes #18470.
2020-01-07 14:25:56 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Rémi Verschelde 6d6280dfa3 Emscripten: Re-add BINARYEN_TRAP_MODE='clamp' for fastcomp
The option is needed when using the 'fastcomp' backend (default before
1.39.0), and must not be defined when using 'upstream' (new default).
So we define it conditionally to support both backends.

Follow-up to #30751.
2019-12-03 13:33:35 +01:00
bruvzg 2ef8c5fac5
iOS modular build and export implementation. 2019-12-01 21:57:18 +02:00
Fabio Alessandrelli ed19b4076e Add download_chunk_size property to HTTPRequest.
This allows setting the `read_chunk_size` of the internal HTTPClient.
This is important to reduce the allocation overhead and number of file
writes when downloading large files, allowing for better download speed.
2019-11-24 19:32:20 +01:00
Rémi Verschelde 02913f53d3 pcre2: Use scons option to disable JIT on some platforms
Third-party platforms (e.g. console ports) need to be able to
disable JIT support in the regex module too, so it can't be
hardcoded in the module SCsub. This is cleaner this way anyway.

Fixes #19316.
2019-11-20 08:54:52 +01:00
Rémi Verschelde e5dfcb5edd HTML5: Explicitly link idbfs.js for IDBFS support
Upstream Emscripten changed this in 1.39.1+, so IDBFS is no longer
included by default and has to be linked manually.

The explicit linking doesn't seem to be problematic on earlier
versions (tested `1.38.47-upstream`).

Fixes #33724.
2019-11-19 09:45:43 +01:00
Rémi Verschelde e9e2a4b044 HTML5: Fix support for Emscripten 1.39.1+
A change in upstream Emscripten 1.39.1+ made our buildsystem error
out where it was previously only issuing a warning:
```
[  5%] Linking Static Library ==> main/libmain.javascript.opt.bc
shared:WARNING: Assuming object file output in the absence of `-c`, based on output filename. Please add with `-c` or `-r` to avoid this warning
Ranlib Library         ==> main/libmain.javascript.opt.bc
/opt/emsdk/upstream/bin/llvm-ranlib: error: unable to load 'main/libmain.javascript.opt.bc': file too small to be an archive
```

As advised on emscripten-core/emscripten#9806, we should be using
`emar` here to create the static library and not `emcc`.
This was apparently done to workaround Emscripten issues in the past,
but evidently this is no longer necessary.

The rest of the `env` redefinitions should probably be re-assessed
against the current state of Emscripten.

Fixes #33374.
2019-11-15 09:39:19 +01:00
Fabio Alessandrelli 9d13a37b81 Remove ECMAScript 6 "arrow operator".
We don't need it, it's not well supported by compilers, and it was a
mistake in the first place.
2019-10-24 16:46:31 +02:00
Fabio Alessandrelli ab1e809426 Implement HTTP server for HTML5 export
Since most browsers no longer allow making async requests from a page
loaded from `file://`, we now need a proper HTTP server to load the
exported HTML5 game.
This should also allow us to get the debugger to work over a WebSocket
connection.
2019-10-23 10:59:03 +02:00
Fabio Alessandrelli 53637e4b1c Improve EditorExportPlatform interface.
Convert all get_device* methods to get_option* and normalize their usage
as icon, label, tooltip.
2019-10-23 10:59:03 +02:00
Hugo Locurcio c8a8be6dd1
Optimize images losslessly using oxipng -o6 --strip all --zopfli 2019-10-12 23:23:33 +02:00
Marcel Admiraal a8836ba28d Remove dependency on the editor directory being in the build's include path.
- Add or remove the necessary subdirectorires to the includes to remove
dependency on the editor directory being in the build's include path.
- Ensure includes in modified files conform to style guideline.
- Remove editor from the build include path.
2019-10-10 08:57:00 +02:00
PouleyKetchoupp 5bfe32eaa4 Properly revert cursor when using set_custom_mouse_cursor with null
Fixes #32486
2019-10-03 13:02:11 +02:00
Relintai 6f1d6cfc78 Fixed running the export templates with newer emscripten versions. 2019-10-01 15:41:19 +02:00
qarmin 17732fe698 Added some obvious errors explanations 2019-09-25 10:28:50 +02:00
mellondill 3c176827d6 https://github.com/godotengine/godot/issues/31297 - HTML5: this.rtenv.callMain is not a function when using latest-upstream backend
Added needed changed for normal compiling with emscripten 1.38.41 and later
2019-08-12 21:59:27 +03:00
Rémi Verschelde 37a16fee05 Export: Remove temp files from cache after export
So far we left most temporary files lying around, so this attempts to
fix that.

I added a helper method to DirAccess to factor out the boilerplate of
creating a DirAccess, checking if the file exists, remove it or print
an error on failure.
2019-08-12 13:31:59 +02:00
Saracen 69f7263cd8 Fix audio capture naming in Javascript 2019-08-09 23:22:30 +01:00
Robin Hübner 6ab118c464 Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in "platform", "modules/gdnative", "modules/gdscript" directories. 2019-08-09 11:13:24 +02:00
Rémi Verschelde 63544e6b02 Emscripten: Do not define BINARYEN_TRAP_MODE='clamp'
It is not supported in Emscripten's `latest-upstream` LLVM backend,
and doesn't seem necessary in the `latest` backend either.
It was initially added in #22857 to solve a compilation error with the latter.

Part of #30270.
2019-07-22 13:21:56 +02:00
Rémi Verschelde 3e40827050
Merge pull request #30465 from guilhermefelipecgs/cursor_blinking
Fix cursor blinking in integrated GPUs
2019-07-10 13:33:11 +02:00
Guilherme Felipe a9a0d0fb15 Fix cursor blinking in integrated GPUs
Optimization for Input::set_custom_mouse_cursor when used inside
_process function. (Avoids cursor blinking in low end devices)
2019-07-09 19:38:25 -03:00
Fabio Alessandrelli 0c19674621 Better detect Emscripten toolchain.
Emscripten is apparently changing the variables in its config file,
causing potential breakage of our build system.

Binaries of the latest/latest-upstream releases are located in a
subfolder of BINARYEN_ROOT called emscripten.
Binaries of the other releases (e.g. sdk-1.38.31-64bit) are instead
placed under the EMSCRIPTEN_ROOT folder.

This PR checks if BINARYEN_ROOT has a subfolder called emscripten, if
that does not exists, it falls back to checking the EMSCRIPTEN_ROOT.

This way we give precedence to the new releases, given that activating
multiple releases sequentially might result in having mismatching
BINARYEN_ROOT and EMSCRIPTEN_ROOT.
2019-07-09 19:17:27 +02:00
Rémi Verschelde 771aa9a779
Merge pull request #29482 from Calinou/html5-fix-emscripten-root
Fix Emscripten root directory detection when building for HTML5
2019-07-01 13:52:22 +02:00
Hugo Locurcio e08fa103f2
Fix Emscripten root directory detection when building for HTML5
Recent Emscripten SDK versions seem to only include the
`BINARYEN_ROOT` variable in the Emscripten configuration file,
whereas the platform's `detect.py` only looked at `EMSCRIPTEN_ROOT`.
2019-06-19 22:23:58 +02:00
JohnJLight 38d3bfe971 Made use of semicolons more consitent, fixed formatting 2019-06-19 15:24:31 +02:00
Rémi Verschelde 24ee8c3566 Add script to fix style issues and copyright headers
This is only meant to check the validity of the whole codebase every
now and then, or to apply clang-format config changes when relevant.
2019-06-17 13:35:47 +02:00
Rémi Verschelde baab976d0f
Merge pull request #10643 from BastiaanOlij/camera_server
CameraServer class
2019-06-16 10:22:26 +02:00
Rémi Verschelde 1e483d7c73
Merge pull request #29786 from dotdigitalgroup/hidpi-javascript-fix-master
Fix pointer position in hidpi-corrected resolutions on web
2019-06-15 23:06:02 +02:00
Rémi Verschelde 68735d2a88 Fix compilation warnings in JS and Windows builds
Warnings raised by Emscripten 1.38.0 and MinGW64 5.0.4 / GCC 8.3.0.

JS can now build with `werror=yes warnings=extra`.
MinGW64 still has a few warnings to resolve with `warnings=extra`,
and only one with `warnings=all`.

Part of #29033 and #29801.
2019-06-15 14:40:45 +02:00
BastiaanOlij 02ea99129e Adding a new Camera Server implementation to Godot.
This is a new singleton where camera sources such as webcams or cameras on a mobile phone can register themselves with the Server.
Other parts of Godot can interact with this to obtain images from the camera as textures.
This work includes additions to the Visual Server to use this functionality to present the camera image in the background. This is specifically targetted at AR applications.
2019-06-15 21:30:32 +10:00
Leonardo Giovanni Scur 31cc1bdb58 Fix pointer position in hidpi-corrected resolutions on web 2019-06-14 17:37:21 -03:00
Rémi Verschelde 6d16f2f053 Fix error macro calls not ending with semicolon
It's not necessary, but the vast majority of calls of error macros
do have an ending semicolon, so it's best to be consistent.
Most WARN_DEPRECATED calls did *not* have a semicolon, but there's
no reason for them to be treated differently.
2019-06-11 14:49:34 +02:00
Fabio Alessandrelli ce542bced1 Implement Clipboard API read when supported.
Being async, the first time a value is pasted GUI elements will still
return the previous one.
This at least until 'clipboardchange' window event gets implemented by
user agents.
2019-05-29 23:21:09 +02:00
Fabio Alessandrelli 2b436dd50e Kinda working HTML5 clipboard paste.
Listen to paste events to update local clipboard.
CTRL+V still not working out of the box.
To do that, We would need to change how we handle keypress, most likely
making it worse and less safe. In the end, I'm not sure we can fix it
properly for now. Maybe in the future, with the Clipboard API, support
of which is still pretty limited on chrome, and only available to
extensions in Firefox.

For now, you can paste via:
- Browser bar -> Edit -> Paste.
- Middle mouse click (Linux only, copies secondary clipboard).

And THEN press CTRL+V
2019-05-29 23:21:09 +02:00
Fabio Alessandrelli 0f76df2397 Add OS clipboard set support to OS Javascript 2019-05-28 12:59:29 +02:00
Rémi Verschelde c29ef774d8
Merge pull request #29032 from akien-mga/tools-exceptions-rtti
SCons: Keep exceptions and rtti on Android, iOS and HTML5 tools build
2019-05-21 17:10:51 +02:00
hbina085 f78baa5f93 added a const keyword for a methods that return constant literal... 2019-05-21 02:16:30 -04:00
Rémi Verschelde 4b20959d99 SCons: Keep exceptions and rtti on Android, iOS and HTML5 tools build
Those were disable to keep size small, and on Android avoid the dependency on the STL,
but for tools build (editor) this is not really a concern.

Note: as of today it's not possible to build tools=yes for those platforms, but this
change is one of the necessary steps to enable it.

Fixes #25262.
2019-05-20 16:51:20 +02:00
Fabio Alessandrelli 6622091eaf Fix OS_Javascript execute method
Signature was changed in OS via:

cd4449e7ab
2019-05-15 19:24:20 +02:00
Rémi Verschelde d52b70fb5e SCons: Always use env.Prepend for CPPPATH
Include paths are processed from left to right, so we use Prepend to
ensure that paths to bundled thirdparty files will have precedence over
system paths (e.g. `/usr/include` should have lowest priority).
2019-04-30 13:12:06 +02:00