|
@@ -104,34 +104,26 @@ void olivec_draw_line(uint32_t *pixels, size_t pixels_width, size_t pixels_heigh
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void olivec_sort_triangle_points_by_y(int *x1, int *y1,
|
|
|
- int *x2, int *y2,
|
|
|
- int *x3, int *y3)
|
|
|
-{
|
|
|
-
|
|
|
- if (*y1 > *y2) {
|
|
|
- OLIVEC_SWAP(int, *x1, *x2);
|
|
|
- OLIVEC_SWAP(int, *y1, *y2);
|
|
|
- }
|
|
|
-
|
|
|
- if (*y2 > *y3) {
|
|
|
- OLIVEC_SWAP(int, *x2, *x3);
|
|
|
- OLIVEC_SWAP(int, *y2, *y3);
|
|
|
- }
|
|
|
-
|
|
|
- if (*y1 > *y2) {
|
|
|
- OLIVEC_SWAP(int, *x1, *x2);
|
|
|
- OLIVEC_SWAP(int, *y1, *y2);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void olivec_fill_triangle(uint32_t *pixels, size_t width, size_t height,
|
|
|
int x1, int y1,
|
|
|
int x2, int y2,
|
|
|
int x3, int y3,
|
|
|
uint32_t color)
|
|
|
{
|
|
|
- olivec_sort_triangle_points_by_y(&x1, &y1, &x2, &y2, &x3, &y3);
|
|
|
+ if (y1 > y2) {
|
|
|
+ OLIVEC_SWAP(int, x1, x2);
|
|
|
+ OLIVEC_SWAP(int, y1, y2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (y2 > y3) {
|
|
|
+ OLIVEC_SWAP(int, x2, x3);
|
|
|
+ OLIVEC_SWAP(int, y2, y3);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (y1 > y2) {
|
|
|
+ OLIVEC_SWAP(int, x1, x2);
|
|
|
+ OLIVEC_SWAP(int, y1, y2);
|
|
|
+ }
|
|
|
|
|
|
int dx12 = x2 - x1;
|
|
|
int dy12 = y2 - y1;
|
|
@@ -170,10 +162,11 @@ void olivec_fill_triangle(uint32_t *pixels, size_t width, size_t height,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// TODO: supersampling for circles and lines
|
|
|
+// TODO: Olivec_Canvas
|
|
|
+// TODO: Alpha blending
|
|
|
+// TODO: supersampling
|
|
|
// TODO: olivec_draw_circle
|
|
|
// TODO: olivec_(draw|fill)_ellipse
|
|
|
-// TODO: WebAssembly Demo
|
|
|
-// TODO: Alpha blending
|
|
|
+// TODO: Benchmarking
|
|
|
|
|
|
#endif // OLIVE_C_
|