Posted: Tue Nov 17
Due: Monday 11/23 10:00am
Fill Them Triangles!
Add scanline conversion and z-buffering to your graphics engine.
Parser Note:
- In the previous assignment, I noted that the
clearcommand was no longer needed, because we immediately clear the polygon/edge matrix after a shape is drawn. In order to test Scanline conversion on multiple shapes, a different version of clear is useful. Now, clear will clear the screen and zbuffer, allowing us to reset and test multiple shapes in the same script.- I have added this command to the provided source code, everyone should implement it even if not using the provided code.
Additions to the engine:
- Scanline conversion
- Create a function to draw a single scanline. Since scanlines are always horizontal, it should be a much simpler function than our all-purpose
draw_line - Create a new function that handles the scanline conversion. It should use your new
draw_scanlinefunction. - Call
scanline_convertin yourdraw_polygonsfunction. - Make sure that you change color values for each triangle.
- You can do random coloring, create a cycle of colors to go through, don’t take up too much time on this.
- Create a function to draw a single scanline. Since scanlines are always horizontal, it should be a much simpler function than our all-purpose
- Z-buffering
- In the base files provided, I’ve added a z-buffer argument to the necessary functions, but have not done anything with it. Whenever you interact with the screen buffer, you should also look at the z bufffer.