mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
Port hello_triangle_rust example to use the new Rust wrapper
This commit is contained in:
parent
abf30b6f9d
commit
3c583160d4
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -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",
|
||||
]
|
||||
|
||||
|
@ -20,3 +20,4 @@ vulkan = ["wgpu-native/gfx-backend-vulkan"]
|
||||
|
||||
[dependencies]
|
||||
wgpu-native = { path = "../wgpu-native" }
|
||||
wgpu = { path = "../wgpu-rs" }
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ extern crate wgpu_native as wgn;
|
||||
|
||||
pub use wgn::{
|
||||
Color, Origin3d, Extent3d,
|
||||
AdapterDescriptor, Extensions, DeviceDescriptor,
|
||||
AdapterDescriptor, Extensions, DeviceDescriptor, PowerPreference,
|
||||
ShaderModuleDescriptor,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user