2019-12-02 04:03:04 +00:00
|
|
|
pub mod camera;
|
2020-01-11 10:11:27 +00:00
|
|
|
pub mod instancing;
|
2020-01-08 06:35:07 +00:00
|
|
|
pub mod passes;
|
2020-01-11 10:11:27 +00:00
|
|
|
pub mod render_resources;
|
|
|
|
pub mod shader;
|
2020-01-08 06:35:07 +00:00
|
|
|
|
2019-12-02 04:03:04 +00:00
|
|
|
mod light;
|
2019-12-02 18:48:08 +00:00
|
|
|
mod material;
|
2020-01-11 10:11:27 +00:00
|
|
|
mod render_graph;
|
2020-01-11 19:29:57 +00:00
|
|
|
mod vertex;
|
2019-12-01 09:16:15 +00:00
|
|
|
|
2020-01-11 10:11:27 +00:00
|
|
|
pub use camera::*;
|
2019-12-02 04:03:04 +00:00
|
|
|
pub use light::*;
|
2019-12-02 18:48:08 +00:00
|
|
|
pub use material::*;
|
2020-01-11 10:11:27 +00:00
|
|
|
pub use render_graph::*;
|
|
|
|
pub use shader::*;
|
2019-12-02 09:31:07 +00:00
|
|
|
|
2020-01-11 10:11:27 +00:00
|
|
|
use std::mem;
|
2020-01-11 19:29:57 +00:00
|
|
|
pub use vertex::Vertex;
|
2020-01-01 20:23:39 +00:00
|
|
|
|
2019-12-02 04:03:04 +00:00
|
|
|
pub struct UniformBuffer {
|
|
|
|
pub buffer: wgpu::Buffer,
|
|
|
|
pub size: u64,
|
2020-01-01 19:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl UniformBuffer {
|
|
|
|
pub fn get_binding_resource<'a>(&'a self) -> wgpu::BindingResource<'a> {
|
|
|
|
wgpu::BindingResource::Buffer {
|
|
|
|
buffer: &self.buffer,
|
2020-01-11 10:11:27 +00:00
|
|
|
range: 0..self.size,
|
2020-01-01 19:53:44 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-01 20:23:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_vertex_buffer_descriptor<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
|
|
|
let vertex_size = mem::size_of::<Vertex>();
|
|
|
|
wgpu::VertexBufferDescriptor {
|
|
|
|
stride: vertex_size as wgpu::BufferAddress,
|
|
|
|
step_mode: wgpu::InputStepMode::Vertex,
|
|
|
|
attributes: &[
|
|
|
|
wgpu::VertexAttributeDescriptor {
|
|
|
|
format: wgpu::VertexFormat::Float4,
|
|
|
|
offset: 0,
|
|
|
|
shader_location: 0,
|
|
|
|
},
|
|
|
|
wgpu::VertexAttributeDescriptor {
|
|
|
|
format: wgpu::VertexFormat::Float4,
|
|
|
|
offset: 4 * 4,
|
|
|
|
shader_location: 1,
|
|
|
|
},
|
2020-01-14 01:35:30 +00:00
|
|
|
wgpu::VertexAttributeDescriptor {
|
|
|
|
format: wgpu::VertexFormat::Float2,
|
|
|
|
offset: 8 * 4,
|
|
|
|
shader_location: 2,
|
|
|
|
},
|
2020-01-01 20:23:39 +00:00
|
|
|
],
|
|
|
|
}
|
2020-01-11 10:11:27 +00:00
|
|
|
}
|