X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fopt.cc;h=15c61ccd209df95f7a67d437260b7bb348018766;hp=9226785206e33bbff57c72d371555f3974ac177c;hb=dd5d77962633caa459b366e596295023a727b33c;hpb=c5c29f4044110dd153ee5ca3b018c812d518a053 diff --git a/src/opt.cc b/src/opt.cc index 9226785..15c61cc 100644 --- a/src/opt.cc +++ b/src/opt.cc @@ -9,15 +9,24 @@ Options opt; Options def_opt = { 1280, 800, false, // vr - false // fullscreen + false, // fullscreen + 0, // scene file + true, // music + true, // reflections + 0, // data url + 0.0f // minimum turn angle }; enum { OPT_SIZE, OPT_VR, - OPT_SRGB, OPT_FULLSCREEN, OPT_WINDOWED, + OPT_SCENEFILE, + OPT_MUSIC, + OPT_REFLECT, + OPT_DATAURL, + OPT_MIN_TURN, OPT_HELP }; @@ -27,6 +36,11 @@ static optcfg_option options[] = { {0, "vr", OPT_VR, "enable VR mode"}, {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"}, {'w', "windowed", OPT_WINDOWED, "run in windowed mode"}, + {0, "scene", OPT_SCENEFILE, "scene file to open"}, + {'m', "music", OPT_MUSIC, "play background audio"}, + {'r', "reflect", OPT_REFLECT, "render reflections"}, + {0, "url", OPT_DATAURL, "data URL"}, + {0, "minturn", OPT_MIN_TURN, "minimum turn angle"}, {'h', "help", OPT_HELP, "print usage and exit"}, OPTCFG_OPTIONS_END }; @@ -89,8 +103,37 @@ static int opt_handler(optcfg *oc, int optid, void *cls) opt.fullscreen = !is_enabled(oc); break; + case OPT_SCENEFILE: + opt.scenefile = strdup(optcfg_next_value(oc)); + break; + + case OPT_MUSIC: + opt.music = is_enabled(oc); + break; + + case OPT_REFLECT: + opt.reflect = is_enabled(oc); + break; + + case OPT_DATAURL: + opt.data_url = strdup(optcfg_next_value(oc)); + break; + + case OPT_MIN_TURN: + { + int deg; + char *valstr = optcfg_next_value(oc); + + if(!valstr || sscanf(valstr, "%d", °) != 1) { + fprintf(stderr, "minimum turn must be a number >= 0 in degrees\n"); + return -1; + } + opt.min_turn = deg; + } + break; + case OPT_HELP: - printf("Usage: vrfileman [options]\nOptions:\n"); + printf("Usage: demo [options]\nOptions:\n"); optcfg_print_options(oc); exit(0); } @@ -99,6 +142,10 @@ static int opt_handler(optcfg *oc, int optid, void *cls) static int arg_handler(optcfg *oc, const char *arg, void *cls) { - fprintf(stderr, "unexpected argument: %s\n", arg); - return -1; + if(opt.scenefile) { + fprintf(stderr, "unexpected argument: %s\n", arg); + return -1; + } + opt.scenefile = arg; + return 0; }