Xcode/TemplatesForXcode/SDL Application/main.c
changeset 2220 4d2d0548f5b2
parent 2213 59a667370c57
     1.1 --- a/Xcode/TemplatesForXcode/SDL Application/main.c	Fri Aug 10 16:03:35 2007 +0000
     1.2 +++ b/Xcode/TemplatesForXcode/SDL Application/main.c	Sat Aug 11 18:51:12 2007 +0000
     1.3 @@ -4,7 +4,7 @@
     1.4     Please see the SDL documentation for details on using the SDL API:
     1.5     /Developer/Documentation/SDL/docs.html
     1.6  */
     1.7 -
     1.8 +   
     1.9  #include <stdio.h>
    1.10  #include <stdlib.h>
    1.11  #include <string.h>
    1.12 @@ -12,54 +12,54 @@
    1.13  
    1.14  #include "SDL.h"
    1.15  
    1.16 -int
    1.17 -main(int argc, char *argv[])
    1.18 +int main(int argc, char *argv[])
    1.19  {
    1.20 -    Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
    1.21 -    SDL_Surface *screen;
    1.22 -    Uint8 video_bpp = 0;
    1.23 -    Uint32 videoflags = SDL_SWSURFACE;
    1.24 -    int done;
    1.25 -    SDL_Event event;
    1.26 +	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
    1.27 +	SDL_Surface *screen;
    1.28 +	Uint8  video_bpp = 0;
    1.29 +	Uint32 videoflags = SDL_SWSURFACE;
    1.30 +	int    done;
    1.31 +        SDL_Event event;
    1.32  
    1.33 -    /* Initialize the SDL library */
    1.34 -    if (SDL_Init(initflags) < 0) {
    1.35 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.36 -        exit(1);
    1.37 -    }
    1.38 +	/* Initialize the SDL library */
    1.39 +	if ( SDL_Init(initflags) < 0 ) {
    1.40 +		fprintf(stderr, "Couldn't initialize SDL: %s\n",
    1.41 +			SDL_GetError());
    1.42 +		exit(1);
    1.43 +	}
    1.44  
    1.45 -    /* Set 640x480 video mode */
    1.46 -    screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
    1.47 -    if (screen == NULL) {
    1.48 -        fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    1.49 -                video_bpp, SDL_GetError());
    1.50 -        SDL_Quit();
    1.51 -        exit(2);
    1.52 -    }
    1.53 +	/* Set 640x480 video mode */
    1.54 +	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
    1.55 +        if (screen == NULL) {
    1.56 +		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    1.57 +                        video_bpp, SDL_GetError());
    1.58 +		SDL_Quit();
    1.59 +		exit(2);
    1.60 +	}
    1.61  
    1.62 -    done = 0;
    1.63 -    while (!done) {
    1.64 +	done = 0;
    1.65 +	while ( !done ) {
    1.66  
    1.67 -        /* Check for events */
    1.68 -        while (SDL_PollEvent(&event)) {
    1.69 -            switch (event.type) {
    1.70 +		/* Check for events */
    1.71 +		while ( SDL_PollEvent(&event) ) {
    1.72 +			switch (event.type) {
    1.73  
    1.74 -            case SDL_MOUSEMOTION:
    1.75 -                break;
    1.76 -            case SDL_MOUSEBUTTONDOWN:
    1.77 -                break;
    1.78 -            case SDL_KEYDOWN:
    1.79 -                /* Any keypress quits the app... */
    1.80 -            case SDL_QUIT:
    1.81 -                done = 1;
    1.82 -                break;
    1.83 -            default:
    1.84 -                break;
    1.85 -            }
    1.86 -        }
    1.87 -    }
    1.88 -
    1.89 -    /* Clean up the SDL library */
    1.90 -    SDL_Quit();
    1.91 -    return (0);
    1.92 +				case SDL_MOUSEMOTION:
    1.93 +					break;
    1.94 +				case SDL_MOUSEBUTTONDOWN:
    1.95 +					break;
    1.96 +				case SDL_KEYDOWN:
    1.97 +					/* Any keypress quits the app... */
    1.98 +				case SDL_QUIT:
    1.99 +					done = 1;
   1.100 +					break;
   1.101 +				default:
   1.102 +					break;
   1.103 +			}
   1.104 +		}
   1.105 +	}
   1.106 +	
   1.107 +	/* Clean up the SDL library */
   1.108 +	SDL_Quit();
   1.109 +	return(0);
   1.110  }