Mercurial > sdl-ios-xcode
annotate Xcode/TemplatesForXcode/SDL Application/main.c @ 2220:4d2d0548f5b2
Don't run indent on the Xcode templates
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 11 Aug 2007 18:51:12 +0000 |
parents | 59a667370c57 |
children |
rev | line source |
---|---|
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 /* Simple program: Create a blank window, wait for keypress, quit. |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 Please see the SDL documentation for details on using the SDL API: |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 /Developer/Documentation/SDL/docs.html |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 */ |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
7 |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 #include <string.h> |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 #include <math.h> |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 #include "SDL.h" |
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
15 int main(int argc, char *argv[]) |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 { |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
17 Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
18 SDL_Surface *screen; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
19 Uint8 video_bpp = 0; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
20 Uint32 videoflags = SDL_SWSURFACE; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
21 int done; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
22 SDL_Event event; |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
24 /* Initialize the SDL library */ |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
25 if ( SDL_Init(initflags) < 0 ) { |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
26 fprintf(stderr, "Couldn't initialize SDL: %s\n", |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
27 SDL_GetError()); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
28 exit(1); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
29 } |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
31 /* Set 640x480 video mode */ |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
32 screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
33 if (screen == NULL) { |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
34 fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
35 video_bpp, SDL_GetError()); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
36 SDL_Quit(); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
37 exit(2); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
38 } |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
40 done = 0; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
41 while ( !done ) { |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
43 /* Check for events */ |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
44 while ( SDL_PollEvent(&event) ) { |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
45 switch (event.type) { |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
2220
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
47 case SDL_MOUSEMOTION: |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
48 break; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
49 case SDL_MOUSEBUTTONDOWN: |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
50 break; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
51 case SDL_KEYDOWN: |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
52 /* Any keypress quits the app... */ |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
53 case SDL_QUIT: |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
54 done = 1; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
55 break; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
56 default: |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
57 break; |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
58 } |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
59 } |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
60 } |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
61 |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
62 /* Clean up the SDL library */ |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
63 SDL_Quit(); |
4d2d0548f5b2
Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents:
2213
diff
changeset
|
64 return(0); |
2207
d63e9f5944ae
Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 } |