summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--render.c20
-rw-r--r--render.h6
2 files changed, 17 insertions, 9 deletions
diff --git a/render.c b/render.c
index 5949ee9..04c39dd 100644
--- a/render.c
+++ b/render.c
@@ -215,8 +215,6 @@ void ren_text(
ren_char(r, c, x, y, *s);
}
-#define max_tri_ec 2
-
void swap_vert(int* a, int* b, int ec) {
int t, i;
for (i = 0; i < ec; i++) {
@@ -226,28 +224,38 @@ void swap_vert(int* a, int* b, int ec) {
}
}
-int tri_hand(int* v0, int* v1, int* v2) {
+int tri_hand(
+ const int* v0,
+ const int* v1,
+ const int* v2
+) {
return
(v1[0] - v0[0]) * (v2[1] - v0[1]) -
(v2[0] - v0[0]) * (v1[1] - v0[1]) > 0;
}
+#define max_tri_ec 8
+
void ren_tri(
Renderer* r,
Colour c,
- int* v0,
- int* v1,
- int* v2,
+ const int* iv0,
+ const int* iv1,
+ const int* iv2,
Tri_Mode mode
) {
int ec, sx, ex, x, y, me, ms, e, ha;
int sb = 0, * d;
+ int v0[max_tri_ec], v1[max_tri_ec], v2[max_tri_ec];
switch (mode) {
case tri_mode_flat:
ec = 2;
break;
default: assert(0);
}
+ vec_cpy(v0, iv0, ec);
+ vec_cpy(v1, iv1, ec);
+ vec_cpy(v2, iv2, ec);
if (v0[1] > v1[1])
swap_vert(v0, v1, ec);
if (v1[1] > v2[1])
diff --git a/render.h b/render.h
index 887cffa..a8d5a4d 100644
--- a/render.h
+++ b/render.h
@@ -55,9 +55,9 @@ typedef enum {
void ren_tri(
Renderer* r,
Colour c,
- int* v0,
- int* v1,
- int* v2,
+ const int* v0,
+ const int* v1,
+ const int* v2,
Tri_Mode mode
);