Xcode/TemplatesForXcodeLeopard/SDL Application/main.c
branchSDL-1.2
changeset 5895 402eac854030
child 7191 75360622e65f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Xcode/TemplatesForXcodeLeopard/SDL Application/main.c	Sun Sep 11 14:44:37 2011 -0400
     1.3 @@ -0,0 +1,65 @@
     1.4 +
     1.5 +/* Simple program:  Create a blank window, wait for keypress, quit.
     1.6 +
     1.7 +   Please see the SDL documentation for details on using the SDL API:
     1.8 +   /Developer/Documentation/SDL/docs.html
     1.9 +*/
    1.10 +   
    1.11 +#include <stdio.h>
    1.12 +#include <stdlib.h>
    1.13 +#include <string.h>
    1.14 +#include <math.h>
    1.15 +
    1.16 +#include "SDL.h"
    1.17 +
    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 +
    1.27 +	/* Initialize the SDL library */
    1.28 +	if ( SDL_Init(initflags) < 0 ) {
    1.29 +		fprintf(stderr, "Couldn't initialize SDL: %s\n",
    1.30 +			SDL_GetError());
    1.31 +		exit(1);
    1.32 +	}
    1.33 +
    1.34 +	/* Set 640x480 video mode */
    1.35 +	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
    1.36 +        if (screen == NULL) {
    1.37 +		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    1.38 +                        video_bpp, SDL_GetError());
    1.39 +		SDL_Quit();
    1.40 +		exit(2);
    1.41 +	}
    1.42 +
    1.43 +	done = 0;
    1.44 +	while ( !done ) {
    1.45 +
    1.46 +		/* Check for events */
    1.47 +		while ( SDL_PollEvent(&event) ) {
    1.48 +			switch (event.type) {
    1.49 +
    1.50 +				case SDL_MOUSEMOTION:
    1.51 +					break;
    1.52 +				case SDL_MOUSEBUTTONDOWN:
    1.53 +					break;
    1.54 +				case SDL_KEYDOWN:
    1.55 +					/* Any keypress quits the app... */
    1.56 +				case SDL_QUIT:
    1.57 +					done = 1;
    1.58 +					break;
    1.59 +				default:
    1.60 +					break;
    1.61 +			}
    1.62 +		}
    1.63 +	}
    1.64 +	
    1.65 +	/* Clean up the SDL library */
    1.66 +	SDL_Quit();
    1.67 +	return(0);
    1.68 +}