rename uniform_buf to camera_buf

This commit is contained in:
Quaternions 2023-09-01 14:57:04 -07:00
parent ba2bab562f
commit a853eb965e

View File

@ -111,7 +111,7 @@ pub struct Skybox {
entity_pipeline: wgpu::RenderPipeline, entity_pipeline: wgpu::RenderPipeline,
ground_pipeline: wgpu::RenderPipeline, ground_pipeline: wgpu::RenderPipeline,
bind_group: wgpu::BindGroup, bind_group: wgpu::BindGroup,
uniform_buf: wgpu::Buffer, camera_buf: wgpu::Buffer,
entities: Vec<Entity>, entities: Vec<Entity>,
depth_view: wgpu::TextureView, depth_view: wgpu::TextureView,
staging_belt: wgpu::util::StagingBelt, staging_belt: wgpu::util::StagingBelt,
@ -245,10 +245,10 @@ impl strafe_client::framework::Example for Skybox {
grounded: true, grounded: true,
walkspeed: 18.0, walkspeed: 18.0,
}; };
let raw_uniforms = camera.to_uniform_data(); let camera_uniforms = camera.to_uniform_data();
let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let camera_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Buffer"), label: Some("Camera"),
contents: bytemuck::cast_slice(&raw_uniforms), contents: bytemuck::cast_slice(&camera_uniforms),
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
}); });
@ -433,7 +433,7 @@ impl strafe_client::framework::Example for Skybox {
entries: &[ entries: &[
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
binding: 0, binding: 0,
resource: uniform_buf.as_entire_binding(), resource: camera_buf.as_entire_binding(),
}, },
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
binding: 1, binding: 1,
@ -455,7 +455,7 @@ impl strafe_client::framework::Example for Skybox {
entity_pipeline, entity_pipeline,
ground_pipeline, ground_pipeline,
bind_group, bind_group,
uniform_buf, camera_buf,
entities, entities,
depth_view, depth_view,
staging_belt: wgpu::util::StagingBelt::new(0x100), staging_belt: wgpu::util::StagingBelt::new(0x100),
@ -573,16 +573,16 @@ impl strafe_client::framework::Example for Skybox {
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
// update rotation // update rotation
let raw_uniforms = self.camera.to_uniform_data(); let camera_uniforms = self.camera.to_uniform_data();
self.staging_belt self.staging_belt
.write_buffer( .write_buffer(
&mut encoder, &mut encoder,
&self.uniform_buf, &self.camera_buf,
0, 0,
wgpu::BufferSize::new((raw_uniforms.len() * 4) as wgpu::BufferAddress).unwrap(), wgpu::BufferSize::new((camera_uniforms.len() * 4) as wgpu::BufferAddress).unwrap(),
device, device,
) )
.copy_from_slice(bytemuck::cast_slice(&raw_uniforms)); .copy_from_slice(bytemuck::cast_slice(&camera_uniforms));
self.staging_belt.finish(); self.staging_belt.finish();