summaryrefslogtreecommitdiff
path: root/src/camera.rs
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2022-10-17 23:06:51 -0400
committerMicha White <botahamec@outlook.com>2022-10-17 23:06:51 -0400
commit9359df753ef76fdeb40a0de19c67080329710067 (patch)
tree40a6b32ce940830c680e3f6b0b7424b50c497dc3 /src/camera.rs
parentbc859833a41aa581228a476c3fa81acac9730a2e (diff)
More docs
Diffstat (limited to 'src/camera.rs')
-rw-r--r--src/camera.rs19
1 files changed, 4 insertions, 15 deletions
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(