mac: get the launcher building with SDL2

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-03-25 16:13:50 +10:30
parent 861ff0362f
commit 94121600ea
2 changed files with 24 additions and 39 deletions

View File

@ -43,11 +43,8 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
}
- (id)init {
int i,j;
int flags;
int bpps[3] = {32, 24, 16};
SDL_PixelFormat format;
SDL_Rect **modes;
int i, nummodes, err;
SDL_DisplayMode mode;
ScreenInfo *info;
self = [super init];
@ -60,23 +57,15 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
return self;
flags = SDL_OPENGL | SDL_FULLSCREEN;
format.palette = NULL;
for (i = 0; i < 3; i++) {
format.BitsPerPixel = bpps[i];
modes = SDL_ListModes(&format, flags);
if (modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
nummodes = SDL_GetNumDisplayModes(0);
for (i = 0; i < nummodes; i++) {
err = SDL_GetDisplayMode(0, i, &mode);
if (err)
continue;
for (j = 0; modes[j]; j++) {
info = [[ScreenInfo alloc] initWithWidth:modes[j]->w height:modes[j]->h bpp:bpps[i]];
info = [[ScreenInfo alloc] initWithWidth:mode.w height:mode.h bpp:SDL_BITSPERPIXEL(mode.format)];
[screenModes addObject:info];
[info release];
}
}
SDL_QuitSubSystem(SDL_INIT_VIDEO);
arguments = [[QuakeArguments alloc] initWithArguments:gArgv + 1 count:gArgc - 1];
@ -125,7 +114,6 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
int index = [screenModePopUp indexOfSelectedItem];
if (index > 0) {
ScreenInfo *info = [screenModes objectAtIndex:index];
int width = [info width];
int height = [info height];
int bpp = [info bpp];
@ -167,7 +155,7 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
[defaults setObject:[NSNumber numberWithInt:index] forKey:FQPrefScreenModeKey];
[defaults synchronize];
int status = SDL_main (argc, argv);
int status = SDL_main(argc, argv);
exit(status);
}
@ -180,5 +168,4 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
[super dealloc];
}
@end

View File

@ -13,7 +13,6 @@
#import "SDLMain.h"
#import <sys/param.h> /* for MAXPATHLEN */
#import <unistd.h>
#import "SDLApplication.h"
int gArgc;
char **gArgv;
@ -57,13 +56,12 @@ BOOL gCalledAppMainline = FALSE;
}
@end
#ifdef main
# undef main
#endif
/* Main entry point to executable - should *not* be SDL_main! */
int main (int argc, char **argv)
int main(int argc, char **argv)
{
/* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */
@ -72,7 +70,7 @@ int main (int argc, char **argv)
gArgv[0] = argv[0];
gArgv[1] = NULL;
gArgc = 1;
gFinderLaunch = YES;
gFinderLaunch = TRUE;
} else {
int i;
gArgc = argc;
@ -82,6 +80,6 @@ int main (int argc, char **argv)
gFinderLaunch = NO;
}
NSApplicationMain (argc, (const char**) argv);
NSApplicationMain(argc, (const char**)argv);
return 0;
}