From bd26db954e14d2196c4f8a83d1fbf09c87c66ef9 Mon Sep 17 00:00:00 2001 From: Krow Savcik Date: Sun, 31 Dec 2023 15:28:42 +0200 Subject: feature: line toggling Added line toggling with 'T' --- draw.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'draw.c') diff --git a/draw.c b/draw.c index 9e79b93..9b703be 100644 --- a/draw.c +++ b/draw.c @@ -6,8 +6,9 @@ #include "sim.h" /*#define SHADOW*/ -#define TRIANGLELINES -#define MAXTRIANGLE 2048 +/*#define TRIANGLELINES*/ +int drawlines; +#define MAXTRIANGLE (1<<16) #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define INTTOCOL(C) (C>>16), ((C>>8)%256), (C%256) @@ -112,7 +113,10 @@ void redo_obj() { tgs_cnt = 0; - add_obj("obj/car.obj", P(0,0,0)); +/* add_obj("obj/car.obj", P(0,0,0));*/ +/* add_obj("obj/peach.obj", P(0,0,0));*/ +/* add_obj("obj/toad.obj", P(20,0,0));*/ + add_obj("obj/psyduck.obj", P(0,0,0)); } void @@ -230,6 +234,8 @@ draw_triangle(Point x, Point y, Point z) mny = MIN(a.y, MIN(b.y, c.y)); mxy = MAX(a.y, MAX(b.y, c.y)); +/* if (mnx < 0 || mxx >= w || mny < 0 || mxy >= h) return;*/ + /* Fake depth :> */ for(i = MAX(mnx, 0); i <= MIN(mxx, w-1); ++i) { @@ -247,13 +253,13 @@ draw_triangle(Point x, Point y, Point z) } SDL_RenderDrawPoints(ren, pts_queue, pts_queue_cnt); -#ifdef TRIANGLELINES - SDL_SetRenderDrawColor(ren, 0xff, 0xff, 0xff, 0xff); - SDL_SetRenderDrawColor(ren, 0x00, 0x00, 0x00, 0xff); - SDL_RenderDrawLine(ren, a.x, a.y, b.x, b.y); - SDL_RenderDrawLine(ren, c.x, c.y, b.x, b.y); - SDL_RenderDrawLine(ren, a.x, a.y, c.x, c.y); -#endif + if (drawlines) { +/* SDL_SetRenderDrawColor(ren, 0xff, 0xff, 0xff, 0xff);*/ + SDL_SetRenderDrawColor(ren, 0x00, 0x00, 0x00, 0xff); + SDL_RenderDrawLine(ren, a.x, a.y, b.x, b.y); + SDL_RenderDrawLine(ren, c.x, c.y, b.x, b.y); + SDL_RenderDrawLine(ren, a.x, a.y, c.x, c.y); + } } void -- cgit v1.2.3