diff options
author | Krow Savcik <krow@savcik.xyz> | 2023-12-31 15:28:42 +0200 |
---|---|---|
committer | Krow Savcik <krow@savcik.xyz> | 2023-12-31 15:28:42 +0200 |
commit | bd26db954e14d2196c4f8a83d1fbf09c87c66ef9 (patch) | |
tree | ef6351b0d7890689aca8ba99905c8516a15af0bd | |
parent | 3d933458666b2224a7fb100c289059b90609eae5 (diff) |
feature: line toggling
Added line toggling with 'T'
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | draw.c | 26 | ||||
-rw-r--r-- | draw.h | 2 |
3 files changed, 18 insertions, 11 deletions
@@ -17,6 +17,7 @@ Controls - **W,A,S,D** for moving. - **M** for toggling mouse-lock. +- **T** for toggling line drawing. - **arrows** for rotating camera. - **J,K** for moving vertically. - **I** for object importing. @@ -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 @@ -3,4 +3,4 @@ int draw_init(); void add_obj_interactive(); void redo_obj(); -extern int w, h; +extern int w, h, drawlines; |