summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-13 00:36:21 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-13 00:36:21 (GMT)
commitc2527f76ad3d79cc087640b62b9e27f14b3e6869 (patch)
treea07d8690dc2e36e50569551510b5073e43208741 /meme/gui.c
parent6cea3edc58b963ad06ee226d6fbceef3a9640c6a (diff)
downloadmisc-c2527f76ad3d79cc087640b62b9e27f14b3e6869.zip
misc-c2527f76ad3d79cc087640b62b9e27f14b3e6869.tar.gz
misc-c2527f76ad3d79cc087640b62b9e27f14b3e6869.tar.bz2
meme/gui.c: clean up color handling; increase contrast of depth grading
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/meme/gui.c b/meme/gui.c
index 97a42a5..9924c46 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -28,9 +28,14 @@
#define YRES 1024
#define CURSOR_R 5
+
+#define EDGE_RGBA 0x000000ff
#define CURSOR_RGBA 0xff202080
#define PROFILE_RGBA 0x2020ffff
+#define DEPTH_RANGE 0xc0
+#define DEPTH_OFFSET 0x30
+
static int x_orig, y_orig;
static int x_min, x_max, y_min, y_max, z_min, z_max;
@@ -116,7 +121,7 @@ static void surface_draw(SDL_Surface *s)
Sint16 xa, ya, xb, yb, xc, yc;
int a, b, c;
int z3;
- Uint32 col;
+ uint8_t col;
for (f = facets; f; f = f->next) {
a = coord(f->v[0]->x, f->v[0]->y, &xa, &ya);
@@ -132,9 +137,10 @@ static void surface_draw(SDL_Surface *s)
continue;
z3 = f->v[0]->z + f->v[1]->z + f->v[2]->z - z_min*3;
- col = z3*0x90/3/(z_max-z_min)*0x1010100 + 0x606060ff;
-
- filledTrigonColor(s, xa, ya, xb, yb, xc, yc, col);
+ col = z3*DEPTH_RANGE/3/(z_max-z_min) + DEPTH_OFFSET;
+
+ filledTrigonColor(s, xa, ya, xb, yb, xc, yc,
+ col * 0x1010100 + 0xff);
}
}
@@ -154,7 +160,7 @@ static bool edge_draw(const struct vertex *a, const struct vertex *b,
return 0;
if (!(res_a || res_b))
return 0;
- aalineColor(s, xa, ya, xb, yb, 0x000000ff);
+ aalineColor(s, xa, ya, xb, yb, EDGE_RGBA);
return 0;
}