From: John Tsiombikas Date: Wed, 27 Jul 2016 04:08:59 +0000 (+0300) Subject: added more options X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=commitdiff_plain;h=818d6e49d86bc91748396a8c408cd84d17e10994 added more options --- diff --git a/src/app.cc b/src/app.cc index 81325f6..730302e 100644 --- a/src/app.cc +++ b/src/app.cc @@ -28,6 +28,9 @@ bool app_init(int argc, char **argv) if(!init_options(argc, argv, 0)) { return false; } + app_resize(opt.width, opt.height); + app_fullscreen(opt.fullscreen); + if(init_opengl() == -1) { return false; } diff --git a/src/app.h b/src/app.h index a95e117..aecf645 100644 --- a/src/app.h +++ b/src/app.h @@ -20,6 +20,8 @@ void app_mouse_button(int bn, bool pressed, int x, int y); void app_mouse_motion(int x, int y); // the following functions are implemented by the window system backend +void app_resize(int x, int y); +void app_fullscreen(int fs); void app_quit(); void app_redraw(); void app_swap_buffers(); diff --git a/src/main.cc b/src/main.cc index 7e700a6..d7dea97 100644 --- a/src/main.cc +++ b/src/main.cc @@ -72,6 +72,16 @@ break_evloop: return 0; } +void app_resize(int x, int y) +{ + SDL_SetWindowSize(win, x, y); +} + +void app_fullscreen(int fs) +{ + SDL_SetWindowFullscreen(win, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); +} + void app_quit() { quit = true; 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; diff --git a/src/opt.h b/src/opt.h index c0bb5f6..fc4d672 100644 --- a/src/opt.h +++ b/src/opt.h @@ -2,6 +2,7 @@ #define OPT_H_ struct Options { + int width, height; bool vr; bool srgb; bool fullscreen;