dungeon_crawler

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/prototype/src/cfg.cc	Tue Aug 21 03:17:48 2012 +0300
     1.3 @@ -0,0 +1,46 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdlib.h>
     1.6 +#include <string.h>
     1.7 +#include "cfg.h"
     1.8 +
     1.9 +Config cfg;
    1.10 +
    1.11 +Config::Config()
    1.12 +{
    1.13 +	width = 800;
    1.14 +	height = 600;
    1.15 +	stereo = false;
    1.16 +	level_file = "0.level";
    1.17 +	tileset_file = "default.tileset";
    1.18 +}
    1.19 +
    1.20 +bool Config::parse_args(int argc, char **argv)
    1.21 +{
    1.22 +	for(int i=1; i<argc; i++) {
    1.23 +		if(strcmp(argv[i], "-s") == 0) {
    1.24 +			if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
    1.25 +				fprintf(stderr, "-s must be followed by <width>x<height>\n");
    1.26 +				return false;
    1.27 +			}
    1.28 +		} else if(strcmp(argv[i], "-stereo") == 0) {
    1.29 +			stereo = true;
    1.30 +		} else if(strcmp(argv[i], "-level") == 0) {
    1.31 +			level_file = argv[++i];
    1.32 +		} else if(strcmp(argv[i], "-tileset") == 0) {
    1.33 +			tileset_file = argv[++i];
    1.34 +		} else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
    1.35 +			printf("Usage: %s [options]\n", argv[0]);
    1.36 +			printf("  -s WxH              window size (resolution)\n");
    1.37 +			printf("  -level <filename>   specify which level file to load\n");
    1.38 +			printf("  -tileset <filename> specify which tileset to use\n");
    1.39 +			printf("  -stereo             enable stereoscopic rendering\n");
    1.40 +			printf("  -h/-help            print usage information and exit\n");
    1.41 +			exit(0);
    1.42 +
    1.43 +		} else {
    1.44 +			fprintf(stderr, "unrecognized argument: %s\n", argv[i]);
    1.45 +			return false;
    1.46 +		}
    1.47 +	}
    1.48 +	return true;
    1.49 +}