19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Simple program:  Create a blank window, wait for keypress, quit.
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   Please see the SDL documentation for details on using the SDL API:
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   /Developer/Documentation/SDL/docs.html
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h>
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h>
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h>
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <math.h>
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL.h"
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint main(int argc, char *argv[])
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_Surface *screen;
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	Uint8  video_bpp = 0;
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	Uint32 videoflags = SDL_SWSURFACE;
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int    done;
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        SDL_Event event;
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Initialize the SDL library */
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if ( SDL_Init(initflags) < 0 ) {
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		fprintf(stderr, "Couldn't initialize SDL: %s\n",
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			SDL_GetError());
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		exit(1);
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Set 640x480 video mode */
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (screen == NULL) {
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                        video_bpp, SDL_GetError());
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		SDL_Quit();
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		exit(2);
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	done = 0;
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	while ( !done ) {
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		/* Check for events */
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		while ( SDL_PollEvent(&event) ) {
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			switch (event.type) {
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				case SDL_MOUSEMOTION:
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					break;
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				case SDL_MOUSEBUTTONDOWN:
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					break;
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				case SDL_KEYDOWN:
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					/* Any keypress quits the app... */
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				case SDL_QUIT:
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					done = 1;
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					break;
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				default:
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					break;
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Clean up the SDL library */
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_Quit();
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(0);
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
66