stevenarella/www
iceiix 0471eb3a82 Use web-sys for web backend (#444)
A small step for #446 🕸️ Web support, use web-sys to interface to the web.
Previously, we would try to use glutin on the web, which is not supported;
now glutin is only used on native: fixes #171 could not find Context in platform_impl.

winit is still used on both, but the GL context is created with web-sys and glow
(on the web), and created with glutin and used with glow (on native). stdweb is
no longer used, being replaced by web-sys.

Substantial refactoring to allow reusing the code between web/native:

* settings: use VirtualKeyCode from winit, not reexported from glutin
* std_or_web: remove broken localstoragefs/stdweb, add File placeholder
* render: disable skin_thread on wasm since we don't have threads

* gl: use glow types in gl wrapper (integers in native, but Web*Key in web)
* gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't
* gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web
* gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper

* glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2

* shaders: add explicit float/int type conversions, required for WebGL
* shaders: specify mediump precision, required for WebGL
* shaders: specify fragment shader output locations for WebGL

* main: refactor handle_window_event to take a winit window, not glutin context
* main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this)
* main: use winit events in handle_window_event not reexported glutin events
* main: refactor game loop handling into tick_all()
* main: create winit window for WebGL, and use winit_window from glutin
* main: restore console_error_panic_hook,  mistakingly removed in (#260)
* main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web

* www: index.js: fix wasm import path
* www: npm update, npm audit fix
* www: update readme to link to status on #446 🕸️ Web support
2020-12-26 13:43:21 -08:00
..
.gitignore Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
README.md Use web-sys for web backend (#444) 2020-12-26 13:43:21 -08:00
bootstrap.js Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
index.html Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00
index.js Use web-sys for web backend (#444) 2020-12-26 13:43:21 -08:00
package-lock.json Use web-sys for web backend (#444) 2020-12-26 13:43:21 -08:00
package.json Use web-sys for web backend (#444) 2020-12-26 13:43:21 -08:00
webpack.config.js Add support for compiling WebAssembly wasm32-unknown-unknown target (#92) 2019-03-03 08:32:36 -08:00

README.md

stevenarella-web

Web app for running Stevenarella as WebAssembly

Status: very incomplete. It currently compiles but does not run, due to required modifications to adapt to the web, for progress see: 🕸️ Web support

Building

To build for wasm32-unknown-unknown, run in the top-level directory (not www):

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli
wasm-pack build

or:

cargo web start --target wasm32-unknown-unknown

Running

After building the Rust app, run the NodeJS web server as follows:

cd pkg
npm link
cd ..
cd www
npm link stevenarella
npm install
npm start
open http://localhost:8080/

Credits

Based on rustwasm/create-wasm-app:

An npm init template for kick starting a project that uses NPM packages containing Rust-generated WebAssembly and bundles them with Webpack.