|
|
@@ -1,5 +1,6 @@
|
|
|
use std::iter;
|
|
|
|
|
|
+use camera::{camera_buffer, camera_struct::Camera, camera_uniform};
|
|
|
use wgpu::{util::DeviceExt, BlendState, ColorTargetState, PipelineLayoutDescriptor, RenderPipelineDescriptor};
|
|
|
use winit::{
|
|
|
event::*,
|
|
|
@@ -7,6 +8,7 @@ use winit::{
|
|
|
keyboard::{KeyCode, PhysicalKey},
|
|
|
window::{Window, WindowBuilder},
|
|
|
};
|
|
|
+mod camera;
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
@@ -19,6 +21,10 @@ struct State<'a> {
|
|
|
size: winit::dpi::PhysicalSize<u32>,
|
|
|
render_pipeline : wgpu::RenderPipeline,
|
|
|
vertex_buffer: wgpu::Buffer,
|
|
|
+ camera: camera::camera_struct::Camera,
|
|
|
+ camera_buffer : wgpu::Buffer,
|
|
|
+ camera_bind_group: wgpu::BindGroup,
|
|
|
+ camera_uniform : camera_uniform::CameraUniform,
|
|
|
// The window must be declared after the surface so
|
|
|
// it gets dropped after it as the surface contains
|
|
|
// unsafe references to the window's resources.
|
|
|
@@ -96,10 +102,21 @@ impl<'a> State<'a> {
|
|
|
});
|
|
|
|
|
|
|
|
|
+
|
|
|
+ let plan1 = generate_plane();
|
|
|
+ let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor{
|
|
|
+ label: Some("Vertex Buffer 1"),
|
|
|
+ contents: bytemuck::cast_slice(todo!()),
|
|
|
+ usage: wgpu::BufferUsages::VERTEX,
|
|
|
+ });
|
|
|
+
|
|
|
+ let (camera, camera_uniform, camera_buffer,camera_bind_group, camera_bind_group_layout) = camera_buffer::new(device, config);
|
|
|
+
|
|
|
+
|
|
|
let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor{
|
|
|
label: Some("Pipeline Layout"),
|
|
|
bind_group_layouts: &[
|
|
|
-
|
|
|
+ &camera_bind_group_layout,
|
|
|
],
|
|
|
push_constant_ranges: &[]
|
|
|
});
|
|
|
@@ -140,12 +157,6 @@ impl<'a> State<'a> {
|
|
|
}),
|
|
|
multiview: None
|
|
|
});
|
|
|
- let plan1 = generate_plane();
|
|
|
- let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor{
|
|
|
- label: Some("Vertex Buffer 1"),
|
|
|
- contents: bytemuck::cast_slice(todo!()),
|
|
|
- usage: wgpu::BufferUsages::VERTEX,
|
|
|
- });
|
|
|
|
|
|
|
|
|
Self {
|
|
|
@@ -157,6 +168,10 @@ impl<'a> State<'a> {
|
|
|
config,
|
|
|
size,
|
|
|
window,
|
|
|
+ camera,
|
|
|
+ camera_bind_group,
|
|
|
+ camera_buffer,
|
|
|
+ camera_uniform,
|
|
|
}
|
|
|
}
|
|
|
|