VERY IMPORTANT NOTE: Im trying to fill a triangle. I have already made the 3D part. Sorry if this wasn't understandable.
I'm currently trying to create a simple 3D-Engine. Well, I have successfully drawn a triangle using this method.
void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) { drawLine(x1, y1, x2, y2); //Usage: drawLine(x, y, x1, y1) drawLine(x2, y2, x3, y3); drawLine(x3, y3, x1, y1); } After this method worked surprisingly well and a cube appeared very convincing, I tried to add lighting. Now I'm facing a pretty big problem. After a long thought I found this method of filling a triangle but here is the problem. It paints a few triangles but not all. Unfortunately I cannot show any pictures because I do not have a camera and a screenshot would not work (as I explain later). My theory is that it only draws bottom flat triangles (or the other way around). What should I change about my method so that it works? Thanks in advance.
This is my filling code:
void FillTriangle(int x1, int y1, int x2, int y2, int x3, int y3) { drawLine(x1, y1, x2, y2); drawLine(x2, y2, x3, y3); drawLine(x3, y3, x1, y1); for(int x = x1; x<=x2; x++) { for(int y = y1; y<=y2; y++) { drawLine(x3, y3, x, y); } } }