comparison test/testwm.c @ 87:3ef4bc90c388

Added -width and -height command line options
author Sam Lantinga <slouken@lokigames.com>
date Sat, 07 Jul 2001 06:33:33 +0000
parents 74212992fb08
children 9c9598e4b904
comparison
equal deleted inserted replaced
86:13e4c612098d 87:3ef4bc90c388
252 SDL_Event event; 252 SDL_Event event;
253 char *title; 253 char *title;
254 SDL_Surface *icon; 254 SDL_Surface *icon;
255 Uint8 *icon_mask; 255 Uint8 *icon_mask;
256 int parsed; 256 int parsed;
257 int w, h;
257 258
258 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { 259 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
259 fprintf(stderr, 260 fprintf(stderr,
260 "Couldn't initialize SDL: %s\n", SDL_GetError()); 261 "Couldn't initialize SDL: %s\n", SDL_GetError());
261 exit(1); 262 exit(1);
262 } 263 }
263 atexit(SDL_Quit); 264 atexit(SDL_Quit);
264 265
265 /* Check command line arguments */ 266 /* Check command line arguments */
267 w = 640;
268 h = 480;
266 video_bpp = 8; 269 video_bpp = 8;
267 video_flags = SDL_SWSURFACE; 270 video_flags = SDL_SWSURFACE;
268 parsed = 1; 271 parsed = 1;
269 while ( parsed ) { 272 while ( parsed ) {
270 if ( (argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0) ) { 273 if ( (argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0) ) {
280 if ( (argc >= 2) && (strcmp(argv[1], "-noframe") == 0) ) { 283 if ( (argc >= 2) && (strcmp(argv[1], "-noframe") == 0) ) {
281 video_flags |= SDL_NOFRAME; 284 video_flags |= SDL_NOFRAME;
282 argc -= 1; 285 argc -= 1;
283 argv += 1; 286 argv += 1;
284 } else 287 } else
288 if ( (argc >= 3) && (strcmp(argv[1], "-width") == 0) ) {
289 w = atoi(argv[2]);
290 argc -= 2;
291 argv += 2;
292 } else
293 if ( (argc >= 3) && (strcmp(argv[1], "-height") == 0) ) {
294 h = atoi(argv[2]);
295 argc -= 2;
296 argv += 2;
297 } else
285 if ( (argc >= 3) && (strcmp(argv[1], "-bpp") == 0) ) { 298 if ( (argc >= 3) && (strcmp(argv[1], "-bpp") == 0) ) {
286 video_bpp = atoi(argv[2]); 299 video_bpp = atoi(argv[2]);
287 argc -= 2; 300 argc -= 2;
288 argv += 2; 301 argv += 2;
289 } else { 302 } else {
312 printf("Title was set to: %s\n", title); 325 printf("Title was set to: %s\n", title);
313 else 326 else
314 printf("No window title was set!\n"); 327 printf("No window title was set!\n");
315 328
316 /* Initialize the display */ 329 /* Initialize the display */
317 if ( SetVideoMode(640, 480) < 0 ) { 330 if ( SetVideoMode(w, h) < 0 ) {
318 return(1); 331 return(1);
319 } 332 }
320 333
321 /* Set an event filter that discards everything but QUIT */ 334 /* Set an event filter that discards everything but QUIT */
322 SDL_SetEventFilter(FilterEvents); 335 SDL_SetEventFilter(FilterEvents);