X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=src%2Fopt.cc;h=b25edc5a17246f24a0b5889c7e4690ba8ca91e03;hp=0b9914983c5de853b38120cc121ee6cc834a1abf;hb=818d6e49d86bc91748396a8c408cd84d17e10994;hpb=05cc7dce02b656e633c880dcc55acdf370cb25c1 diff --git a/src/opt.cc b/src/opt.cc index 0b99149..b25edc5 100644 --- a/src/opt.cc +++ b/src/opt.cc @@ -7,6 +7,7 @@ Options opt; enum { + OPT_SIZE, OPT_VR, OPT_SRGB, OPT_FULLSCREEN, @@ -16,6 +17,7 @@ enum { static optcfg_option options[] = { // short, long, id, desc + {'s', "size", OPT_SIZE, "window size (WxH)"}, {0, "vr", OPT_VR, "enable VR mode"}, {0, "srgb", OPT_SRGB, "use linear color space"}, {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"}, @@ -30,6 +32,8 @@ bool init_options(int argc, char **argv, const char *cfgfile) { // default options memset(&opt, 0, sizeof opt); + opt.width = 1280; + opt.height = 800; opt.srgb = true; optcfg *oc = optcfg_init(options); @@ -60,6 +64,16 @@ static bool is_enabled(optcfg *oc) static int opt_handler(optcfg *oc, int optid, void *cls) { switch(optid) { + case OPT_SIZE: + { + char *valstr = optcfg_next_value(oc); + if(!valstr || sscanf(valstr, "%dx%d", &opt.width, &opt.height) != 2) { + fprintf(stderr, "size must be in the form: WIDTHxHEIGHT\n"); + return -1; + } + } + break; + case OPT_VR: opt.vr = is_enabled(oc); break;