From 760ff67cd8fd65d70485b2c019d53a16d6fca48b Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Tue, 9 Jun 2020 22:19:43 +0900 Subject: [PATCH] Add a description about to_rgba() --- docs/beginner/tutorial9-models/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/beginner/tutorial9-models/README.md b/docs/beginner/tutorial9-models/README.md index 166c8e78..b2208f4a 100644 --- a/docs/beginner/tutorial9-models/README.md +++ b/docs/beginner/tutorial9-models/README.md @@ -387,6 +387,12 @@ let material = &self.obj_model.materials[mesh.material]; render_pass.draw_mesh_instanced(mesh, material, 0..self.instances.len() as u32, &self.uniform_bind_group); ``` +We also need to make a subtle change on `from_image()` method in `texture.rs`. PNGs work fine with `as_rgba8()`, as they have an alpha channel. But, JPEGs don't have an alpha channel, and the code would panic if we try to call `as_rgba8()` on the JPEG texture image we are going to use. Instead, we can use `to_rgba()` to handle such an image. + +```rust +let rgba = img.to_rgba(); +``` + With all that in place we should get the following. ![cubes-correct.png](./cubes-correct.png)