Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoqsh committed Feb 27, 2024
1 parent 8150f99 commit ff6671a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ let triangle = |vert: sl::InVertex<Vert>| {

As you can see from the snippet, the shader requires you to provide two things: the position of the vertex on the screen and the color of each fragment/pixel. The result is a `triangle` function, but if you ask for its type in the IDE you may notice that it is more complex than usual:
```rust
impl Fn(InVertex<Vert>) -> Out<Ret<Compose<Ret<ReadVertex, Vec2<f32>>, Ret<NewVec<(f32, f32), Vs>, Vec2<f32>>>, Vec4<f32>>, Ret<Compose<Ret<Fragment<Ret<ReadVertex, Vec3<f32>>>, Vec3<f32>>, f32>, Vec4<f32>>>
impl Fn(InVertex<Vert>) -> Out<
Ret<Compose<Ret<ReadVertex, Vec2<f32>>, Ret<NewVec<(f32, f32), Vs>, Vec2<f32>>>, Vec4<f32>>,
Ret<Compose<Ret<Fragment<Ret<ReadVertex, Vec3<f32>>>, Vec3<f32>>, f32>, Vec4<f32>>,
>
```

That's because this function doesn't actually compute anything. It is needed only to describe the method for computing what we need on GPU. During shader instantiation, this function is used to compile an actual shader. However, this saves us from having to write the shader in wgsl and allows to typecheck at compile time. For example, dunge checks that a vertex type in a shader matches with a mesh used during rendering. It also checks types inside the shader itself.
Expand Down Expand Up @@ -141,7 +144,9 @@ Now you can run our application and see the window:
window.run(dunge::update(upd, draw))?;
```

<img align="center" src="https://github.com/nanoqsh/dunge/tree/main/examples/window/s.png">
<div align="center">
<img src="./examples/window/s.png">
</div>

You can see full code from this example [here](https://github.com/nanoqsh/dunge/tree/main/examples/window) and run it using:
```sh
Expand Down

0 comments on commit ff6671a

Please sign in to comment.