Allow examples to run from any dir

This commit is contained in:
Dzmitry Malyshau 2019-02-21 09:49:30 -05:00
parent 855bcfe176
commit 038e49aa25
3 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -27,7 +27,9 @@ pub fn load_glsl(name: &str, stage: ShaderStage) -> Vec<u8> {
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();

View File

@ -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);