Lab: Textured Triangles

From The GPU and You.

Start by getting the WGPU triangle example from the "Getting WGPU Going" section of the lecture notes.

Answer these questions as you work through the lecture notes:

  1. Which is the vertex shader, and which is the fragment shader?
  2. This vertex shader doesn't take in vertex information from a vertex buffer, but only vertex indices. Which index produces the top middle point of the triangle?
  3. How would you change the color of the output triangle?
  4. Does this file also explain why the background is green?
  5. Write down four jargon terms you didn't know before and briefly define them (if you knew them all, look through the WGPU documentation for more until you get to four).
  6. Can you think of a situation where you would want to use multiple render pipelines within a single render pass?
  7. Can you think of a situation where you would want to use multiple render passes during one frame?
  8. If we wanted to draw two triangles (a quadrilateral) instead of one, in what two places would we need to change the code?

Download this "47" image and put it in a content folder next to src: 47.png

Then, follow along with the rest of the lecture notes and figure out where to insert the code snippets so that they make sense and achieve the goal of putting a picture on the triangles. For example, you need to define the load_texture function at the top level of your file, while the let tex_47 = load_texture()...) snippet needs to be inside of your run function after the device and queue have been created but before calling event_loop.run(...).

Once you have the 47 image on screen, you're done! Talk to Prof Osborn or a TA.