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
This commit is contained in:
parent
0aa062f4b8
commit
0471eb3a82
|
@ -110,12 +110,6 @@ version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base-x"
|
|
||||||
version = "0.2.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
@ -376,6 +370,16 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "console_error_panic_hook"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.10",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const_fn"
|
name = "const_fn"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
|
@ -590,12 +594,6 @@ dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "discard"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -706,38 +704,12 @@ dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-channel-preview"
|
|
||||||
version = "0.3.0-alpha.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core-preview",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-core"
|
name = "futures-core"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748"
|
checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-core-preview"
|
|
||||||
version = "0.3.0-alpha.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-executor-preview"
|
|
||||||
version = "0.3.0-alpha.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core-preview",
|
|
||||||
"futures-util-preview",
|
|
||||||
"num_cpus",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-io"
|
name = "futures-io"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
|
@ -774,17 +746,6 @@ dependencies = [
|
||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-util-preview"
|
|
||||||
version = "0.3.0-alpha.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core-preview",
|
|
||||||
"pin-utils",
|
|
||||||
"slab",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.4"
|
version = "0.14.4"
|
||||||
|
@ -830,7 +791,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glow"
|
name = "glow"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "git+https://github.com/iceiix/glow?rev=45c808678735e03737d5e1b9d6ed0e21070edcd9#45c808678735e03737d5e1b9d6ed0e21070edcd9"
|
source = "git+https://github.com/iceiix/glow?rev=b354346dee69ff0ca7ccef67f7580dfbb697423b#b354346dee69ff0ca7ccef67f7580dfbb697423b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
|
@ -954,12 +915,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hex"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hex"
|
name = "hex"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -1089,7 +1044,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"stdweb",
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1182,16 +1139,6 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "localstoragefs"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6ba6cbee6bbe7e6ea61ad375952239a9678624f216a0f442ae04a90260e76cdf"
|
|
||||||
dependencies = [
|
|
||||||
"hex 0.3.2",
|
|
||||||
"stdweb",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -2093,15 +2040,6 @@ dependencies = [
|
||||||
"simple_asn1",
|
"simple_asn1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusttype"
|
name = "rusttype"
|
||||||
version = "0.9.2"
|
version = "0.9.2"
|
||||||
|
@ -2178,21 +2116,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.118"
|
version = "1.0.118"
|
||||||
|
@ -2249,12 +2172,6 @@ dependencies = [
|
||||||
"opaque-debug 0.3.0",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha1"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shared_library"
|
name = "shared_library"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
|
@ -2338,64 +2255,8 @@ name = "std_or_web"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"localstoragefs",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb"
|
|
||||||
version = "0.4.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
|
|
||||||
dependencies = [
|
|
||||||
"discard",
|
|
||||||
"futures-channel-preview",
|
|
||||||
"futures-core-preview",
|
|
||||||
"futures-executor-preview",
|
|
||||||
"futures-util-preview",
|
|
||||||
"rustc_version",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"stdweb-derive",
|
|
||||||
"stdweb-internal-macros",
|
|
||||||
"stdweb-internal-runtime",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-derive"
|
|
||||||
version = "0.5.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-internal-macros"
|
|
||||||
version = "0.2.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
|
|
||||||
dependencies = [
|
|
||||||
"base-x",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
"sha1",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-internal-runtime"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "steven_blocks"
|
name = "steven_blocks"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
@ -2414,7 +2275,7 @@ dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cfb8",
|
"cfb8",
|
||||||
"flate2",
|
"flate2",
|
||||||
"hex 0.4.2",
|
"hex",
|
||||||
"log",
|
"log",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
@ -2443,6 +2304,7 @@ dependencies = [
|
||||||
"cgmath",
|
"cgmath",
|
||||||
"clipboard",
|
"clipboard",
|
||||||
"collision",
|
"collision",
|
||||||
|
"console_error_panic_hook",
|
||||||
"flate2",
|
"flate2",
|
||||||
"glow",
|
"glow",
|
||||||
"glutin",
|
"glutin",
|
||||||
|
@ -2456,13 +2318,13 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"std_or_web",
|
"std_or_web",
|
||||||
"stdweb",
|
|
||||||
"steven_blocks",
|
"steven_blocks",
|
||||||
"steven_protocol",
|
"steven_protocol",
|
||||||
"steven_resources",
|
"steven_resources",
|
||||||
"steven_shared",
|
"steven_shared",
|
||||||
"structopt",
|
"structopt",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
"winit",
|
"winit",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
@ -3053,8 +2915,9 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"smithay-client-toolkit",
|
"smithay-client-toolkit",
|
||||||
"stdweb",
|
"wasm-bindgen",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
|
"web-sys",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
"x11-dl",
|
"x11-dl",
|
||||||
]
|
]
|
||||||
|
|
|
@ -20,8 +20,8 @@ opt-level = 1
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
wasm-bindgen = "0.2.69"
|
wasm-bindgen = "0.2.69"
|
||||||
glutin = "0.26.0"
|
winit = { version = "0.24.0", features = [ "web-sys" ]}
|
||||||
glow = { git = "https://github.com/iceiix/glow", rev = "45c808678735e03737d5e1b9d6ed0e21070edcd9" }
|
glow = { git = "https://github.com/iceiix/glow", rev = "b354346dee69ff0ca7ccef67f7580dfbb697423b" }
|
||||||
byteorder = "1.3.4"
|
byteorder = "1.3.4"
|
||||||
serde = "1.0.118"
|
serde = "1.0.118"
|
||||||
serde_json = "1.0.60"
|
serde_json = "1.0.60"
|
||||||
|
@ -42,10 +42,11 @@ clipboard = "0.5.0"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
reqwest = { version = "0.10.10", features = [ "blocking" ]}
|
reqwest = { version = "0.10.10", features = [ "blocking" ]}
|
||||||
|
glutin = "0.26.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
stdweb = "0.4.20"
|
console_error_panic_hook = "0.1.6"
|
||||||
winit = { version = "0.24.0", features = [ "stdweb" ]}
|
web-sys = "0.3.46"
|
||||||
|
|
||||||
[dependencies.steven_resources]
|
[dependencies.steven_resources]
|
||||||
path = "./resources"
|
path = "./resources"
|
||||||
|
|
|
@ -44,12 +44,6 @@ version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base-x"
|
|
||||||
version = "0.2.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
@ -166,12 +160,6 @@ dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "discard"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding_rs"
|
name = "encoding_rs"
|
||||||
version = "0.8.26"
|
version = "0.8.26"
|
||||||
|
@ -347,12 +335,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hex"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hex"
|
name = "hex"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -502,16 +484,6 @@ version = "0.2.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
|
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "localstoragefs"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6ba6cbee6bbe7e6ea61ad375952239a9678624f216a0f442ae04a90260e76cdf"
|
|
||||||
dependencies = [
|
|
||||||
"hex 0.3.2",
|
|
||||||
"stdweb",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.11"
|
version = "0.4.11"
|
||||||
|
@ -874,15 +846,6 @@ dependencies = [
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
@ -922,38 +885,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.118"
|
version = "1.0.118"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.118"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.60"
|
version = "1.0.60"
|
||||||
|
@ -990,12 +927,6 @@ dependencies = [
|
||||||
"opaque-debug 0.3.0",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha1"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -1018,60 +949,8 @@ name = "std_or_web"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"localstoragefs",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb"
|
|
||||||
version = "0.4.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
|
|
||||||
dependencies = [
|
|
||||||
"discard",
|
|
||||||
"rustc_version",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"stdweb-derive",
|
|
||||||
"stdweb-internal-macros",
|
|
||||||
"stdweb-internal-runtime",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-derive"
|
|
||||||
version = "0.5.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-internal-macros"
|
|
||||||
version = "0.2.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
|
|
||||||
dependencies = [
|
|
||||||
"base-x",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
"sha1",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-internal-runtime"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "steven_protocol"
|
name = "steven_protocol"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
@ -1080,7 +959,7 @@ dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cfb8",
|
"cfb8",
|
||||||
"flate2",
|
"flate2",
|
||||||
"hex 0.4.2",
|
"hex",
|
||||||
"log",
|
"log",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
use aes::Aes128;
|
use aes::Aes128;
|
||||||
use cfb8::stream_cipher::{NewStreamCipher, StreamCipher};
|
use cfb8::stream_cipher::{NewStreamCipher, StreamCipher};
|
||||||
use cfb8::Cfb8;
|
use cfb8::Cfb8;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
use std_or_web::fs;
|
use std_or_web::fs;
|
||||||
|
|
||||||
pub mod forge;
|
pub mod forge;
|
||||||
|
|
|
@ -22,12 +22,9 @@ use std::ops::{Deref, DerefMut};
|
||||||
static mut CONTEXT: *mut glow::Context = 0 as *mut glow::Context;
|
static mut CONTEXT: *mut glow::Context = 0 as *mut glow::Context;
|
||||||
|
|
||||||
/// Inits the gl library. This should be called once a context is ready.
|
/// Inits the gl library. This should be called once a context is ready.
|
||||||
pub fn init(vid: &glutin::WindowedContext<glutin::PossiblyCurrent>) {
|
pub fn init(context: glow::Context) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let context = Box::new(gl::Context::from_loader_function(|s| {
|
CONTEXT = Box::into_raw(Box::new(context));
|
||||||
vid.get_proc_address(s) as *const _
|
|
||||||
}));
|
|
||||||
CONTEXT = Box::into_raw(context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +259,7 @@ pub const CLAMP_TO_EDGE: TextureValue = gl::CLAMP_TO_EDGE as TextureValue;
|
||||||
|
|
||||||
/// `Texture` is a buffer of data used by fragment shaders.
|
/// `Texture` is a buffer of data used by fragment shaders.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Texture(u32);
|
pub struct Texture(glow::Texture);
|
||||||
|
|
||||||
impl Texture {
|
impl Texture {
|
||||||
// Allocates a new texture.
|
// Allocates a new texture.
|
||||||
|
@ -494,7 +491,7 @@ pub const COMPILE_STATUS: ShaderParameter = gl::COMPILE_STATUS;
|
||||||
pub const INFO_LOG_LENGTH: ShaderParameter = gl::INFO_LOG_LENGTH;
|
pub const INFO_LOG_LENGTH: ShaderParameter = gl::INFO_LOG_LENGTH;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Program(u32);
|
pub struct Program(glow::Program);
|
||||||
|
|
||||||
impl Program {
|
impl Program {
|
||||||
pub fn new() -> Program {
|
pub fn new() -> Program {
|
||||||
|
@ -550,7 +547,7 @@ impl Drop for Program {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Shader(u32);
|
pub struct Shader(glow::Shader);
|
||||||
|
|
||||||
impl Shader {
|
impl Shader {
|
||||||
pub fn new(ty: ShaderType) -> Shader {
|
pub fn new(ty: ShaderType) -> Shader {
|
||||||
|
@ -582,8 +579,8 @@ impl Shader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone)]
|
||||||
pub struct Uniform(u32);
|
pub struct Uniform(glow::UniformLocation);
|
||||||
|
|
||||||
impl Uniform {
|
impl Uniform {
|
||||||
pub fn set_int(&self, val: i32) {
|
pub fn set_int(&self, val: i32) {
|
||||||
|
@ -688,7 +685,7 @@ impl Attribute {
|
||||||
// This includes buffers, the format of the buffers and enabled
|
// This includes buffers, the format of the buffers and enabled
|
||||||
// attributes.
|
// attributes.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct VertexArray(u32);
|
pub struct VertexArray(glow::VertexArray);
|
||||||
|
|
||||||
impl VertexArray {
|
impl VertexArray {
|
||||||
/// Allocates a new `VertexArray`.
|
/// Allocates a new `VertexArray`.
|
||||||
|
@ -715,7 +712,7 @@ impl Drop for VertexArray {
|
||||||
unsafe {
|
unsafe {
|
||||||
glow_context().delete_vertex_array(self.0);
|
glow_context().delete_vertex_array(self.0);
|
||||||
}
|
}
|
||||||
self.0 = 0;
|
self.0 = glow::VertexArray::default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +746,7 @@ pub const WRITE_ONLY: Access = gl::WRITE_ONLY;
|
||||||
|
|
||||||
/// `Buffer` is a storage for vertex data.
|
/// `Buffer` is a storage for vertex data.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Buffer(u32);
|
pub struct Buffer(glow::Buffer);
|
||||||
|
|
||||||
impl Buffer {
|
impl Buffer {
|
||||||
/// Allocates a new Buffer.
|
/// Allocates a new Buffer.
|
||||||
|
@ -848,7 +845,7 @@ pub const COLOR_ATTACHMENT_2: Attachment = gl::COLOR_ATTACHMENT2;
|
||||||
pub const DEPTH_ATTACHMENT: Attachment = gl::DEPTH_ATTACHMENT;
|
pub const DEPTH_ATTACHMENT: Attachment = gl::DEPTH_ATTACHMENT;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Framebuffer(u32);
|
pub struct Framebuffer(glow::Framebuffer);
|
||||||
|
|
||||||
pub fn check_framebuffer_status() {
|
pub fn check_framebuffer_status() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
357
src/main.rs
357
src/main.rs
|
@ -205,6 +205,7 @@ struct Opt {
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
|
use glow::HasRenderLoop;
|
||||||
extern crate console_error_panic_hook;
|
extern crate console_error_panic_hook;
|
||||||
pub use console_error_panic_hook::set_once as set_panic_hook;
|
pub use console_error_panic_hook::set_once as set_panic_hook;
|
||||||
} else {
|
} else {
|
||||||
|
@ -214,7 +215,7 @@ cfg_if! {
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_os = "unknown")] {
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
|
@ -229,7 +230,6 @@ fn main2() {
|
||||||
let opt = Opt::from_args();
|
let opt = Opt::from_args();
|
||||||
|
|
||||||
set_panic_hook();
|
set_panic_hook();
|
||||||
std::env::set_var("RUST_BACKTRACE", "1");
|
|
||||||
|
|
||||||
let con = Arc::new(Mutex::new(console::Console::new()));
|
let con = Arc::new(Mutex::new(console::Console::new()));
|
||||||
let proxy = console::ConsoleProxy::new(con.clone());
|
let proxy = console::ConsoleProxy::new(con.clone());
|
||||||
|
@ -239,7 +239,7 @@ fn main2() {
|
||||||
|
|
||||||
info!("Starting steven");
|
info!("Starting steven");
|
||||||
|
|
||||||
let (vars, vsync) = {
|
let (vars, mut vsync) = {
|
||||||
let mut vars = console::Vars::new();
|
let mut vars = console::Vars::new();
|
||||||
vars.register(CL_BRAND);
|
vars.register(CL_BRAND);
|
||||||
auth::register_vars(&mut vars);
|
auth::register_vars(&mut vars);
|
||||||
|
@ -253,35 +253,90 @@ fn main2() {
|
||||||
let (res, mut resui) = resources::Manager::new();
|
let (res, mut resui) = resources::Manager::new();
|
||||||
let resource_manager = Arc::new(RwLock::new(res));
|
let resource_manager = Arc::new(RwLock::new(res));
|
||||||
|
|
||||||
let events_loop = glutin::event_loop::EventLoop::new();
|
let events_loop = winit::event_loop::EventLoop::new();
|
||||||
let window_builder = glutin::window::WindowBuilder::new()
|
|
||||||
.with_title("Stevenarella")
|
|
||||||
.with_inner_size(glutin::dpi::LogicalSize::new(854.0, 480.0));
|
|
||||||
let window = glutin::ContextBuilder::new()
|
|
||||||
.with_stencil_buffer(0)
|
|
||||||
.with_depth_buffer(24)
|
|
||||||
.with_gl(glutin::GlRequest::GlThenGles {
|
|
||||||
opengl_version: (3, 2),
|
|
||||||
opengles_version: (2, 0),
|
|
||||||
})
|
|
||||||
.with_gl_profile(glutin::GlProfile::Core)
|
|
||||||
.with_vsync(vsync)
|
|
||||||
.build_windowed(window_builder, &events_loop)
|
|
||||||
.expect("Could not create glutin window.");
|
|
||||||
|
|
||||||
let mut window = unsafe {
|
let window_builder = winit::window::WindowBuilder::new()
|
||||||
window
|
.with_title("Stevenarella")
|
||||||
.make_current()
|
.with_inner_size(winit::dpi::LogicalSize::new(854.0, 480.0));
|
||||||
.expect("Could not set current context.")
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let (context, shader_version, winit_window, render_loop) = {
|
||||||
|
let winit_window = window_builder.build(&events_loop).unwrap();
|
||||||
|
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
use winit::platform::web::WindowExtWebSys;
|
||||||
|
|
||||||
|
let canvas = winit_window.canvas();
|
||||||
|
|
||||||
|
let html_window = web_sys::window().unwrap();
|
||||||
|
let document = html_window.document().unwrap();
|
||||||
|
let body = document.body().unwrap();
|
||||||
|
|
||||||
|
body.append_child(&canvas)
|
||||||
|
.expect("Append canvas to HTML body");
|
||||||
|
|
||||||
|
let canvas = canvas.dyn_into::<web_sys::HtmlCanvasElement>().unwrap();
|
||||||
|
let webgl2_context = canvas
|
||||||
|
.get_context("webgl2")
|
||||||
|
.unwrap()
|
||||||
|
.unwrap()
|
||||||
|
.dyn_into::<web_sys::WebGl2RenderingContext>()
|
||||||
|
.unwrap();
|
||||||
|
(
|
||||||
|
glow::Context::from_webgl2_context(webgl2_context),
|
||||||
|
"#version 300 es", // WebGL 2
|
||||||
|
winit_window,
|
||||||
|
glow::RenderLoop::from_request_animation_frame(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
gl::init(&window);
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
let (context, shader_version, glutin_window) = {
|
||||||
|
let glutin_window = glutin::ContextBuilder::new()
|
||||||
|
.with_stencil_buffer(0)
|
||||||
|
.with_depth_buffer(24)
|
||||||
|
.with_gl(glutin::GlRequest::GlThenGles {
|
||||||
|
opengl_version: (3, 2),
|
||||||
|
opengles_version: (3, 0),
|
||||||
|
})
|
||||||
|
.with_gl_profile(glutin::GlProfile::Core)
|
||||||
|
.with_vsync(vsync)
|
||||||
|
.build_windowed(window_builder, &events_loop)
|
||||||
|
.expect("Could not create glutin window.");
|
||||||
|
|
||||||
let renderer = render::Renderer::new(resource_manager.clone());
|
let glutin_window = unsafe {
|
||||||
|
glutin_window
|
||||||
|
.make_current()
|
||||||
|
.expect("Could not set current context.")
|
||||||
|
};
|
||||||
|
|
||||||
|
let context = unsafe {
|
||||||
|
glow::Context::from_loader_function(|s| glutin_window.get_proc_address(s) as *const _)
|
||||||
|
};
|
||||||
|
|
||||||
|
let shader_version = match glutin_window.get_api() {
|
||||||
|
glutin::Api::OpenGl => "#version 150", // OpenGL 3.2
|
||||||
|
glutin::Api::OpenGlEs => "#version 300 es", // OpenGL ES 3.0 (similar to WebGL 2)
|
||||||
|
glutin::Api::WebGl => {
|
||||||
|
panic!("unexpectedly received WebGl API with glutin, expected to use glow codepath")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(context, shader_version, glutin_window)
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
let winit_window = glutin_window.window();
|
||||||
|
|
||||||
|
let dpi_factor = winit_window.scale_factor();
|
||||||
|
|
||||||
|
gl::init(context);
|
||||||
|
info!("Shader version: {}", shader_version);
|
||||||
|
|
||||||
|
let renderer = render::Renderer::new(resource_manager.clone(), shader_version);
|
||||||
let mut ui_container = ui::Container::new();
|
let mut ui_container = ui::Container::new();
|
||||||
|
|
||||||
let mut last_frame = Instant::now();
|
let mut last_frame = Instant::now();
|
||||||
let frame_time = 1e9f64 / 60.0;
|
|
||||||
|
|
||||||
let mut screen_sys = screen::ScreenSystem::new();
|
let mut screen_sys = screen::ScreenSystem::new();
|
||||||
if opt.server.is_none() {
|
if opt.server.is_none() {
|
||||||
|
@ -301,7 +356,6 @@ fn main2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let textures = renderer.get_textures();
|
let textures = renderer.get_textures();
|
||||||
let dpi_factor = window.window().scale_factor();
|
|
||||||
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
|
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
|
||||||
opt.default_protocol_version
|
opt.default_protocol_version
|
||||||
.unwrap_or_else(|| "".to_string()),
|
.unwrap_or_else(|| "".to_string()),
|
||||||
|
@ -344,94 +398,156 @@ fn main2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut last_resource_version = 0;
|
let mut last_resource_version = 0;
|
||||||
events_loop.run(move |event, _event_loop, control_flow| {
|
|
||||||
*control_flow = glutin::event_loop::ControlFlow::Poll;
|
|
||||||
|
|
||||||
if !handle_window_event(&mut window, &mut game, &mut ui_container, event) {
|
/* TODO: fix move of winit_window
|
||||||
return;
|
#[cfg(target_arch = "wasm32")]
|
||||||
}
|
render_loop.run(move |running: &mut bool| {
|
||||||
|
tick_all(
|
||||||
let now = Instant::now();
|
&winit_window,
|
||||||
let diff = now.duration_since(last_frame);
|
&mut game,
|
||||||
last_frame = now;
|
&mut ui_container,
|
||||||
let delta = (diff.subsec_nanos() as f64) / frame_time;
|
&mut last_frame,
|
||||||
let physical_size = window.window().inner_size();
|
&mut resui,
|
||||||
let (physical_width, physical_height) = physical_size.into();
|
&mut last_resource_version,
|
||||||
let (width, height) = physical_size.to_logical::<f64>(game.dpi_factor).into();
|
&mut vsync,
|
||||||
|
|
||||||
let version = {
|
|
||||||
let try_res = game.resource_manager.try_write();
|
|
||||||
if let Ok(mut res) = try_res {
|
|
||||||
res.tick(&mut resui, &mut ui_container, delta);
|
|
||||||
res.version()
|
|
||||||
} else {
|
|
||||||
// TODO: why does game.resource_manager.write() sometimes deadlock?
|
|
||||||
//warn!("Failed to obtain mutable reference to resource manager!");
|
|
||||||
last_resource_version
|
|
||||||
}
|
|
||||||
};
|
|
||||||
last_resource_version = version;
|
|
||||||
|
|
||||||
let vsync_changed = *game.vars.get(settings::R_VSYNC);
|
|
||||||
if vsync != vsync_changed {
|
|
||||||
error!("Changing vsync currently requires restarting");
|
|
||||||
game.should_close = true;
|
|
||||||
// TODO: after https://github.com/tomaka/glutin/issues/693 Allow changing vsync on a Window
|
|
||||||
//vsync = vsync_changed;
|
|
||||||
}
|
|
||||||
let fps_cap = *game.vars.get(settings::R_MAX_FPS);
|
|
||||||
|
|
||||||
game.tick(delta);
|
|
||||||
game.server.tick(&mut game.renderer, delta);
|
|
||||||
|
|
||||||
// Check if window is valid, it might be minimized
|
|
||||||
if physical_width == 0 || physical_height == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.renderer.update_camera(physical_width, physical_height);
|
|
||||||
game.server.world.compute_render_list(&mut game.renderer);
|
|
||||||
game.chunk_builder
|
|
||||||
.tick(&mut game.server.world, &mut game.renderer, version);
|
|
||||||
|
|
||||||
game.screen_sys
|
|
||||||
.tick(delta, &mut game.renderer, &mut ui_container);
|
|
||||||
game.console
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.tick(&mut ui_container, &game.renderer, delta, width);
|
|
||||||
ui_container.tick(&mut game.renderer, delta, width, height);
|
|
||||||
game.renderer.tick(
|
|
||||||
&mut game.server.world,
|
|
||||||
delta,
|
|
||||||
width as u32,
|
|
||||||
height as u32,
|
|
||||||
physical_width,
|
|
||||||
physical_height,
|
|
||||||
);
|
);
|
||||||
|
println!("render_loop");
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
if fps_cap > 0 && !vsync {
|
events_loop.run(move |event, _event_loop, control_flow| {
|
||||||
let frame_time = now.elapsed();
|
#[cfg(target_arch = "wasm32")]
|
||||||
let sleep_interval = Duration::from_millis(1000 / fps_cap as u64);
|
{
|
||||||
if frame_time < sleep_interval {
|
*control_flow = winit::event_loop::ControlFlow::Wait;
|
||||||
thread::sleep(sleep_interval - frame_time);
|
}
|
||||||
}
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
let winit_window = {
|
||||||
|
*control_flow = winit::event_loop::ControlFlow::Poll;
|
||||||
|
glutin_window.window()
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
if let winit::event::Event::WindowEvent {
|
||||||
|
event: winit::event::WindowEvent::Resized(physical_size),
|
||||||
|
..
|
||||||
|
} = event
|
||||||
|
{
|
||||||
|
glutin_window.resize(physical_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !handle_window_event(&winit_window, &mut game, &mut ui_container, event) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
{
|
||||||
|
tick_all(
|
||||||
|
&winit_window,
|
||||||
|
&mut game,
|
||||||
|
&mut ui_container,
|
||||||
|
&mut last_frame,
|
||||||
|
&mut resui,
|
||||||
|
&mut last_resource_version,
|
||||||
|
&mut vsync,
|
||||||
|
);
|
||||||
|
|
||||||
|
glutin_window
|
||||||
|
.swap_buffers()
|
||||||
|
.expect("Failed to swap GL buffers");
|
||||||
}
|
}
|
||||||
window.swap_buffers().expect("Failed to swap GL buffers");
|
|
||||||
|
|
||||||
if game.should_close {
|
if game.should_close {
|
||||||
*control_flow = glutin::event_loop::ControlFlow::Exit;
|
*control_flow = winit::event_loop::ControlFlow::Exit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tick_all(
|
||||||
|
window: &winit::window::Window,
|
||||||
|
game: &mut Game,
|
||||||
|
mut ui_container: &mut ui::Container,
|
||||||
|
last_frame: &mut Instant,
|
||||||
|
mut resui: &mut resources::ManagerUI,
|
||||||
|
last_resource_version: &mut usize,
|
||||||
|
vsync: &mut bool,
|
||||||
|
) {
|
||||||
|
let now = Instant::now();
|
||||||
|
let diff = now.duration_since(*last_frame);
|
||||||
|
*last_frame = now;
|
||||||
|
let frame_time = 1e9f64 / 60.0;
|
||||||
|
let delta = (diff.subsec_nanos() as f64) / frame_time;
|
||||||
|
let physical_size = window.inner_size();
|
||||||
|
let (physical_width, physical_height) = physical_size.into();
|
||||||
|
let (width, height) = physical_size.to_logical::<f64>(game.dpi_factor).into();
|
||||||
|
|
||||||
|
let version = {
|
||||||
|
let try_res = game.resource_manager.try_write();
|
||||||
|
if let Ok(mut res) = try_res {
|
||||||
|
res.tick(&mut resui, &mut ui_container, delta);
|
||||||
|
res.version()
|
||||||
|
} else {
|
||||||
|
// TODO: why does game.resource_manager.write() sometimes deadlock?
|
||||||
|
//warn!("Failed to obtain mutable reference to resource manager!");
|
||||||
|
*last_resource_version
|
||||||
|
}
|
||||||
|
};
|
||||||
|
*last_resource_version = version;
|
||||||
|
|
||||||
|
let vsync_changed = *game.vars.get(settings::R_VSYNC);
|
||||||
|
if *vsync != vsync_changed {
|
||||||
|
error!("Changing vsync currently requires restarting");
|
||||||
|
game.should_close = true;
|
||||||
|
// TODO: after https://github.com/tomaka/glutin/issues/693 Allow changing vsync on a Window
|
||||||
|
//vsync = vsync_changed;
|
||||||
|
}
|
||||||
|
let fps_cap = *game.vars.get(settings::R_MAX_FPS);
|
||||||
|
|
||||||
|
game.tick(delta);
|
||||||
|
game.server.tick(&mut game.renderer, delta);
|
||||||
|
|
||||||
|
// Check if window is valid, it might be minimized
|
||||||
|
if physical_width == 0 || physical_height == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
game.renderer.update_camera(physical_width, physical_height);
|
||||||
|
game.server.world.compute_render_list(&mut game.renderer);
|
||||||
|
game.chunk_builder
|
||||||
|
.tick(&mut game.server.world, &mut game.renderer, version);
|
||||||
|
|
||||||
|
game.screen_sys
|
||||||
|
.tick(delta, &mut game.renderer, &mut ui_container);
|
||||||
|
game.console
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.tick(&mut ui_container, &game.renderer, delta, width);
|
||||||
|
ui_container.tick(&mut game.renderer, delta, width, height);
|
||||||
|
game.renderer.tick(
|
||||||
|
&mut game.server.world,
|
||||||
|
delta,
|
||||||
|
width as u32,
|
||||||
|
height as u32,
|
||||||
|
physical_width,
|
||||||
|
physical_height,
|
||||||
|
);
|
||||||
|
|
||||||
|
if fps_cap > 0 && !*vsync {
|
||||||
|
let frame_time = now.elapsed();
|
||||||
|
let sleep_interval = Duration::from_millis(1000 / fps_cap as u64);
|
||||||
|
if frame_time < sleep_interval {
|
||||||
|
thread::sleep(sleep_interval - frame_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_window_event<T>(
|
fn handle_window_event<T>(
|
||||||
window: &mut glutin::WindowedContext<glutin::PossiblyCurrent>,
|
window: &winit::window::Window,
|
||||||
game: &mut Game,
|
game: &mut Game,
|
||||||
ui_container: &mut ui::Container,
|
ui_container: &mut ui::Container,
|
||||||
event: glutin::event::Event<T>,
|
event: winit::event::Event<T>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
use glutin::event::*;
|
use winit::event::*;
|
||||||
match event {
|
match event {
|
||||||
Event::MainEventsCleared => return true,
|
Event::MainEventsCleared => return true,
|
||||||
Event::DeviceEvent { event, .. } => {
|
Event::DeviceEvent { event, .. } => {
|
||||||
|
@ -460,8 +576,8 @@ fn handle_window_event<T>(
|
||||||
use std::f64::consts::PI;
|
use std::f64::consts::PI;
|
||||||
|
|
||||||
if game.focused {
|
if game.focused {
|
||||||
window.window().set_cursor_grab(true).unwrap();
|
window.set_cursor_grab(true).unwrap();
|
||||||
window.window().set_cursor_visible(false);
|
window.set_cursor_visible(false);
|
||||||
if let Some(player) = game.server.player {
|
if let Some(player) = game.server.player {
|
||||||
let rotation = game
|
let rotation = game
|
||||||
.server
|
.server
|
||||||
|
@ -478,8 +594,8 @@ fn handle_window_event<T>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.window().set_cursor_grab(false).unwrap();
|
window.set_cursor_grab(false).unwrap();
|
||||||
window.window().set_cursor_visible(true);
|
window.set_cursor_visible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -491,9 +607,6 @@ fn handle_window_event<T>(
|
||||||
game.is_logo_pressed = modifiers_state.logo();
|
game.is_logo_pressed = modifiers_state.logo();
|
||||||
}
|
}
|
||||||
WindowEvent::CloseRequested => game.should_close = true,
|
WindowEvent::CloseRequested => game.should_close = true,
|
||||||
WindowEvent::Resized(physical_size) => {
|
|
||||||
window.resize(physical_size);
|
|
||||||
}
|
|
||||||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||||
game.dpi_factor = scale_factor;
|
game.dpi_factor = scale_factor;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +619,7 @@ fn handle_window_event<T>(
|
||||||
|
|
||||||
WindowEvent::MouseInput { state, button, .. } => match (state, button) {
|
WindowEvent::MouseInput { state, button, .. } => match (state, button) {
|
||||||
(ElementState::Released, MouseButton::Left) => {
|
(ElementState::Released, MouseButton::Left) => {
|
||||||
let physical_size = window.window().inner_size();
|
let physical_size = window.inner_size();
|
||||||
let (width, height) =
|
let (width, height) =
|
||||||
physical_size.to_logical::<f64>(game.dpi_factor).into();
|
physical_size.to_logical::<f64>(game.dpi_factor).into();
|
||||||
|
|
||||||
|
@ -515,11 +628,11 @@ fn handle_window_event<T>(
|
||||||
&& !game.screen_sys.is_current_closable()
|
&& !game.screen_sys.is_current_closable()
|
||||||
{
|
{
|
||||||
game.focused = true;
|
game.focused = true;
|
||||||
window.window().set_cursor_grab(true).unwrap();
|
window.set_cursor_grab(true).unwrap();
|
||||||
window.window().set_cursor_visible(false);
|
window.set_cursor_visible(false);
|
||||||
} else if !game.focused {
|
} else if !game.focused {
|
||||||
window.window().set_cursor_grab(false).unwrap();
|
window.set_cursor_grab(false).unwrap();
|
||||||
window.window().set_cursor_visible(true);
|
window.set_cursor_visible(true);
|
||||||
ui_container.click_at(
|
ui_container.click_at(
|
||||||
game,
|
game,
|
||||||
game.last_mouse_x,
|
game.last_mouse_x,
|
||||||
|
@ -542,7 +655,7 @@ fn handle_window_event<T>(
|
||||||
game.last_mouse_y = y;
|
game.last_mouse_y = y;
|
||||||
|
|
||||||
if !game.focused {
|
if !game.focused {
|
||||||
let physical_size = window.window().inner_size();
|
let physical_size = window.inner_size();
|
||||||
let (width, height) =
|
let (width, height) =
|
||||||
physical_size.to_logical::<f64>(game.dpi_factor).into();
|
physical_size.to_logical::<f64>(game.dpi_factor).into();
|
||||||
ui_container.hover_at(game, x, y, width, height);
|
ui_container.hover_at(game, x, y, width, height);
|
||||||
|
@ -564,15 +677,15 @@ fn handle_window_event<T>(
|
||||||
match (input.state, input.virtual_keycode) {
|
match (input.state, input.virtual_keycode) {
|
||||||
(ElementState::Released, Some(VirtualKeyCode::Escape)) => {
|
(ElementState::Released, Some(VirtualKeyCode::Escape)) => {
|
||||||
if game.focused {
|
if game.focused {
|
||||||
window.window().set_cursor_grab(false).unwrap();
|
window.set_cursor_grab(false).unwrap();
|
||||||
window.window().set_cursor_visible(true);
|
window.set_cursor_visible(true);
|
||||||
game.focused = false;
|
game.focused = false;
|
||||||
game.screen_sys.replace_screen(Box::new(
|
game.screen_sys.replace_screen(Box::new(
|
||||||
screen::SettingsMenu::new(game.vars.clone(), true),
|
screen::SettingsMenu::new(game.vars.clone(), true),
|
||||||
));
|
));
|
||||||
} else if game.screen_sys.is_current_closable() {
|
} else if game.screen_sys.is_current_closable() {
|
||||||
window.window().set_cursor_grab(true).unwrap();
|
window.set_cursor_grab(true).unwrap();
|
||||||
window.window().set_cursor_visible(false);
|
window.set_cursor_visible(false);
|
||||||
game.focused = true;
|
game.focused = true;
|
||||||
game.screen_sys.pop_screen();
|
game.screen_sys.pop_screen();
|
||||||
}
|
}
|
||||||
|
@ -584,13 +697,11 @@ fn handle_window_event<T>(
|
||||||
if !game.is_fullscreen {
|
if !game.is_fullscreen {
|
||||||
// TODO: support options for exclusive and simple fullscreen
|
// TODO: support options for exclusive and simple fullscreen
|
||||||
// see https://docs.rs/glutin/0.22.0-alpha5/glutin/window/struct.Window.html#method.set_fullscreen
|
// see https://docs.rs/glutin/0.22.0-alpha5/glutin/window/struct.Window.html#method.set_fullscreen
|
||||||
window.window().set_fullscreen(Some(
|
window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(
|
||||||
glutin::window::Fullscreen::Borderless(
|
window.current_monitor(),
|
||||||
window.window().current_monitor(),
|
)));
|
||||||
),
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
window.window().set_fullscreen(None);
|
window.set_fullscreen(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
game.is_fullscreen = !game.is_fullscreen;
|
game.is_fullscreen = !game.is_fullscreen;
|
||||||
|
|
|
@ -17,11 +17,15 @@ use std::collections::HashMap;
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Registry {
|
pub struct Registry {
|
||||||
shaders: HashMap<String, String>,
|
shaders: HashMap<String, String>,
|
||||||
|
shader_version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Registry {
|
impl Registry {
|
||||||
pub fn new() -> Registry {
|
pub fn new(shader_version: &str) -> Registry {
|
||||||
Default::default()
|
Registry {
|
||||||
|
shaders: Default::default(),
|
||||||
|
shader_version: shader_version.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(&mut self, name: &str, source: &str) {
|
pub fn register(&mut self, name: &str, source: &str) {
|
||||||
|
@ -32,16 +36,29 @@ impl Registry {
|
||||||
.insert(name.to_owned(), source.trim().to_owned());
|
.insert(name.to_owned(), source.trim().to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_version(&self, out: &mut String) {
|
||||||
|
out.push_str(&self.shader_version);
|
||||||
|
out.push('\n');
|
||||||
|
if self.shader_version.ends_with(" es") {
|
||||||
|
out.push_str(
|
||||||
|
r#"precision mediump float;
|
||||||
|
precision mediump sampler2DArray;
|
||||||
|
#define ES
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get(&self, name: &str) -> String {
|
pub fn get(&self, name: &str) -> String {
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
out.push_str("#version 150\n");
|
self.add_version(&mut out);
|
||||||
self.get_internal(&mut out, name);
|
self.get_internal(&mut out, name);
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_define(&self, name: &str, define: &str) -> String {
|
pub fn get_define(&self, name: &str, define: &str) -> String {
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
out.push_str("#version 150\n");
|
self.add_version(&mut out);
|
||||||
out.push_str("#define ");
|
out.push_str("#define ");
|
||||||
out.push_str(define);
|
out.push_str(define);
|
||||||
out.push('\n');
|
out.push('\n');
|
||||||
|
|
|
@ -37,8 +37,6 @@ use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
|
|
||||||
const ATLAS_SIZE: usize = 1024;
|
const ATLAS_SIZE: usize = 1024;
|
||||||
|
|
||||||
// TEMP
|
// TEMP
|
||||||
|
@ -153,7 +151,7 @@ init_shader! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
pub fn new(res: Arc<RwLock<resources::Manager>>) -> Renderer {
|
pub fn new(res: Arc<RwLock<resources::Manager>>, shader_version: &str) -> Renderer {
|
||||||
let version = { res.read().unwrap().version() };
|
let version = { res.read().unwrap().version() };
|
||||||
let tex = gl::Texture::new();
|
let tex = gl::Texture::new();
|
||||||
tex.bind(gl::TEXTURE_2D_ARRAY);
|
tex.bind(gl::TEXTURE_2D_ARRAY);
|
||||||
|
@ -175,7 +173,7 @@ impl Renderer {
|
||||||
let (textures, skin_req, skin_reply) = TextureManager::new(res.clone());
|
let (textures, skin_req, skin_reply) = TextureManager::new(res.clone());
|
||||||
let textures = Arc::new(RwLock::new(textures));
|
let textures = Arc::new(RwLock::new(textures));
|
||||||
|
|
||||||
let mut greg = glsl::Registry::new();
|
let mut greg = glsl::Registry::new(shader_version);
|
||||||
shaders::add_shaders(&mut greg);
|
shaders::add_shaders(&mut greg);
|
||||||
let ui = ui::UIState::new(&greg, textures.clone(), res.clone());
|
let ui = ui::UIState::new(&greg, textures.clone(), res.clone());
|
||||||
|
|
||||||
|
@ -951,7 +949,7 @@ pub struct TextureManager {
|
||||||
|
|
||||||
skins: HashMap<String, AtomicIsize, BuildHasherDefault<FNVHash>>,
|
skins: HashMap<String, AtomicIsize, BuildHasherDefault<FNVHash>>,
|
||||||
|
|
||||||
_skin_thread: thread::JoinHandle<()>,
|
_skin_thread: Option<thread::JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextureManager {
|
impl TextureManager {
|
||||||
|
@ -966,7 +964,13 @@ impl TextureManager {
|
||||||
) {
|
) {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
let (stx, srx) = mpsc::channel();
|
let (stx, srx) = mpsc::channel();
|
||||||
let skin_thread = thread::spawn(|| Self::process_skins(srx, tx));
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let skin_thread = None;
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
let skin_thread = Some(thread::spawn(|| Self::process_skins(srx, tx)));
|
||||||
|
|
||||||
let mut tm = TextureManager {
|
let mut tm = TextureManager {
|
||||||
textures: HashMap::with_hasher(BuildHasherDefault::default()),
|
textures: HashMap::with_hasher(BuildHasherDefault::default()),
|
||||||
version: {
|
version: {
|
||||||
|
|
|
@ -249,19 +249,19 @@ impl Manager {
|
||||||
gl::enable(gl::BLEND);
|
gl::enable(gl::BLEND);
|
||||||
for collection in &self.collections {
|
for collection in &self.collections {
|
||||||
collection.shader.program.use_program();
|
collection.shader.program.use_program();
|
||||||
if let Some(v) = collection.shader.perspective_matrix {
|
if let Some(v) = &collection.shader.perspective_matrix {
|
||||||
v.set_matrix4(perspective_matrix)
|
v.set_matrix4(perspective_matrix)
|
||||||
}
|
}
|
||||||
if let Some(v) = collection.shader.camera_matrix {
|
if let Some(v) = &collection.shader.camera_matrix {
|
||||||
v.set_matrix4(camera_matrix)
|
v.set_matrix4(camera_matrix)
|
||||||
}
|
}
|
||||||
if let Some(v) = collection.shader.texture {
|
if let Some(v) = &collection.shader.texture {
|
||||||
v.set_int(0)
|
v.set_int(0)
|
||||||
}
|
}
|
||||||
if let Some(v) = collection.shader.sky_offset {
|
if let Some(v) = &collection.shader.sky_offset {
|
||||||
v.set_float(sky_offset)
|
v.set_float(sky_offset)
|
||||||
}
|
}
|
||||||
if let Some(v) = collection.shader.light_level {
|
if let Some(v) = &collection.shader.light_level {
|
||||||
v.set_float(light_level)
|
v.set_float(light_level)
|
||||||
}
|
}
|
||||||
gl::blend_func(collection.blend_s, collection.blend_d);
|
gl::blend_func(collection.blend_s, collection.blend_d);
|
||||||
|
@ -276,13 +276,13 @@ impl Manager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
model.array.bind();
|
model.array.bind();
|
||||||
if let Some(v) = collection.shader.lighting {
|
if let Some(v) = &collection.shader.lighting {
|
||||||
v.set_float2(model.block_light, model.sky_light)
|
v.set_float2(model.block_light, model.sky_light)
|
||||||
}
|
}
|
||||||
if let Some(v) = collection.shader.model_matrix {
|
if let Some(v) = &collection.shader.model_matrix {
|
||||||
v.set_matrix4_multi(&model.matrix)
|
v.set_matrix4_multi(&model.matrix)
|
||||||
}
|
}
|
||||||
if let Some(v) = collection.shader.color_mul {
|
if let Some(v) = &collection.shader.color_mul {
|
||||||
unsafe {
|
unsafe {
|
||||||
v.set_float_multi_raw(model.colors.as_ptr() as *const _, model.colors.len())
|
v.set_float_multi_raw(model.colors.as_ptr() as *const _, model.colors.len())
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,17 @@ in vec3 vLighting;
|
||||||
#ifndef alpha
|
#ifndef alpha
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#ifdef ES
|
||||||
|
layout(location = 1) out vec4 accum;
|
||||||
|
layout(location = 2) out float revealage;
|
||||||
|
#else
|
||||||
out vec4 accum;
|
out vec4 accum;
|
||||||
out float revealage;
|
out float revealage;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include lookup_texture
|
#include lookup_texture
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
|
@ -20,7 +20,7 @@ out vec3 vLighting;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 pos = vec3(aPosition.x, -aPosition.y, aPosition.z);
|
vec3 pos = vec3(aPosition.x, -aPosition.y, aPosition.z);
|
||||||
vec3 o = vec3(offset.x, -offset.y / 4096.0, offset.z);
|
vec3 o = vec3(float(offset.x), -float(offset.y) / 4096.0, float(offset.z));
|
||||||
gl_Position = perspectiveMatrix * cameraMatrix * vec4(pos + o * 16.0, 1.0);
|
gl_Position = perspectiveMatrix * cameraMatrix * vec4(pos + o * 16.0, 1.0);
|
||||||
|
|
||||||
vColor = aColor;
|
vColor = aColor;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const float invAtlasSize = 1.0 / 1024;
|
const float invAtlasSize = 1.0 / 1024.0;
|
||||||
vec4 atlasTexture() {
|
vec4 atlasTexture() {
|
||||||
vec2 tPos = vTextureOffset;
|
vec2 tPos = vTextureOffset;
|
||||||
tPos = clamp(tPos, vec2(0.1), vTextureInfo.zw - 0.1);
|
tPos = clamp(tPos, vec2(0.1), vTextureInfo.zw - 0.1);
|
||||||
|
|
|
@ -26,8 +26,8 @@ void main() {
|
||||||
|
|
||||||
vColor = aColor;
|
vColor = aColor;
|
||||||
vTextureInfo = aTextureInfo;
|
vTextureInfo = aTextureInfo;
|
||||||
vTextureOffset = aTextureOffset.xy / 16.0;
|
vTextureOffset = vec2(aTextureOffset.xy) / 16.0;
|
||||||
vAtlas = aTextureOffset.z;
|
vAtlas = float(aTextureOffset.z);
|
||||||
vID = float(id);
|
vID = float(id);
|
||||||
|
|
||||||
vLighting = getLight(lighting);
|
vLighting = getLight(lighting);
|
||||||
|
|
|
@ -21,7 +21,7 @@ void main() {
|
||||||
gl_Position = perspectiveMatrix * cameraMatrix * modelMatrix[id] * vec4(pos, 1.0);
|
gl_Position = perspectiveMatrix * cameraMatrix * modelMatrix[id] * vec4(pos, 1.0);
|
||||||
|
|
||||||
vTextureInfo = aTextureInfo;
|
vTextureInfo = aTextureInfo;
|
||||||
vTextureOffset = aTextureOffset.xy / 16.0;
|
vTextureOffset = vec2(aTextureOffset.xy) / 16.0;
|
||||||
vAtlas = aTextureOffset.z;
|
vAtlas = float(aTextureOffset.z);
|
||||||
vID = float(id);
|
vID = float(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ out float vAtlas;
|
||||||
uniform vec2 screenSize;
|
uniform vec2 screenSize;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 pos = aPosition.xy / screenSize;
|
vec2 pos = vec2(aPosition.xy) / screenSize;
|
||||||
gl_Position = vec4((pos.x-0.5)*2.0, -(pos.y-0.5)*2.0, float(-aPosition.z) / float(0xFFFF-1), 1.0);
|
gl_Position = vec4((pos.x-0.5)*2.0, -(pos.y-0.5)*2.0, float(-aPosition.z) / float(0xFFFF-1), 1.0);
|
||||||
vColor = aColor;
|
vColor = aColor;
|
||||||
vTextureInfo = aTextureInfo;
|
vTextureInfo = aTextureInfo;
|
||||||
vTextureOffset = aTextureOffset.xy / 16.0;
|
vTextureOffset = vec2(aTextureOffset.xy) / 16.0;
|
||||||
vAtlas = aTextureOffset.z;
|
vAtlas = float(aTextureOffset.z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::console;
|
use crate::console;
|
||||||
use glutin::event::VirtualKeyCode;
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
use winit::event::VirtualKeyCode;
|
||||||
// Might just rename this to settings.rs
|
// Might just rename this to settings.rs
|
||||||
|
|
||||||
pub const R_MAX_FPS: console::CVar<i64> = console::CVar {
|
pub const R_MAX_FPS: console::CVar<i64> = console::CVar {
|
||||||
|
|
|
@ -18,9 +18,9 @@ use crate::format;
|
||||||
use crate::render;
|
use crate::render;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||||
use glutin::event::VirtualKeyCode;
|
|
||||||
use std::cell::{RefCell, RefMut};
|
use std::cell::{RefCell, RefMut};
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
|
use winit::event::VirtualKeyCode;
|
||||||
|
|
||||||
const SCALED_WIDTH: f64 = 854.0;
|
const SCALED_WIDTH: f64 = 854.0;
|
||||||
const SCALED_HEIGHT: f64 = 480.0;
|
const SCALED_HEIGHT: f64 = 480.0;
|
||||||
|
|
|
@ -1,276 +1,14 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
|
||||||
name = "base-x"
|
|
||||||
version = "0.2.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bumpalo"
|
|
||||||
version = "2.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.10"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "discard"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hex"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itoa"
|
|
||||||
version = "0.4.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "localstoragefs"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"stdweb 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "log"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ryu"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.104"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.104"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_json"
|
|
||||||
version = "1.0.44"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha1"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "std_or_web"
|
name = "std_or_web"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if",
|
||||||
"localstoragefs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb"
|
|
||||||
version = "0.4.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"stdweb-derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"stdweb-internal-macros 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"stdweb-internal-runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-derive"
|
|
||||||
version = "0.5.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-internal-macros"
|
|
||||||
version = "0.2.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"base-x 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stdweb-internal-runtime"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen"
|
|
||||||
version = "0.2.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-macro 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-backend"
|
|
||||||
version = "0.2.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-shared 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro"
|
|
||||||
version = "0.2.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-macro-support 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro-support"
|
|
||||||
version = "0.2.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-backend 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen-shared 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-shared"
|
|
||||||
version = "0.2.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[metadata]
|
|
||||||
"checksum base-x 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1"
|
|
||||||
"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708"
|
|
||||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|
||||||
"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
|
||||||
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
|
||||||
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
|
|
||||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
"checksum localstoragefs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba6cbee6bbe7e6ea61ad375952239a9678624f216a0f442ae04a90260e76cdf"
|
|
||||||
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
|
||||||
"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc"
|
|
||||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
|
||||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
|
||||||
"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
|
|
||||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
|
|
||||||
"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
|
|
||||||
"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7"
|
|
||||||
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
|
||||||
"checksum stdweb 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
|
|
||||||
"checksum stdweb-derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
|
|
||||||
"checksum stdweb-internal-macros 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
|
|
||||||
"checksum stdweb-internal-runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
|
||||||
"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8"
|
|
||||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
|
||||||
"checksum wasm-bindgen 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)" = "99de4b68939a880d530aed51289a7c7baee154e3ea8ac234b542c49da7134aaf"
|
|
||||||
"checksum wasm-bindgen-backend 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)" = "b58e66a093a7b7571cb76409763c495b8741ac4319ac20acc2b798f6766d92ee"
|
|
||||||
"checksum wasm-bindgen-macro 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)" = "a80f89daea7b0a67b11f6e9f911422ed039de9963dce00048a653b63d51194bf"
|
|
||||||
"checksum wasm-bindgen-macro-support 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)" = "4f9dbc3734ad6cff6b76b75b7df98c06982becd0055f651465a08f769bca5c61"
|
|
||||||
"checksum wasm-bindgen-shared 0.2.56 (registry+https://github.com/rust-lang/crates.io-index)" = "d907984f8506b3554eab48b8efff723e764ddbf76d4cd4a3fe4196bc00c49a70"
|
|
||||||
|
|
|
@ -6,6 +6,3 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
||||||
localstoragefs = "0.1.0"
|
|
||||||
|
|
|
@ -2,7 +2,52 @@ use cfg_if::cfg_if;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(target_arch = "wasm32")] {
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
pub use localstoragefs::fs;
|
// TODO: a real filesystem like https://emscripten.org/docs/api_reference/Filesystem-API.html
|
||||||
|
pub mod fs {
|
||||||
|
use std::convert::AsRef;
|
||||||
|
use std::io::Result;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
|
pub struct File { }
|
||||||
|
|
||||||
|
impl File {
|
||||||
|
pub fn create<P: AsRef<Path>>(path: P) -> Result<File> {
|
||||||
|
println!("File create {}", path.as_ref().to_str().unwrap());
|
||||||
|
Ok(File{})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn open<P: AsRef<Path>>(path: P) -> Result<File> {
|
||||||
|
println!("File open {}", path.as_ref().to_str().unwrap());
|
||||||
|
Ok(File{})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Read for File {
|
||||||
|
fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
|
||||||
|
println!("File read");
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Read for &File {
|
||||||
|
fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
|
||||||
|
println!("&File read");
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for File {
|
||||||
|
fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
||||||
|
println!("File write {:?}", buf);
|
||||||
|
Ok(buf.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flush(&mut self) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pub use std::fs;
|
pub use std::fs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,20 @@
|
||||||
|
|
||||||
Web app for running Stevenarella as WebAssembly
|
Web app for running Stevenarella as WebAssembly
|
||||||
|
|
||||||
Status: very incomplete. It does not currently compile, due to required modifications to adapt to the web,
|
Status: very incomplete. It currently compiles but does not run, due to required modifications to adapt to the web,
|
||||||
for progress see: [https://github.com/iceiix/stevenarella/issues/171](https://github.com/iceiix/stevenarella/issues/171).
|
for progress see: [🕸️ Web support](https://github.com/iceiix/stevenarella/issues/446)
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
To build for wasm32-unknown-unknown, run:
|
To build for wasm32-unknown-unknown, run in the top-level directory (not www):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
rustup target add wasm32-unknown-unknown
|
||||||
|
cargo install wasm-bindgen-cli
|
||||||
|
wasm-pack build
|
||||||
|
```
|
||||||
|
|
||||||
|
or:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo web start --target wasm32-unknown-unknown
|
cargo web start --target wasm32-unknown-unknown
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import * as wasm from "stevenarella";
|
import * as wasm from "../pkg/stevenarella_bg.wasm";
|
||||||
|
|
||||||
wasm.main();
|
wasm.main();
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,8 +19,8 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/rustwasm/create-wasm-app#readme",
|
"homepage": "https://github.com/rustwasm/create-wasm-app#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"copy-webpack-plugin": "^5.1.1",
|
"copy-webpack-plugin": "^5.1.2",
|
||||||
"webpack": "^4.43.0",
|
"webpack": "^4.44.2",
|
||||||
"webpack-cli": "^3.3.12",
|
"webpack-cli": "^3.3.12",
|
||||||
"webpack-dev-server": "^3.11.0"
|
"webpack-dev-server": "^3.11.0"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue