if(!init_options(argc, argv, 0)) {
return false;
}
+ app_resize(opt.width, opt.height);
+ app_fullscreen(opt.fullscreen);
+
if(init_opengl() == -1) {
return false;
}
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();
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;
Options opt;
enum {
+ OPT_SIZE,
OPT_VR,
OPT_SRGB,
OPT_FULLSCREEN,
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"},
{
// default options
memset(&opt, 0, sizeof opt);
+ opt.width = 1280;
+ opt.height = 800;
opt.srgb = true;
optcfg *oc = optcfg_init(options);
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;