Emscripten rework (#286)
* partial implementation for emscripten
this pull request contain a partial but working implementation of emscripten backend
some implementations may be controversial.
here some implementation detail:
* cursor state:
* on grab: emscripten request pointer lock deferred and also set a callback when pointer lock change
the callback request pointer lock deferred.
* on hide: `emscripten_hide_mouse` exist but not `emscripten_show_mouse`
a pull request has been open on october 2016 but never been merged
so I copied the javascript function and put it in emscripten_asm_const function
* fullscreen: if fullscreen is requested then it request fullscreen deferred and set a callback on fullscreen change
the callback request fullscreen deferred
* run forever: this method use emscripten main loop to run an infinite loop
* keyboard callback doesn't consume the event. I think it is more apopriate as in desktop environment it is the same, is it ?
* emscripten dir is added in example and contains html pages
Some things that are not implemented:
* lots of events
* min and max dimension can be implemented with a callback that listen to size change and resize if dimension out of bound
* title may be implemented using javascript to change document.title
* Use std::os::raw in the emscripten bindings
* Fix emscripten code
* Update code
* Add CI
* Remove the emscripten-specific examples
* Add some information to the README
This commit is contained in:
parent
ae7802c8c2
commit
769d4fe897
5 changed files with 709 additions and 6 deletions
12
README.md
12
README.md
|
|
@ -41,3 +41,15 @@ fn main() {
|
|||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Platform-specific usage
|
||||
|
||||
#### Emscripten and WebAssembly
|
||||
|
||||
Building a binary will yield a `.js` file. In order to use it in an HTML file, you need to:
|
||||
|
||||
- Put a `<canvas id="my_id"></canvas>` element somewhere. A canvas corresponds to a winit "window".
|
||||
- Write a Javascript code that creates a global variable named `Module`. Set `Module.canvas` to
|
||||
the ID of the `<canvas>` element (in the example this would be `"my_id"`). More information
|
||||
[here](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
|
||||
- Make sure that you insert the `.js` file generated by Rust after the `Module` variable is created.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue