Here's the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | internal void DrawPolygon(app_offscreen_buffer *Buffer,int points, ...) { v2 start = {}; v2 tempPoint1 = {}; v2 tempPoint2 = {}; va_list args; if(points>=3) { va_start(args, points); start = va_arg(args, v2); tempPoint1 = start; points--; for (int i=0; i< points-1; i++ ) { tempPoint2 = va_arg(args, v2); DrawBresenhamLine(Buffer,tempPoint1.x,tempPoint1.y, tempPoint2.x,tempPoint2.y); tempPoint1 = tempPoint2; } DrawBresenhamLine(Buffer,start.x,start.y, tempPoint2.x,tempPoint2.y); va_end(args); } } internal void DrawPolygonEx(app_offscreen_buffer *Buffer,int num_vertices,v2 *points){ for(int i=0;i<num_vertices-1;i++) { DrawBresenhamLine(Buffer,points[i].x, points[i].y, points[i+1].x, points[i+1].y); } DrawBresenhamLine(Buffer,points[0].x, points[0].y, points[(num_vertices)-1].x, points[(num_vertices)-1].y); } |
And do you no any good free tool to check difference between 2 function calls or maybe a code profiler ....