Port hello_triangle_rust example to use the new Rust wrapper

This commit is contained in:
Dzmitry Malyshau 2018-09-26 10:58:15 -04:00
parent abf30b6f9d
commit 3c583160d4
4 changed files with 13 additions and 31 deletions

1
Cargo.lock generated
View File

@ -206,6 +206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "examples"
version = "0.1.0"
dependencies = [
"wgpu 0.1.0",
"wgpu-native 0.1.0",
]

View File

@ -20,3 +20,4 @@ vulkan = ["wgpu-native/gfx-backend-vulkan"]
[dependencies]
wgpu-native = { path = "../wgpu-native" }
wgpu = { path = "../wgpu-rs" }

View File

@ -1,40 +1,20 @@
extern crate wgpu_native;
use wgpu_native::*;
extern crate wgpu;
fn main() {
let instance = wgpu_create_instance();
let adapter = wgpu_instance_get_adapter(
instance,
AdapterDescriptor {
power_preference: PowerPreference::LowPower,
let instance = wgpu::Instance::new();
let adapter = instance.get_adapter(
wgpu::AdapterDescriptor {
power_preference: wgpu::PowerPreference::LowPower,
},
);
let device = wgpu_adapter_create_device(
adapter,
DeviceDescriptor {
extensions: Extensions {
let device = adapter.create_device(
wgpu::DeviceDescriptor {
extensions: wgpu::Extensions {
anisotropic_filtering: false,
},
},
);
let vs_bytes = include_bytes!("./../data/hello_triangle.vert.spv");
let _vs = wgpu_device_create_shader_module(
device,
ShaderModuleDescriptor {
code: ByteArray {
bytes: vs_bytes.as_ptr(),
length: vs_bytes.len(),
},
},
);
let _vs = device.create_shader_module(vs_bytes);
let fs_bytes = include_bytes!("./../data/hello_triangle.frag.spv");
let _fs = wgpu_device_create_shader_module(
device,
ShaderModuleDescriptor {
code: ByteArray {
bytes: fs_bytes.as_ptr(),
length: fs_bytes.len(),
},
},
);
let _fs = device.create_shader_module(fs_bytes);
}

View File

@ -2,7 +2,7 @@ extern crate wgpu_native as wgn;
pub use wgn::{
Color, Origin3d, Extent3d,
AdapterDescriptor, Extensions, DeviceDescriptor,
AdapterDescriptor, Extensions, DeviceDescriptor, PowerPreference,
ShaderModuleDescriptor,
};