-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSDLMain.m
71 lines (52 loc) · 1.52 KB
/
SDLMain.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <[email protected]>
Non-NIB-Code & other changes: Max Horn <[email protected]>
Feel free to customize this file to suit your needs
*/
#import "SDL.h"
#import "SDLMain.h"
#import <sys/param.h> /* for MAXPATHLEN */
#import <unistd.h>
/* Use NIB Code */
static int gArgc;
static char **gArgv;
@interface SDLApplication : NSApplication
@end
@implementation SDLApplication
/* Invoked from the Quit menu item */
- (void)terminate:(id)sender
{
fprintf(stderr, "terminate\n");
/* Post a SDL_QUIT event */
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
@end
/* The main class of the application, the application's delegate */
@implementation SDLMain
/* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
int status;
fprintf(stderr, "applicationDidFinishLaunching\n");
/* Hand off to main application code */
status = SDL_main (gArgc, gArgv);
/* We're done, thank you for playing */
exit(status);
}
@end
#ifdef main
# undef main
#endif
/* Main entry point to executable - should *not* be SDL_main! */
int main (int argc, const char *argv[])
{
fprintf(stderr, "main\n");
/* Copy the arguments into a global variable */
gArgc = argc;
gArgv = (char **) argv;
[SDLApplication poseAsClass:[NSApplication class]];
NSApplicationMain (argc, argv);
return 0;
}