vrseasons

view src/opt.cc @ 2:eea1b91dc3d4

added is_complete() to framebuffer object and fixed GL_UNSUPPORTED_FRAMEBUFFER on intel
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 13 Apr 2015 16:51:52 +0300
parents 393ef1143c9c
children
line source
1 #include <stdio.h>
2 #include <string.h>
3 #include "opt.h"
5 enum {
6 OPT_SIZE,
7 OPT_FULLSCREEN,
8 OPT_WINDOWED,
9 OPT_VR,
10 OPT_HELP,
12 NUM_OPTS
13 };
14 static const char *optname[] = {
15 "size", "fullscreen", "windowed", "vr", "help", 0
16 };
18 static int get_option(const char *str);
20 void default_opt(Options *opt)
21 {
22 opt->xres = 1280;
23 opt->yres = 800;
24 opt->fov = 50.0;
25 opt->fullscreen = false;
26 opt->use_vr = false;
27 }
29 bool parse_args(Options *opt, int argc, char **argv)
30 {
31 for(int i=1; i<argc; i++) {
32 if(argv[i][0] == '-') {
33 int o = get_option(argv[i] + 1);
34 switch(o) {
35 case OPT_SIZE:
36 if(sscanf(argv[++i], "%dx%d", &opt->xres, &opt->yres) != 2) {
37 fprintf(stderr, "invalid argument to option: %s\n", argv[i - 1]);
38 return false;
39 }
40 break;
42 case OPT_FULLSCREEN:
43 opt->fullscreen = true;
44 break;
45 case OPT_WINDOWED:
46 opt->fullscreen = false;
47 break;
49 case OPT_VR:
50 opt->use_vr = true;
51 break;
53 case OPT_HELP:
54 printf("options:\n");
55 for(int j=0; optname[j]; j++) {
56 printf(" -%s\n", optname[j]);
57 }
58 break;
59 }
60 }
61 }
62 return true;
63 }
65 static int get_option(const char *str)
66 {
67 for(int i=0; optname[i]; i++) {
68 if(strcmp(str, optname[i]) == 0) {
69 return i;
70 }
71 }
72 return -1;
73 }