Well I say solid green in the title, but of course you can use any colour you want - and because we are only aiming to draw a solid triangle here - later on, when you add things like lighting and shading to your drawing/3D rasterization engine, the triangle will be multi-coloured....using Gourand shading for example :)
Green triangle rendered using rasterization.
Part-1- of our code demonstrates the principle of how you would go about rendering a general triangle. Remember what I said 'General' Triangle. As you will most likely split up your rendering process into 3 parts eventually, so you can get the most speed. The 3 types of triangle, are a triangle with a flat bottom....and triangle with a flat top...and of course a general triangle...which can be any type of triangle.
I think the code is pretty simple to follow, but I will take the time to explain it in a bit - but be sure you understand how it works - as we will be modifying it to a fixed point 16-16 format later on so we can sqeeezzeee the most amount of speed from this simple triangle drawing algorithm.