2019-12-02 04:03:04 +00:00
|
|
|
pub mod camera;
|
|
|
|
pub mod shader;
|
2019-12-02 09:31:07 +00:00
|
|
|
pub mod mesh;
|
2020-01-01 19:53:44 +00:00
|
|
|
pub mod render_resources;
|
2019-12-01 09:16:15 +00:00
|
|
|
mod forward;
|
2019-12-24 00:13:05 +00:00
|
|
|
mod forward_shadow;
|
2019-12-27 21:35:07 +00:00
|
|
|
mod forward_instanced;
|
2019-12-01 09:16:15 +00:00
|
|
|
mod shadow;
|
2019-12-02 04:03:04 +00:00
|
|
|
mod light;
|
2020-01-01 19:53:44 +00:00
|
|
|
mod pipeline;
|
2019-12-02 04:03:04 +00:00
|
|
|
mod pass;
|
2019-12-02 18:48:08 +00:00
|
|
|
mod material;
|
2019-12-01 09:16:15 +00:00
|
|
|
|
2020-01-01 19:53:44 +00:00
|
|
|
pub use forward::{ForwardUniforms, ForwardPipelineNew, ForwardPass};
|
2019-12-27 21:35:07 +00:00
|
|
|
pub use forward_shadow::{ForwardShadowPass};
|
2020-01-01 20:23:39 +00:00
|
|
|
pub use forward_instanced::ForwardInstancedPipeline;
|
2019-12-02 04:03:04 +00:00
|
|
|
pub use shadow::ShadowPass;
|
|
|
|
pub use light::*;
|
|
|
|
pub use shader::*;
|
2020-01-01 19:53:44 +00:00
|
|
|
pub use pipeline::*;
|
2019-12-02 04:03:04 +00:00
|
|
|
pub use pass::*;
|
2019-12-02 18:48:08 +00:00
|
|
|
pub use material::*;
|
|
|
|
pub use mesh::*;
|
2019-12-02 23:19:56 +00:00
|
|
|
pub use camera::*;
|
2019-12-24 00:13:05 +00:00
|
|
|
pub use render_resources::RenderResources;
|
2019-12-02 09:31:07 +00:00
|
|
|
|
2020-01-01 20:23:39 +00:00
|
|
|
use std::mem;
|
|
|
|
use crate::vertex::Vertex;
|
|
|
|
|
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,
|
|
|
|
range: 0 .. self.size,
|
|
|
|
}
|
|
|
|
}
|
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,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
2019-12-02 04:03:04 +00:00
|
|
|
}
|