annotate prototype/src/cfg.cc @ 25:527fede30057
- fixed sphere rendering (PointLight::draw)
- added config argument options
- fixed macosx compilation
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Sat, 25 Aug 2012 02:16:08 +0300 |
parents |
5c41e6fcb300 |
children |
6d71dd4760f9 |
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@25
|
20 if(argv[i][0] == '-') {
|
nuclear@25
|
21 if(strcmp(argv[i], "-s") == 0) {
|
nuclear@25
|
22 if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
|
nuclear@25
|
23 fprintf(stderr, "-s must be followed by <width>x<height>\n");
|
nuclear@25
|
24 return false;
|
nuclear@25
|
25 }
|
nuclear@25
|
26 } else if(strcmp(argv[i], "-stereo") == 0) {
|
nuclear@25
|
27 stereo = true;
|
nuclear@25
|
28 } else if(strcmp(argv[i], "-level") == 0) {
|
nuclear@25
|
29 level_file = argv[++i];
|
nuclear@25
|
30 } else if(strcmp(argv[i], "-tileset") == 0) {
|
nuclear@25
|
31 tileset_file = argv[++i];
|
nuclear@25
|
32 } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
|
nuclear@25
|
33 printf("Usage: %s [options]\n", argv[0]);
|
nuclear@25
|
34 printf(" -s WxH window size (resolution)\n");
|
nuclear@25
|
35 printf(" -level <filename> specify which level file to load\n");
|
nuclear@25
|
36 printf(" -tileset <filename> specify which tileset to use\n");
|
nuclear@25
|
37 printf(" -stereo enable stereoscopic rendering\n");
|
nuclear@25
|
38 printf(" -h/-help print usage information and exit\n");
|
nuclear@25
|
39 exit(0);
|
nuclear@25
|
40
|
nuclear@25
|
41 } else {
|
nuclear@25
|
42 fprintf(stderr, "unrecognized option: %s\n", argv[i]);
|
nuclear@18
|
43 return false;
|
nuclear@18
|
44 }
|
nuclear@18
|
45 } else {
|
nuclear@25
|
46 level_file = argv[i];
|
nuclear@18
|
47 }
|
nuclear@18
|
48 }
|
nuclear@18
|
49 return true;
|
nuclear@18
|
50 }
|