From e55774c3e1717347283b1e9f8241cac5f52c9fed Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 22 Jul 2018 15:33:28 +0200 Subject: [PATCH] Make it possible to set alpha/delta/gamma on the command line, for grid searches. --- flow.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/flow.cpp b/flow.cpp index 1761881..e7f6820 100644 --- a/flow.cpp +++ b/flow.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -965,6 +966,35 @@ private: int main(int argc, char **argv) { + static const option long_options[] = { + { "alpha", required_argument, 0, 'a' }, + { "delta", required_argument, 0, 'd' }, + { "gamma", required_argument, 0, 'g' } + }; + + for ( ;; ) { + int option_index = 0; + int c = getopt_long(argc, argv, "a:d:g:", long_options, &option_index); + + if (c == -1) { + break; + } + switch (c) { + case 'a': + vr_alpha = atof(optarg); + break; + case 'd': + vr_delta = atof(optarg); + break; + case 'g': + vr_gamma = atof(optarg); + break; + default: + fprintf(stderr, "Unknown option '%s'\n", argv[option_index]); + exit(1); + }; + } + if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); exit(1); @@ -988,8 +1018,8 @@ int main(int argc, char **argv) // Load pictures. unsigned width1, height1, width2, height2; - GLuint tex0 = load_texture(argc >= 2 ? argv[1] : "test1499.png", &width1, &height1); - GLuint tex1 = load_texture(argc >= 3 ? argv[2] : "test1500.png", &width2, &height2); + GLuint tex0 = load_texture(argc >= (optind + 1) ? argv[optind] : "test1499.png", &width1, &height1); + GLuint tex1 = load_texture(argc >= (optind + 2) ? argv[optind + 1] : "test1500.png", &width2, &height2); if (width1 != width2 || height1 != height2) { fprintf(stderr, "Image dimensions don't match (%dx%d versus %dx%d)\n", -- 2.39.2