Skip to content

Commit

Permalink
wasm32-unknown-unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Nov 18, 2021
1 parent afd5c28 commit ee8482c
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 43 deletions.
98 changes: 62 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@ rust-ini = "0.17"
serde = "1.0"
serde_derive = "1.0"
serde_scan = "0.4"
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "8f02b73", features = [] }
#wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "8f02b73", features = [] }
wgpu = { version = "0.11", features = ["webgl"] }
# binaries
env_logger = "0.8"
getopts = "0.2"
obj = "0.10"
png = "0.16"
winit = "0.25"
winit = { version = "0.25", features = ["web-sys"] }
wasm-bindgen = "0.2.78"
console_error_panic_hook = { version = "0.1.7" }

[dev-dependencies]
#naga = { git = "https://github.com/gfx-rs/naga", rev = "7613798", features = ["wgsl-in"] }
naga = { version = "0.6", features = ["wgsl-in"] }
naga = { version = "0.7", features = ["wgsl-in"] }

[dependencies.profiling]
version = "1.0.1"
Expand All @@ -83,3 +86,6 @@ default-features = false
#wgpu-hal = { path = "../wgpu/wgpu-hal" }
#wgpu-core = { path = "../wgpu/wgpu-core" }
#wgpu-types = { path = "../wgpu/wgpu-types" }

[dependencies.getrandom]
features = ["js"]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Web version of Vange-rs

Compile Web (Debug):

```sh
PATH=$PATH:/home/caiiiycuk/rust/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/caiiiycuk/rust/rust/build/x86_64-unknown-linux-gnu/stage0/lib/ cargo build --target wasm32-unknown-unknown --bin road --verbose && wasm-bindgen --out-dir html5/ --target web --keep-debug target/wasm32-unknown-unknown/debug/road.wasm
```

Compile native:
```sh
cargo build --bin road
```

# Vange-rs
![Check](https://github.com/kvark/vange-rs/workflows/Check/badge.svg)
[![Gitter](https://badges.gitter.im/kvark/vange-rs.svg)](https://gitter.im/vange-rs/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Expand Down
7 changes: 4 additions & 3 deletions bin/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Harness {
};

info!("Initializing the window");
let instance = wgpu::Instance::new(settings.backend.to_wgpu());
let instance = wgpu::Instance::new(wgpu::Backends::all() /* settings.backend.to_wgpu() */);
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_title(options.title)
Expand All @@ -79,6 +79,7 @@ impl Harness {
.run_until(instance.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
compatible_surface: Some(&surface),
force_fallback_adapter: false,
}))
.expect("Unable to initialize GPU via the selected backend.");

Expand Down Expand Up @@ -227,10 +228,9 @@ impl Harness {
queue.submit(update_command_buffers);
}

match surface.get_current_frame() {
match surface.get_current_texture() {
Ok(frame) => {
let view = frame
.output
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
let targets = ScreenTargets {
Expand All @@ -240,6 +240,7 @@ impl Harness {
};
let render_command_buffer = app.draw(&device, targets, &spawner);
queue.submit(Some(render_command_buffer));
frame.present();
}
Err(_) => {}
};
Expand Down
Loading

0 comments on commit ee8482c

Please sign in to comment.