Clarify changes to State struct

Not a big one, just being explicit where the fields need to be updated on the struct.
pull/123/head
Kane Rogers 4 years ago committed by GitHub
parent fd8c3e169d
commit b93a57d9b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -346,7 +346,25 @@ let index_buffer = device.create_buffer_init(
let num_indices = INDICES.len() as u32;
```
We don't need to implement `Pod` and `Zeroable` for our indices, because `bytemuck` has already implemented them for basic types such as `u16`. That means we can just add `index_buffer` and `num_indices` to `State`.
We don't need to implement `Pod` and `Zeroable` for our indices, because `bytemuck` has already implemented them for basic types such as `u16`. That means we can just add `index_buffer` and `num_indices` to the `State` struct.
```rust
struct State {
surface: wgpu::Surface,
device: wgpu::Device,
queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
size: winit::dpi::PhysicalSize<u32>,
render_pipeline: wgpu::RenderPipeline,
vertex_buffer: wgpu::Buffer,
// NEW!
index_buffer: wgpu::Buffer,
num_indicies: u32,
}
```
And then populate these fields in the constructor:
```rust
Self {

Loading…
Cancel
Save