
Notes:
Code:
Hints:
Step #1: Adding per-pixel color
The only difference is the additional arguments for red, green, blue:

Now we set color for every pixel we draw:

Now we have to also swap colors and calculate color slopes:

Step #2: Adding class/struct to encapsulate variables:
Add SWAP_POINT() function:

Add class to hold pos[] and color[] data for POINT:

Rewrite draw_line() function to use POINT class:

Step #3: Use "vector" instructions to make code more compact:
Add "vector" functions:

Rewrite draw_line() function using "vector" routines:

Step #4: combining cases to make code shorter:

Exercises:
write draw_quad() function to draw rectangle using POINTs:

Write function to draw one quad:
Write function to draw many quads:
Comments