dungeon_crawler

annotate prototype/src/cfg.cc @ 42:6d71dd4760f9

added flag to force the use of the fallback renderer
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 30 Aug 2012 05:38:03 +0300
parents 527fede30057
children d52711f2b9a1
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@42 15 use_deferred = true;
nuclear@18 16 }
nuclear@18 17
nuclear@18 18 bool Config::parse_args(int argc, char **argv)
nuclear@18 19 {
nuclear@18 20 for(int i=1; i<argc; i++) {
nuclear@25 21 if(argv[i][0] == '-') {
nuclear@25 22 if(strcmp(argv[i], "-s") == 0) {
nuclear@25 23 if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
nuclear@25 24 fprintf(stderr, "-s must be followed by <width>x<height>\n");
nuclear@25 25 return false;
nuclear@25 26 }
nuclear@25 27 } else if(strcmp(argv[i], "-stereo") == 0) {
nuclear@25 28 stereo = true;
nuclear@25 29 } else if(strcmp(argv[i], "-level") == 0) {
nuclear@25 30 level_file = argv[++i];
nuclear@25 31 } else if(strcmp(argv[i], "-tileset") == 0) {
nuclear@25 32 tileset_file = argv[++i];
nuclear@42 33 } else if(strcmp(argv[i], "-no-deferred") == 0) {
nuclear@42 34 use_deferred = false;
nuclear@25 35 } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
nuclear@25 36 printf("Usage: %s [options]\n", argv[0]);
nuclear@25 37 printf(" -s WxH window size (resolution)\n");
nuclear@25 38 printf(" -level <filename> specify which level file to load\n");
nuclear@25 39 printf(" -tileset <filename> specify which tileset to use\n");
nuclear@25 40 printf(" -stereo enable stereoscopic rendering\n");
nuclear@42 41 printf(" -no-deferred disable deferred renderer\n");
nuclear@25 42 printf(" -h/-help print usage information and exit\n");
nuclear@25 43 exit(0);
nuclear@25 44
nuclear@25 45 } else {
nuclear@25 46 fprintf(stderr, "unrecognized option: %s\n", argv[i]);
nuclear@18 47 return false;
nuclear@18 48 }
nuclear@18 49 } else {
nuclear@25 50 level_file = argv[i];
nuclear@18 51 }
nuclear@18 52 }
nuclear@18 53 return true;
nuclear@18 54 }