From 9359df753ef76fdeb40a0de19c67080329710067 Mon Sep 17 00:00:00 2001 From: Micha White Date: Mon, 17 Oct 2022 23:06:51 -0400 Subject: More docs --- src/camera.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/camera.rs') diff --git a/src/camera.rs b/src/camera.rs index e77da40..ecece90 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -19,21 +19,6 @@ fn inverse_aspect_ratio(width: u32, height: u32) -> f32 { (height as f32) / (width as f32) } -fn create_bind_group( - device: &wgpu::Device, - buffer: &wgpu::Buffer, - layout: &wgpu::BindGroupLayout, -) -> wgpu::BindGroup { - device.create_bind_group(&wgpu::BindGroupDescriptor { - label: Some("Camera Bind Group"), - layout, - entries: &[wgpu::BindGroupEntry { - binding: 0, - resource: buffer.as_entire_binding(), - }], - }) -} - impl Camera { /// Create a new camera, with a position of (0, 0), and a zoom of 1.0 pub(crate) fn new( @@ -150,6 +135,8 @@ impl Camera { self.inverse_aspect_ratio = inverse_aspect_ratio(width, height); } + /// Create a matrix that can be multiplied by any vector to transform it + /// according to the current camera #[allow(clippy::wrong_self_convention)] fn to_matrix(&self) -> CameraUniform { let cos = self.rotation.cos(); @@ -183,10 +170,12 @@ impl Camera { transform.into() } + /// Get the bind group for the camera pub(crate) const fn bind_group(&self) -> &wgpu::BindGroup { &self.bind_group } + /// Refresh the camera buffer for the next frame #[profiling::function] pub(crate) fn refresh(&self, queue: &wgpu::Queue) { queue.write_buffer( -- cgit v1.2.3