From 7fe1dc57d2249236b83aa1a78001a9245d6e1681 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 13 Dec 2010 20:18:39 +0000 Subject: [PATCH] Allow to specify the snapshot prefix. --- glretrace.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/glretrace.py b/glretrace.py index c516c16..a66d5d2 100644 --- a/glretrace.py +++ b/glretrace.py @@ -164,10 +164,12 @@ unsigned __frame = 0; long long __startTime = 0; static enum { MODE_DISPLAY = 0, - MODE_SCREENSHOT, + MODE_SNAPSHOT, MODE_COMPARE, } __mode = MODE_DISPLAY; +const char *__snapshot_prefix = ""; + static void checkGlError(void) { @@ -228,10 +230,10 @@ static void display_noop(void) { static void frame_complete(void) { ++__frame; - if (!__reshape_window && (__mode == MODE_SCREENSHOT || __mode == MODE_COMPARE)) { + if (!__reshape_window && (__mode == MODE_SNAPSHOT || __mode == MODE_COMPARE)) { char filename[PATH_MAX]; - snprintf(filename, sizeof filename, "screenshot_%04u.png", __frame); + snprintf(filename, sizeof filename, "%s%04u.png", __snapshot_prefix, __frame); Image::Image *ref; if (__mode == MODE_COMPARE) { @@ -246,7 +248,7 @@ static void frame_complete(void) { Image::Image src(__window_width, __window_height, true); glReadPixels(0, 0, __window_width, __window_height, GL_RGBA, GL_UNSIGNED_BYTE, src.pixels); - if (__mode == MODE_SCREENSHOT) { + if (__mode == MODE_SNAPSHOT) { if (src.writePNG(filename) && verbosity) { std::cout << "Wrote " << filename << "\n"; } @@ -317,8 +319,9 @@ static void usage(void) { "Usage: glretrace [OPTION] TRACE\n" "Replay TRACE.\n" "\n" - " -c compare against screenshots\n" + " -c compare against snapshots\n" " -db use a double buffer visual\n" + " -p PREFIX snapshot prefix\n" " -s take snapshots\n" " -v verbose output\n"; } @@ -343,8 +346,10 @@ int main(int argc, char **argv) } else if (!strcmp(arg, "--help")) { usage(); return 0; + } else if (!strcmp(arg, "-p")) { + __snapshot_prefix = argv[++i]; } else if (!strcmp(arg, "-s")) { - __mode = MODE_SCREENSHOT; + __mode = MODE_SNAPSHOT; } else if (!strcmp(arg, "-v")) { ++verbosity; } else { -- 2.7.4