summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-17 12:43:13 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-17 12:43:13 (GMT)
commit09f2659f3e4b2cb61cb17bb9fafd5e543e747806 (patch)
treed96bf5846c61d548467460bc51b38c3b84bb7661 /meme/gui.c
parentb5a90e505ef0bc4e508bdb8340e5a3ebd905d391 (diff)
downloadmisc-09f2659f3e4b2cb61cb17bb9fafd5e543e747806.zip
misc-09f2659f3e4b2cb61cb17bb9fafd5e543e747806.tar.gz
misc-09f2659f3e4b2cb61cb17bb9fafd5e543e747806.tar.bz2
meme/gui.c: add equal highlighting mode when pressing "e"
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/meme/gui.c b/meme/gui.c
index 6142a68..6d52c29 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -13,6 +13,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
+#include <limits.h>
#include "SDL.h"
#include "SDL_gfxPrimitives.h"
@@ -41,6 +42,7 @@
#define MARK_A_RGBA 0x00ff00ff
#define MARK_B_RGBA 0x3030ffff
#define CONTRAST_RGBA 0xffe080ff
+#define EQUAL_RGBA 0xffd0a0ff
#define DEPTH_RANGE 0xc0
#define DEPTH_OFFSET 0x30
@@ -240,6 +242,25 @@ static void end_contrast(void)
}
+/* ----- Equal height ------------------------------------------------------ */
+
+
+static int equal = INT_MAX;
+
+
+static void begin_equal(void)
+{
+ if (cursor)
+ equal = cursor->z;
+}
+
+
+static void end_equal(void)
+{
+ equal = INT_MAX;
+}
+
+
/* ----- Draw the mesh ----------------------------------------------------- */
@@ -249,6 +270,7 @@ static void surface_draw(SDL_Surface *s)
Sint16 xa, ya, xb, yb, xc, yc;
int a, b, c;
int z_off = z_min*3;
+ Uint32 col;
for (f = facets; f; f = f->next) {
a = coord(f->v[0]->x, f->v[0]->y, &xa, &ya);
@@ -263,8 +285,15 @@ static void surface_draw(SDL_Surface *s)
if (!(a || b || c))
continue;
- filledTrigonColor(s, xa, ya, xb, yb, xc, yc,
- z_grad[f->v[0]->z + f->v[1]->z + f->v[2]->z - z_off]);
+ if ((f->v[0]->z < equal && f->v[1]->z < equal &&
+ f->v[2]->z < equal) ||
+ (f->v[0]->z > equal && f->v[1]->z > equal &&
+ f->v[2]->z > equal))
+ col = z_grad[f->v[0]->z + f->v[1]->z + f->v[2]->z -
+ z_off];
+ else
+ col = EQUAL_RGBA;
+ filledTrigonColor(s, xa, ya, xb, yb, xc, yc, col);
}
}
@@ -973,13 +1002,15 @@ static bool event_loop(SDL_Surface **surf)
case SDLK_c:
begin_contrast();
return 0;
+ case SDLK_e:
+ begin_equal();
+ return 0;
case SDLK_g:
show_grid = !show_grid;
return 0;
case SDLK_p:
show_profiles = !show_profiles;
return 0;
- break;
case SDLK_q:
return 1;
default:
@@ -998,6 +1029,9 @@ static bool event_loop(SDL_Surface **surf)
case SDLK_c:
end_contrast();
return 0;
+ case SDLK_e:
+ end_equal();
+ return 0;
default:
break;
}