summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-13 06:53:53 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-13 06:53:53 (GMT)
commit55e2604f9cf7145d3aa4456658260ace68bc260c (patch)
treed69e89401dd64a247425821a53a975385bb8f81d /meme/gui.c
parent6a7b99db7751a7b7bceb2e79d7b11f68a2ad226a (diff)
downloadmisc-55e2604f9cf7145d3aa4456658260ace68bc260c.zip
misc-55e2604f9cf7145d3aa4456658260ace68bc260c.tar.gz
misc-55e2604f9cf7145d3aa4456658260ace68bc260c.tar.bz2
meme/: add overlays (option -o, key O); clean up log file implementation
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/meme/gui.c b/meme/gui.c
index d2ac9d6..b615364 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -21,6 +21,7 @@
#include "util.h"
#include "time.h"
#include "mesh.h"
+#include "overlay.h"
#include "plane.h"
#include "gaux.h"
#include "text.h"
@@ -36,6 +37,8 @@
#define MARK_WIDTH 2
#define MARK_LEN 20
+#define OVERLAY_WIDTH 4
+
#define EDGE_RGBA 0x000000ff
#define CURSOR_RGBA 0xff202080
#define PROFILE_RGBA 0x2020ffff
@@ -43,6 +46,7 @@
#define MARK_B_RGBA 0x3030ffff
#define CONTRAST_RGBA 0xffe080ff
#define EQUAL_RGBA 0xf080ffff
+#define OVERLAY_RGBA 0xffc01060
#define DEPTH_RANGE 0xc0
#define DEPTH_OFFSET 0x30
@@ -54,6 +58,7 @@ static int x_min, x_max, y_min, y_max, z_min, z_max;
static int zoom;
static bool show_grid = 0;
static bool show_profiles = 0;
+static bool show_overlay = 0;
static const struct vertex *cursor;
@@ -876,6 +881,51 @@ static void clear_markers(void)
}
+/* ----- Overlay ----------------------------------------------------------- */
+
+
+
+static Sint16 ovl_x, ovl_y;
+static int ovl_ok;
+
+
+static void moveto(void *user, int x, int y)
+{
+ ovl_ok = coord(x, y, &ovl_x, &ovl_y);
+}
+
+
+static void lineto(void *user, int x, int y)
+{
+ SDL_Surface *s = user;
+ Sint16 to_x = 0, to_y = 0; /* @@@ suppress warning */
+ bool ok;
+
+ ok = coord(x, y, &to_x, &to_y);
+ if (ovl_ok >= 0 && ok >= 0 && (ovl_ok || ok))
+ aalineColor(s, ovl_x, ovl_y, to_x, to_y,
+ OVERLAY_RGBA);
+#if 0
+ /*
+ * Something's wrong with thickLineColor. It places the lines with a
+ * substantial offset from the correct position, or even makes them
+ * veer off the screen.
+ */
+ thickLineColor(s, ovl_x, ovl_y, to_x, to_y,
+ OVERLAY_WIDTH, OVERLAY_RGBA);
+#endif
+ ovl_x = to_x;
+ ovl_y = to_y;
+ ovl_ok = ok;
+}
+
+
+static void draw_overlay(SDL_Surface *s)
+{
+ overlay_draw(moveto, lineto, s);
+}
+
+
/* ----- Last mouse position ---------------------------------------------- */
@@ -1185,6 +1235,9 @@ static bool event_loop(SDL_Surface **surf, const char *logfile)
case SDLK_g:
show_grid = !show_grid;
return 0;
+ case SDLK_o:
+ show_overlay = !show_overlay;
+ return 0;
case SDLK_p:
show_profiles = !show_profiles;
return 0;
@@ -1261,6 +1314,8 @@ time_start(&t);
draw(surf);
time_stop(&t);
fprintf(stderr, "%.3f s @ zoom %d\n", time_ms(&t)/1000.0, zoom);
+ if (show_overlay)
+ draw_overlay(surf);
SDL_UnlockSurface(surf);
SDL_UpdateRect(surf, 0, 0, 0, 0);