Xcode/TemplatesForXcodeLeopard/SDL Cocoa Application/main.c
author Sam Lantinga
Tue, 08 Feb 2011 16:50:51 -0800
changeset 5229 c015d3e63631
parent 3331 d44a0a913aa2
child 7191 75360622e65f
permissions -rw-r--r--
Fixed setting the texture unit, still doesn't work.
slouken@3331
     1
slouken@3331
     2
/* Simple program:  Create a blank window, wait for keypress, quit.
slouken@3331
     3
slouken@3331
     4
   Please see the SDL documentation for details on using the SDL API:
slouken@3331
     5
   /Developer/Documentation/SDL/docs.html
slouken@3331
     6
*/
slouken@3331
     7
   
slouken@3331
     8
#include <stdio.h>
slouken@3331
     9
#include <stdlib.h>
slouken@3331
    10
#include <string.h>
slouken@3331
    11
#include <math.h>
slouken@3331
    12
slouken@3331
    13
#include "SDL.h"
slouken@3331
    14
slouken@3331
    15
int main(int argc, char *argv[])
slouken@3331
    16
{
slouken@3331
    17
	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
slouken@3331
    18
	SDL_Surface *screen;
slouken@3331
    19
	Uint8  video_bpp = 0;
slouken@3331
    20
	Uint32 videoflags = SDL_SWSURFACE;
slouken@3331
    21
	int    done;
slouken@3331
    22
        SDL_Event event;
slouken@3331
    23
slouken@3331
    24
	/* Initialize the SDL library */
slouken@3331
    25
	if ( SDL_Init(initflags) < 0 ) {
slouken@3331
    26
		fprintf(stderr, "Couldn't initialize SDL: %s\n",
slouken@3331
    27
			SDL_GetError());
slouken@3331
    28
		exit(1);
slouken@3331
    29
	}
slouken@3331
    30
slouken@3331
    31
	/* Set 640x480 video mode */
slouken@3331
    32
	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
slouken@3331
    33
        if (screen == NULL) {
slouken@3331
    34
		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
slouken@3331
    35
                        video_bpp, SDL_GetError());
slouken@3331
    36
		SDL_Quit();
slouken@3331
    37
		exit(2);
slouken@3331
    38
	}
slouken@3331
    39
slouken@3331
    40
	done = 0;
slouken@3331
    41
	while ( !done ) {
slouken@3331
    42
slouken@3331
    43
		/* Check for events */
slouken@3331
    44
		while ( SDL_PollEvent(&event) ) {
slouken@3331
    45
			switch (event.type) {
slouken@3331
    46
slouken@3331
    47
				case SDL_MOUSEMOTION:
slouken@3331
    48
					break;
slouken@3331
    49
				case SDL_MOUSEBUTTONDOWN:
slouken@3331
    50
					break;
slouken@3331
    51
				case SDL_KEYDOWN:
slouken@3331
    52
					/* Any keypress quits the app... */
slouken@3331
    53
				case SDL_QUIT:
slouken@3331
    54
					done = 1;
slouken@3331
    55
					break;
slouken@3331
    56
				default:
slouken@3331
    57
					break;
slouken@3331
    58
			}
slouken@3331
    59
		}
slouken@3331
    60
	}
slouken@3331
    61
	
slouken@3331
    62
	/* Clean up the SDL library */
slouken@3331
    63
	SDL_Quit();
slouken@3331
    64
	return(0);
slouken@3331
    65
}