mirror of
https://github.com/sotrh/learn-wgpu.git
synced 2024-11-11 19:10:34 +00:00
Fixed accidental indentation change
This commit is contained in:
parent
eca31a5ed5
commit
03e905cc4d
@ -234,17 +234,17 @@ You'll then need to run the WASM code in an ES6 Module:
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init from "./pkg/pong.js";
|
import init from "./pkg/pong.js";
|
||||||
init().then(() => {
|
init().then(() => {
|
||||||
console.log("WASM Loaded");
|
console.log("WASM Loaded");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
canvas {
|
canvas {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -127,11 +127,11 @@ Now that we have our data, we can create the actual `instance_buffer`.
|
|||||||
```rust
|
```rust
|
||||||
let instance_data = instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
|
let instance_data = instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
|
||||||
let instance_buffer = device.create_buffer_init(
|
let instance_buffer = device.create_buffer_init(
|
||||||
&wgpu::util::BufferInitDescriptor {
|
&wgpu::util::BufferInitDescriptor {
|
||||||
label: Some("Instance Buffer"),
|
label: Some("Instance Buffer"),
|
||||||
contents: bytemuck::cast_slice(&instance_data),
|
contents: bytemuck::cast_slice(&instance_data),
|
||||||
usage: wgpu::BufferUsages::VERTEX,
|
usage: wgpu::BufferUsages::VERTEX,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -183,13 +183,13 @@ We need to add this descriptor to the render pipeline so that we can use it when
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
// ...
|
// ...
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
// ...
|
// ...
|
||||||
// UPDATED!
|
// UPDATED!
|
||||||
buffers: &[Vertex::desc(), InstanceRaw::desc()],
|
buffers: &[Vertex::desc(), InstanceRaw::desc()],
|
||||||
},
|
},
|
||||||
// ...
|
// ...
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -197,10 +197,10 @@ Don't forget to return our new variables!
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
Self {
|
Self {
|
||||||
// ...
|
// ...
|
||||||
// NEW!
|
// NEW!
|
||||||
instances,
|
instances,
|
||||||
instance_buffer,
|
instance_buffer,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -141,15 +141,15 @@ The last change we need to make is in the `render()` function. We've created the
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
// ...
|
// ...
|
||||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||||
view: &self.depth_texture.view,
|
view: &self.depth_texture.view,
|
||||||
depth_ops: Some(wgpu::Operations {
|
depth_ops: Some(wgpu::Operations {
|
||||||
load: wgpu::LoadOp::Clear(1.0),
|
load: wgpu::LoadOp::Clear(1.0),
|
||||||
store: true,
|
store: true,
|
||||||
}),
|
}),
|
||||||
stencil_ops: None,
|
stencil_ops: None,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -549,8 +549,8 @@ pub trait DrawModel<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> DrawModel<'b> for wgpu::RenderPass<'a>
|
impl<'a, 'b> DrawModel<'b> for wgpu::RenderPass<'a>
|
||||||
where
|
where
|
||||||
'b: 'a, {
|
'b: 'a, {
|
||||||
// ...
|
// ...
|
||||||
fn draw_model(&mut self, model: &'b Model, camera_bind_group: &'b wgpu::BindGroup) {
|
fn draw_model(&mut self, model: &'b Model, camera_bind_group: &'b wgpu::BindGroup) {
|
||||||
self.draw_model_instanced(model, 0..1, camera_bind_group);
|
self.draw_model_instanced(model, 0..1, camera_bind_group);
|
||||||
|
Loading…
Reference in New Issue
Block a user