comparison gldragon.cpp @ 67:1327ef5dc9fb

Remove -w and -h options and replace them with -s <width>x<height>.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 15 Dec 2019 23:16:29 +0200
parents e8100c1c5d99
children 267b3fd2c98c
comparison
equal deleted inserted replaced
66:1d24faa5bfb9 67:1327ef5dc9fb
132 { 132 {
133 case 'g': 133 case 'g':
134 optUseShaders = true; 134 optUseShaders = true;
135 break; 135 break;
136 136
137 case 'w': 137 case 's':
138 case 'h':
139 case 'm': 138 case 'm':
140 case 'v': 139 case 'v':
141 if (opt[1] == 0)
142 { 140 {
143 printf("Option '%s' requires an argument.\n", opt); 141 std::string marg;
144 goto exit; 142 if (opt[1] == 0)
145 } 143 {
146 144 if (narg < argc)
147 switch (opt[0]) 145 marg = std::string(argv[++narg]);
148 { 146 else
149 case 'w': optWidth = atoi(opt + 1); break; 147 {
150 case 'h': optHeight = atoi(opt + 1); break; 148 printf("Option '%s' requires an argument.\n", opt);
151 case 'v': optVSyncMode = atoi(opt + 1); break; 149 goto exit;
150 }
151 }
152 else
153 marg = std::string(opt + 1);
154
155 switch (opt[0])
156 {
157 case 's':
158 {
159 std::vector<std::string> mtokens = dmStrSplit(marg, "xX:");
160 if (mtokens.size() != 2)
161 {
162 printf("Option expects argument of format <width>x<height> in pixels.\n"
163 "For example: -s 640x480\n");
164 goto exit;
165 }
166
167 optWidth = std::stoi(mtokens[0], 0, 0);
168 optHeight = std::stoi(mtokens[1], 0, 0);
169 }
170 break;
171
172 case 'v': optVSyncMode = std::stoi(marg, 0, 0); break;
173 }
152 } 174 }
153 break; 175 break;
154 176
155 default: 177 default:
156 printf("Unknown option '%s'.\n", arg); 178 printf("Unknown option '%s'.\n", arg);
180 { 202 {
181 printf( 203 printf(
182 "Usage: %s [options] [<scenefile.scene>]\n" 204 "Usage: %s [options] [<scenefile.scene>]\n"
183 "-? Show this help\n" 205 "-? Show this help\n"
184 "-g Use GLSL shader instead of basic OpenGL lighting\n" 206 "-g Use GLSL shader instead of basic OpenGL lighting\n"
185 "-w<width> Window width (default %d)\n" 207 "-s<w>x<h> Set window dimensions (default %d x %d)\n"
186 "-h<height> Window height (default %d)\n"
187 "-v<0-3> Set vsync mode: 0 = do not attempt to set vsync mode\n" 208 "-v<0-3> Set vsync mode: 0 = do not attempt to set vsync mode\n"
188 " (may be required for software rendering backends),\n" 209 " (may be required for software rendering backends),\n"
189 " 1 = no vsync, 2 = vsync, 3 = adaptive.\n" 210 " 1 = no vsync, 2 = vsync, 3 = adaptive.\n"
190 " Using vsync (2) will result in FPS being approximately\n" 211 " Using vsync (2) will result in FPS being approximately\n"
191 " whatever your monitor refresh rate is. The default\n" 212 " whatever your monitor refresh rate is. The default\n"