From 038e49aa25fd57c85343b938015545fdf102e53d Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 21 Feb 2019 09:49:30 -0500 Subject: [PATCH] Allow examples to run from any dir --- Makefile | 5 ++++- gfx-examples/src/framework.rs | 4 +++- wgpu-bindings/wgpu.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a9542b10b..ef08a5b1e 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ else endif -.PHONY: all check test doc clear lib-native lib-rust examples-native examples-rust +.PHONY: all check test doc clear lib-native lib-rust examples-native examples-rust gfx-cube all: examples-native examples-rust examples-gfx @@ -64,3 +64,6 @@ examples-rust: lib-rust examples/Cargo.toml $(wildcard wgpu-native/**/*.rs) examples-gfx: lib-rust gfx-examples/Cargo.toml $(wildcard gfx-examples/*.rs) cargo build --manifest-path gfx-examples/Cargo.toml --features $(FEATURE_RUST) + +gfx-cube: + cargo run --manifest-path gfx-examples/Cargo.toml --bin cube --features $(FEATURE_RUST) diff --git a/gfx-examples/src/framework.rs b/gfx-examples/src/framework.rs index 805c776b2..a0a07479f 100644 --- a/gfx-examples/src/framework.rs +++ b/gfx-examples/src/framework.rs @@ -27,7 +27,9 @@ pub fn load_glsl(name: &str, stage: ShaderStage) -> Vec { ShaderStage::Fragment => glsl_to_spirv::ShaderType::Fragment, ShaderStage::Compute => glsl_to_spirv::ShaderType::Compute, }; - let path = PathBuf::from("data").join(name); + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("data") + .join(name); let code = read_to_string(path).unwrap(); let mut output = glsl_to_spirv::compile(&code, ty).unwrap(); let mut spv = Vec::new(); diff --git a/wgpu-bindings/wgpu.h b/wgpu-bindings/wgpu.h index 518b97577..e21cb7e96 100644 --- a/wgpu-bindings/wgpu.h +++ b/wgpu-bindings/wgpu.h @@ -696,4 +696,4 @@ WGPUTextureViewId wgpu_texture_create_view(WGPUTextureId texture_id, void wgpu_texture_destroy(WGPUTextureId texture_id); -void wgpu_texture_view_destroy(WGPUTextureViewId _texture_view_id); +void wgpu_texture_view_destroy(WGPUTextureViewId texture_view_id);