mirror of
https://github.com/sotrh/learn-wgpu.git
synced 2024-11-04 06:00:47 +00:00
commit
d5c5b2de12
@ -11,7 +11,7 @@ A vertex is a point in 3d space (can also be 2d). These vertices are then bundle
|
|||||||
|
|
||||||
<img src="./tutorial3-pipeline-vertices.png" />
|
<img src="./tutorial3-pipeline-vertices.png" />
|
||||||
|
|
||||||
Most modern rendering uses triangles to make simple shapes such as cube, and complex shapes such as person.
|
Most modern rendering uses triangles to make all shapes, from simple (such as cubes) to complex (such as people).
|
||||||
|
|
||||||
<!-- Todo: Find/make an image to put here -->
|
<!-- Todo: Find/make an image to put here -->
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ In order to do that, we're going to need something to do the conversion. Add the
|
|||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# ...
|
# ...
|
||||||
glsl-to-spirv = "0.1"
|
shaderc = "0.6"
|
||||||
```
|
```
|
||||||
|
|
||||||
We'll use this in a bit, but first let's create the shaders.
|
We'll use this in a bit, but first let's create the shaders.
|
||||||
|
@ -7,7 +7,7 @@ You were probably getting sick of me saying stuff like "we'll get to that when w
|
|||||||
A buffer is a blob of data on the GPU. A buffer is guaranteed to be contiguous, meaning that all the data is store sequentially in memory. Buffer's generally are used to store simple things like a struct or an array, but it can store more complex stuff such as graph structures like a tree (provided all the nodes are stored together and don't reference anything outside of the buffer). We are going to use buffer's a lot, so let's get started with two of the most important one's: the vertex buffer, and the index buffer.
|
A buffer is a blob of data on the GPU. A buffer is guaranteed to be contiguous, meaning that all the data is store sequentially in memory. Buffer's generally are used to store simple things like a struct or an array, but it can store more complex stuff such as graph structures like a tree (provided all the nodes are stored together and don't reference anything outside of the buffer). We are going to use buffer's a lot, so let's get started with two of the most important one's: the vertex buffer, and the index buffer.
|
||||||
|
|
||||||
## The vertex buffer
|
## The vertex buffer
|
||||||
Previously we've stored vertex data directly in the vertex shader. While that worked fine to get our bootstraps on, it simply won't do longterm. The types of objects we need to draw will vary in size, and recompiling the shader whenever we need to update the model would massively slow down our program. Instead we are going to use buffers to store the vertex data we want to draw. Before we do that though we need to describe what a vertex looks like. We'll do this by creating a new struct.
|
Previously we've stored vertex data directly in the vertex shader. While that worked fine to get our bootstraps on, it simply won't do long-term. The types of objects we need to draw will vary in size, and recompiling the shader whenever we need to update the model would massively slow down our program. Instead we are going to use buffers to store the vertex data we want to draw. Before we do that though we need to describe what a vertex looks like. We'll do this by creating a new struct.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// main.rs
|
// main.rs
|
||||||
@ -83,7 +83,6 @@ Self {
|
|||||||
swap_chain,
|
swap_chain,
|
||||||
render_pipeline,
|
render_pipeline,
|
||||||
vertex_buffer,
|
vertex_buffer,
|
||||||
hidpi_factor,
|
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -324,7 +323,6 @@ Self {
|
|||||||
// NEW!
|
// NEW!
|
||||||
index_buffer,
|
index_buffer,
|
||||||
num_indices,
|
num_indices,
|
||||||
hidpi_factor,
|
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user