From c269f46a0eb94c9302034c383d5638a55b0213c9 Mon Sep 17 00:00:00 2001 From: Ben Hansen Date: Sat, 19 Feb 2022 11:21:54 -0700 Subject: [PATCH] testing some things --- .travis.yml | 32 --- Cargo.lock | 28 ++- build-wasm.sh | 6 +- code/beginner/tutorial1-window/src/lib.rs | 2 +- code/beginner/tutorial2-surface/src/lib.rs | 2 +- code/beginner/tutorial9-models/src/lib.rs | 1 - .../tutorial10-lighting/Cargo.toml | 4 + .../tutorial10-lighting}/index.html | 2 +- .../tutorial10-lighting}/server.py | 2 +- .../tutorial10-lighting/src/lib.rs | 34 ++- .../tutorial10-lighting/src/light.frag | 8 - .../tutorial10-lighting/src/light.frag.spv | Bin 564 -> 0 bytes .../tutorial10-lighting/src/light.vert | 27 --- .../tutorial10-lighting/src/light.vert.spv | Bin 1840 -> 0 bytes .../tutorial10-lighting/src/resources.rs | 1 - .../tutorial10-lighting/src/shader.frag | 47 ---- .../tutorial10-lighting/src/shader.frag.spv | Bin 3196 -> 0 bytes .../tutorial10-lighting/src/shader.vert | 37 ---- .../tutorial10-lighting/src/shader.vert.spv | Bin 3060 -> 0 bytes .../tutorial11-normals/Cargo.toml | 25 ++- .../tutorial11-normals/src/lib.rs | 46 +++- .../tutorial11-normals/src/model.rs | 173 +-------------- .../tutorial11-normals/src/resources.rs | 205 ++++++++++++++++++ .../tutorial11-normals/src/texture.rs | 16 +- .../intermediate/tutorial12-camera/Cargo.toml | 25 ++- .../intermediate/tutorial12-camera/src/lib.rs | 3 + .../tutorial13-threading/Cargo.toml | 25 ++- .../tutorial13-threading/src/lib.rs | 3 + deploy.sh | 28 --- docs/beginner/tutorial9-models/README.md | 5 + .../tutorial10-lighting/README.md | 6 +- .../intermediate/tutorial11-normals/README.md | 2 + 32 files changed, 407 insertions(+), 388 deletions(-) delete mode 100644 .travis.yml rename code/{beginner/tutorial9-models => intermediate/tutorial10-lighting}/index.html (87%) rename code/{beginner/tutorial9-models => intermediate/tutorial10-lighting}/server.py (92%) delete mode 100644 code/intermediate/tutorial10-lighting/src/light.frag delete mode 100644 code/intermediate/tutorial10-lighting/src/light.frag.spv delete mode 100644 code/intermediate/tutorial10-lighting/src/light.vert delete mode 100644 code/intermediate/tutorial10-lighting/src/light.vert.spv delete mode 100644 code/intermediate/tutorial10-lighting/src/shader.frag delete mode 100644 code/intermediate/tutorial10-lighting/src/shader.frag.spv delete mode 100644 code/intermediate/tutorial10-lighting/src/shader.vert delete mode 100644 code/intermediate/tutorial10-lighting/src/shader.vert.spv create mode 100644 code/intermediate/tutorial11-normals/src/resources.rs delete mode 100755 deploy.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a528ed10..00000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -matrix: - include: - - language: rust - addons: - apt: - packages: - - libasound2-dev - rust: - - stable - # - beta - # - nightly - jobs: - # allow_failures: - # - rust: nightly - fast_finish: true - scripts: - - cargo build --verbose - - language: node_js - node_js: - - lts/* - install: - - npm ci - script: - - npm run build - deploy: - provider: pages - skip_cleanup: true - local_dir: docs/.vuepress/dist - github_token: $GITHUB_TOKEN # A token generated on GitHub allowing Travis to push code on you repository. Set in the Travis settings page of your repository, as a secure variable - keep_history: true - on: - branch: master \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 6535d8a5..1831caf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2870,6 +2870,7 @@ dependencies = [ "image 0.24.0", "log", "pollster", + "reqwest", "tobj 3.2.0", "wasm-bindgen", "wasm-bindgen-futures", @@ -2884,14 +2885,21 @@ version = "0.1.0" dependencies = [ "anyhow", "bytemuck", + "cfg-if 1.0.0", "cgmath", + "console_error_panic_hook", + "console_log", "env_logger", "fs_extra", "glob", - "image 0.23.14", + "image 0.24.0", "log", "pollster", + "reqwest", "tobj 3.2.0", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", "wgpu", "winit", ] @@ -2902,14 +2910,21 @@ version = "0.1.0" dependencies = [ "anyhow", "bytemuck", + "cfg-if 1.0.0", "cgmath", + "console_error_panic_hook", + "console_log", "env_logger", "fs_extra", "glob", - "image 0.23.14", + "image 0.24.0", "log", "pollster", + "reqwest", "tobj 3.2.0", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", "wgpu", "winit", ] @@ -2920,15 +2935,22 @@ version = "0.1.0" dependencies = [ "anyhow", "bytemuck", + "cfg-if 1.0.0", "cgmath", + "console_error_panic_hook", + "console_log", "env_logger", "fs_extra", "glob", - "image 0.23.14", + "image 0.24.0", "log", "pollster", "rayon", + "reqwest", "tobj 3.2.0", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", "wgpu", "winit", ] diff --git a/build-wasm.sh b/build-wasm.sh index e7a6322d..dc2f6efe 100755 --- a/build-wasm.sh +++ b/build-wasm.sh @@ -1,4 +1,4 @@ -(trap 'kill 0' SIGINT; +(trap 'killall background' INT; wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/pong code/showcase/pong & wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial1_window code/beginner/tutorial1-window & wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial2_surface code/beginner/tutorial2-surface & @@ -8,5 +8,7 @@ wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial5_text wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial6_uniforms code/beginner/tutorial6-uniforms & wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial7_instancing code/beginner/tutorial7-instancing & wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial8_depth code/beginner/tutorial8-depth & -wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial9_models code/beginner/tutorial9-models +wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial9_models code/beginner/tutorial9-models & +wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial10_lighting code/intermediate/tutorial10-lighting & +wasm-pack build --out-dir ../../../docs/.vuepress/components/wasm/tutorial11_normals code/intermediate/tutorial11-normals ) diff --git a/code/beginner/tutorial1-window/src/lib.rs b/code/beginner/tutorial1-window/src/lib.rs index ff80406e..77b83fcd 100644 --- a/code/beginner/tutorial1-window/src/lib.rs +++ b/code/beginner/tutorial1-window/src/lib.rs @@ -8,7 +8,7 @@ use winit::{ use wasm_bindgen::prelude::*; #[cfg_attr(target_arch="wasm32", wasm_bindgen(start))] -pub async fn run() { +pub fn run() { cfg_if::cfg_if! { if #[cfg(target_arch = "wasm32")] { std::panic::set_hook(Box::new(console_error_panic_hook::hook)); diff --git a/code/beginner/tutorial2-surface/src/lib.rs b/code/beginner/tutorial2-surface/src/lib.rs index f6e92b3b..fb890a39 100644 --- a/code/beginner/tutorial2-surface/src/lib.rs +++ b/code/beginner/tutorial2-surface/src/lib.rs @@ -23,7 +23,7 @@ impl State { // The instance is a handle to our GPU // BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU - let instance = wgpu::Instance::new(wgpu::Backends::all()); + let instance = wgpu::Instance::new(wgpu::Backends::GL); let surface = unsafe { instance.create_surface(window) }; let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { diff --git a/code/beginner/tutorial9-models/src/lib.rs b/code/beginner/tutorial9-models/src/lib.rs index f56ab81b..f6d13a69 100644 --- a/code/beginner/tutorial9-models/src/lib.rs +++ b/code/beginner/tutorial9-models/src/lib.rs @@ -596,7 +596,6 @@ pub async fn run() { } // State::new uses async code, so we're going to wait for it to finish - log::warn!("Creating State"); let mut state = State::new(&window).await; event_loop.run(move |event, _, control_flow| { diff --git a/code/intermediate/tutorial10-lighting/Cargo.toml b/code/intermediate/tutorial10-lighting/Cargo.toml index f671dc03..9468fd8f 100644 --- a/code/intermediate/tutorial10-lighting/Cargo.toml +++ b/code/intermediate/tutorial10-lighting/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" authors = ["Ben Hansen "] edition = "2018" +[lib] +crate-type = ["cdylib", "rlib"] + [dependencies] cfg-if = "1" anyhow = "1.0" @@ -22,6 +25,7 @@ default-features = false features = ["png", "jpeg"] [target.'cfg(target_arch = "wasm32")'.dependencies] +reqwest = { version = "0.11" } console_error_panic_hook = "0.1" console_log = "0.2" wgpu = { version = "0.12", features = ["webgl"]} diff --git a/code/beginner/tutorial9-models/index.html b/code/intermediate/tutorial10-lighting/index.html similarity index 87% rename from code/beginner/tutorial9-models/index.html rename to code/intermediate/tutorial10-lighting/index.html index 10afb64e..090a79db 100644 --- a/code/beginner/tutorial9-models/index.html +++ b/code/intermediate/tutorial10-lighting/index.html @@ -14,7 +14,7 @@