dungeon_crawler

annotate prototype/src/cfg.cc @ 18:5c41e6fcb300

- commandline arguments - stereoscopic rendering - FBO fixed
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 21 Aug 2012 03:17:48 +0300
parents
children 527fede30057
rev   line source
nuclear@18 1 #include <stdio.h>
nuclear@18 2 #include <stdlib.h>
nuclear@18 3 #include <string.h>
nuclear@18 4 #include "cfg.h"
nuclear@18 5
nuclear@18 6 Config cfg;
nuclear@18 7
nuclear@18 8 Config::Config()
nuclear@18 9 {
nuclear@18 10 width = 800;
nuclear@18 11 height = 600;
nuclear@18 12 stereo = false;
nuclear@18 13 level_file = "0.level";
nuclear@18 14 tileset_file = "default.tileset";
nuclear@18 15 }
nuclear@18 16
nuclear@18 17 bool Config::parse_args(int argc, char **argv)
nuclear@18 18 {
nuclear@18 19 for(int i=1; i<argc; i++) {
nuclear@18 20 if(strcmp(argv[i], "-s") == 0) {
nuclear@18 21 if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
nuclear@18 22 fprintf(stderr, "-s must be followed by <width>x<height>\n");
nuclear@18 23 return false;
nuclear@18 24 }
nuclear@18 25 } else if(strcmp(argv[i], "-stereo") == 0) {
nuclear@18 26 stereo = true;
nuclear@18 27 } else if(strcmp(argv[i], "-level") == 0) {
nuclear@18 28 level_file = argv[++i];
nuclear@18 29 } else if(strcmp(argv[i], "-tileset") == 0) {
nuclear@18 30 tileset_file = argv[++i];
nuclear@18 31 } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
nuclear@18 32 printf("Usage: %s [options]\n", argv[0]);
nuclear@18 33 printf(" -s WxH window size (resolution)\n");
nuclear@18 34 printf(" -level <filename> specify which level file to load\n");
nuclear@18 35 printf(" -tileset <filename> specify which tileset to use\n");
nuclear@18 36 printf(" -stereo enable stereoscopic rendering\n");
nuclear@18 37 printf(" -h/-help print usage information and exit\n");
nuclear@18 38 exit(0);
nuclear@18 39
nuclear@18 40 } else {
nuclear@18 41 fprintf(stderr, "unrecognized argument: %s\n", argv[i]);
nuclear@18 42 return false;
nuclear@18 43 }
nuclear@18 44 }
nuclear@18 45 return true;
nuclear@18 46 }