Backed out use of @autorelease keyword for now, since it's not supported by older Xcode versions.
This commit is contained in:
parent
e2aa9f0afb
commit
d36265107b
11 changed files with 773 additions and 702 deletions
|
@ -20,22 +20,25 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
|
||||||
return fopen(file, mode);
|
return fopen(file, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
|
||||||
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
|
||||||
|
|
||||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
|
||||||
|
|
||||||
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
|
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||||
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
|
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
||||||
{
|
|
||||||
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||||
}
|
|
||||||
else
|
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
|
||||||
{
|
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
|
||||||
fp = fopen(file, mode);
|
{
|
||||||
}
|
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fp = fopen(file, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[autorelease_pool drain];
|
||||||
|
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,46 +45,51 @@ int
|
||||||
Cocoa_SetClipboardText(_THIS, const char *text)
|
Cocoa_SetClipboardText(_THIS, const char *text)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSPasteboard *pasteboard;
|
NSPasteboard *pasteboard;
|
||||||
NSString *format = GetTextFormat(_this);
|
NSString *format = GetTextFormat(_this);
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
pasteboard = [NSPasteboard generalPasteboard];
|
|
||||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
pasteboard = [NSPasteboard generalPasteboard];
|
||||||
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
|
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||||
}
|
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
Cocoa_GetClipboardText(_THIS)
|
Cocoa_GetClipboardText(_THIS)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSPasteboard *pasteboard;
|
NSPasteboard *pasteboard;
|
||||||
NSString *format = GetTextFormat(_this);
|
NSString *format = GetTextFormat(_this);
|
||||||
NSString *available;
|
NSString *available;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
pasteboard = [NSPasteboard generalPasteboard];
|
|
||||||
available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
|
|
||||||
if ([available isEqualToString:format]) {
|
|
||||||
NSString* string;
|
|
||||||
const char *utf8;
|
|
||||||
|
|
||||||
string = [pasteboard stringForType:format];
|
pasteboard = [NSPasteboard generalPasteboard];
|
||||||
if (string == nil) {
|
available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
|
||||||
utf8 = "";
|
if ([available isEqualToString:format]) {
|
||||||
} else {
|
NSString* string;
|
||||||
utf8 = [string UTF8String];
|
const char *utf8;
|
||||||
}
|
|
||||||
text = SDL_strdup(utf8);
|
string = [pasteboard stringForType:format];
|
||||||
|
if (string == nil) {
|
||||||
|
utf8 = "";
|
||||||
} else {
|
} else {
|
||||||
text = SDL_strdup("");
|
utf8 = [string UTF8String];
|
||||||
}
|
}
|
||||||
|
text = SDL_strdup(utf8);
|
||||||
|
} else {
|
||||||
|
text = SDL_strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,19 +108,22 @@ Cocoa_HasClipboardText(_THIS)
|
||||||
void
|
void
|
||||||
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSPasteboard *pasteboard;
|
NSPasteboard *pasteboard;
|
||||||
NSInteger count;
|
NSInteger count;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
pasteboard = [NSPasteboard generalPasteboard];
|
|
||||||
count = [pasteboard changeCount];
|
pasteboard = [NSPasteboard generalPasteboard];
|
||||||
if (count != data->clipboard_count) {
|
count = [pasteboard changeCount];
|
||||||
if (data->clipboard_count) {
|
if (count != data->clipboard_count) {
|
||||||
SDL_SendClipboardUpdate();
|
if (data->clipboard_count) {
|
||||||
}
|
SDL_SendClipboardUpdate();
|
||||||
data->clipboard_count = count;
|
|
||||||
}
|
}
|
||||||
|
data->clipboard_count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||||
|
|
|
@ -159,30 +159,33 @@ Cocoa_RegisterApp(void)
|
||||||
{
|
{
|
||||||
/* This can get called more than once! Be careful what you initialize! */
|
/* This can get called more than once! Be careful what you initialize! */
|
||||||
ProcessSerialNumber psn;
|
ProcessSerialNumber psn;
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
|
|
||||||
if (!GetCurrentProcess(&psn)) {
|
if (!GetCurrentProcess(&psn)) {
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
SetFrontProcess(&psn);
|
SetFrontProcess(&psn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
if (NSApp == nil) {
|
if (NSApp == nil) {
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
|
|
||||||
if ([NSApp mainMenu] == nil) {
|
if ([NSApp mainMenu] == nil) {
|
||||||
CreateApplicationMenus();
|
CreateApplicationMenus();
|
||||||
}
|
|
||||||
[NSApp finishLaunching];
|
|
||||||
}
|
|
||||||
if ([NSApp delegate] == nil) {
|
|
||||||
[NSApp setDelegate:[[SDLAppDelegate alloc] init]];
|
|
||||||
}
|
}
|
||||||
|
[NSApp finishLaunching];
|
||||||
}
|
}
|
||||||
|
if ([NSApp delegate] == nil) {
|
||||||
|
[NSApp setDelegate:[[SDLAppDelegate alloc] init]];
|
||||||
|
}
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_PumpEvents(_THIS)
|
Cocoa_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
|
|
||||||
/* Update activity every 30 seconds to prevent screensaver */
|
/* Update activity every 30 seconds to prevent screensaver */
|
||||||
if (_this->suspend_screensaver) {
|
if (_this->suspend_screensaver) {
|
||||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||||
|
@ -194,39 +197,39 @@ Cocoa_PumpEvents(_THIS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
|
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||||
if ( event == nil ) {
|
if ( event == nil ) {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
switch ([event type]) {
|
|
||||||
case NSLeftMouseDown:
|
|
||||||
case NSOtherMouseDown:
|
|
||||||
case NSRightMouseDown:
|
|
||||||
case NSLeftMouseUp:
|
|
||||||
case NSOtherMouseUp:
|
|
||||||
case NSRightMouseUp:
|
|
||||||
case NSLeftMouseDragged:
|
|
||||||
case NSRightMouseDragged:
|
|
||||||
case NSOtherMouseDragged: /* usually middle mouse dragged */
|
|
||||||
case NSMouseMoved:
|
|
||||||
case NSScrollWheel:
|
|
||||||
Cocoa_HandleMouseEvent(_this, event);
|
|
||||||
break;
|
|
||||||
case NSKeyDown:
|
|
||||||
case NSKeyUp:
|
|
||||||
case NSFlagsChanged:
|
|
||||||
Cocoa_HandleKeyEvent(_this, event);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Pass through to NSApp to make sure everything stays in sync */
|
|
||||||
[NSApp sendEvent:event];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ([event type]) {
|
||||||
|
case NSLeftMouseDown:
|
||||||
|
case NSOtherMouseDown:
|
||||||
|
case NSRightMouseDown:
|
||||||
|
case NSLeftMouseUp:
|
||||||
|
case NSOtherMouseUp:
|
||||||
|
case NSRightMouseUp:
|
||||||
|
case NSLeftMouseDragged:
|
||||||
|
case NSRightMouseDragged:
|
||||||
|
case NSOtherMouseDragged: /* usually middle mouse dragged */
|
||||||
|
case NSMouseMoved:
|
||||||
|
case NSScrollWheel:
|
||||||
|
Cocoa_HandleMouseEvent(_this, event);
|
||||||
|
break;
|
||||||
|
case NSKeyDown:
|
||||||
|
case NSKeyUp:
|
||||||
|
case NSFlagsChanged:
|
||||||
|
Cocoa_HandleKeyEvent(_this, event);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Pass through to NSApp to make sure everything stays in sync */
|
||||||
|
[NSApp sendEvent:event];
|
||||||
}
|
}
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||||
|
|
|
@ -625,27 +625,28 @@ void
|
||||||
Cocoa_StartTextInput(_THIS)
|
Cocoa_StartTextInput(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSView *parentView = [[NSApp keyWindow] contentView];
|
NSView *parentView = [[NSApp keyWindow] contentView];
|
||||||
|
|
||||||
/* We only keep one field editor per process, since only the front most
|
/* We only keep one field editor per process, since only the front most
|
||||||
* window can receive text input events, so it make no sense to keep more
|
* window can receive text input events, so it make no sense to keep more
|
||||||
* than one copy. When we switched to another window and requesting for
|
* than one copy. When we switched to another window and requesting for
|
||||||
* text input, simply remove the field editor from its superview then add
|
* text input, simply remove the field editor from its superview then add
|
||||||
* it to the front most window's content view */
|
* it to the front most window's content view */
|
||||||
if (!data->fieldEdit) {
|
if (!data->fieldEdit) {
|
||||||
data->fieldEdit =
|
data->fieldEdit =
|
||||||
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||||
}
|
|
||||||
|
|
||||||
if (![[data->fieldEdit superview] isEqual: parentView])
|
|
||||||
{
|
|
||||||
// DEBUG_IME(@"add fieldEdit to window contentView");
|
|
||||||
[data->fieldEdit removeFromSuperview];
|
|
||||||
[parentView addSubview: data->fieldEdit];
|
|
||||||
[[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (![[data->fieldEdit superview] isEqual: parentView])
|
||||||
|
{
|
||||||
|
// DEBUG_IME(@"add fieldEdit to window contentView");
|
||||||
|
[data->fieldEdit removeFromSuperview];
|
||||||
|
[parentView addSubview: data->fieldEdit];
|
||||||
|
[[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
|
||||||
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -654,11 +655,11 @@ Cocoa_StopTextInput(_THIS)
|
||||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||||
|
|
||||||
if (data && data->fieldEdit) {
|
if (data && data->fieldEdit) {
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
[data->fieldEdit removeFromSuperview];
|
[data->fieldEdit removeFromSuperview];
|
||||||
[data->fieldEdit release];
|
[data->fieldEdit release];
|
||||||
data->fieldEdit = nil;
|
data->fieldEdit = nil;
|
||||||
}
|
[pool release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,39 +39,41 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
{
|
{
|
||||||
Cocoa_RegisterApp();
|
Cocoa_RegisterApp();
|
||||||
|
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSAlert* alert = [[NSAlert alloc] init];
|
|
||||||
|
|
||||||
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
NSAlert* alert = [[NSAlert alloc] init];
|
||||||
[alert setAlertStyle:NSCriticalAlertStyle];
|
|
||||||
} else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
|
|
||||||
[alert setAlertStyle:NSWarningAlertStyle];
|
|
||||||
} else {
|
|
||||||
[alert setAlertStyle:NSInformationalAlertStyle];
|
|
||||||
}
|
|
||||||
|
|
||||||
[alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
|
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
||||||
[alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
|
[alert setAlertStyle:NSCriticalAlertStyle];
|
||||||
|
} else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
|
||||||
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
|
[alert setAlertStyle:NSWarningAlertStyle];
|
||||||
int i;
|
} else {
|
||||||
for (i = 0; i < messageboxdata->numbuttons; ++i) {
|
[alert setAlertStyle:NSInformationalAlertStyle];
|
||||||
NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
|
|
||||||
if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
|
||||||
[button setKeyEquivalent:@"\r"];
|
|
||||||
} else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
|
||||||
[button setKeyEquivalent:@"\033"];
|
|
||||||
} else {
|
|
||||||
[button setKeyEquivalent:@""];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NSInteger clicked = [alert runModal];
|
|
||||||
clicked -= NSAlertFirstButtonReturn;
|
|
||||||
*buttonid = buttons[clicked].buttonid;
|
|
||||||
[alert release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
|
||||||
|
[alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
|
||||||
|
|
||||||
|
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < messageboxdata->numbuttons; ++i) {
|
||||||
|
NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
|
||||||
|
if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||||
|
[button setKeyEquivalent:@"\r"];
|
||||||
|
} else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
||||||
|
[button setKeyEquivalent:@"\033"];
|
||||||
|
} else {
|
||||||
|
[button setKeyEquivalent:@""];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSInteger clicked = [alert runModal];
|
||||||
|
clicked -= NSAlertFirstButtonReturn;
|
||||||
|
*buttonid = buttons[clicked].buttonid;
|
||||||
|
[alert release];
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,134 +32,140 @@
|
||||||
static SDL_Cursor *
|
static SDL_Cursor *
|
||||||
Cocoa_CreateDefaultCursor()
|
Cocoa_CreateDefaultCursor()
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSCursor *nscursor;
|
NSCursor *nscursor;
|
||||||
SDL_Cursor *cursor = NULL;
|
SDL_Cursor *cursor = NULL;
|
||||||
|
|
||||||
nscursor = [NSCursor arrowCursor];
|
nscursor = [NSCursor arrowCursor];
|
||||||
|
|
||||||
if (nscursor) {
|
if (nscursor) {
|
||||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
cursor->driverdata = nscursor;
|
cursor->driverdata = nscursor;
|
||||||
[nscursor retain];
|
[nscursor retain];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_Cursor *
|
static SDL_Cursor *
|
||||||
Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSImage *nsimage;
|
NSImage *nsimage;
|
||||||
NSCursor *nscursor = NULL;
|
NSCursor *nscursor = NULL;
|
||||||
SDL_Cursor *cursor = NULL;
|
SDL_Cursor *cursor = NULL;
|
||||||
|
|
||||||
nsimage = Cocoa_CreateImage(surface);
|
nsimage = Cocoa_CreateImage(surface);
|
||||||
if (nsimage) {
|
if (nsimage) {
|
||||||
nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)];
|
nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)];
|
||||||
}
|
|
||||||
|
|
||||||
if (nscursor) {
|
|
||||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
|
||||||
if (cursor) {
|
|
||||||
cursor->driverdata = nscursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nscursor) {
|
||||||
|
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||||
|
if (cursor) {
|
||||||
|
cursor->driverdata = nscursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_Cursor *
|
static SDL_Cursor *
|
||||||
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSCursor *nscursor = NULL;
|
NSCursor *nscursor = NULL;
|
||||||
SDL_Cursor *cursor = NULL;
|
SDL_Cursor *cursor = NULL;
|
||||||
|
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
case SDL_SYSTEM_CURSOR_ARROW:
|
case SDL_SYSTEM_CURSOR_ARROW:
|
||||||
nscursor = [NSCursor arrowCursor];
|
nscursor = [NSCursor arrowCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_IBEAM:
|
case SDL_SYSTEM_CURSOR_IBEAM:
|
||||||
nscursor = [NSCursor IBeamCursor];
|
nscursor = [NSCursor IBeamCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_WAIT:
|
case SDL_SYSTEM_CURSOR_WAIT:
|
||||||
nscursor = [NSCursor arrowCursor];
|
nscursor = [NSCursor arrowCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
||||||
nscursor = [NSCursor crosshairCursor];
|
nscursor = [NSCursor crosshairCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_WAITARROW:
|
case SDL_SYSTEM_CURSOR_WAITARROW:
|
||||||
nscursor = [NSCursor arrowCursor];
|
nscursor = [NSCursor arrowCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
||||||
case SDL_SYSTEM_CURSOR_SIZENESW:
|
case SDL_SYSTEM_CURSOR_SIZENESW:
|
||||||
nscursor = [NSCursor closedHandCursor];
|
nscursor = [NSCursor closedHandCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_SIZEWE:
|
case SDL_SYSTEM_CURSOR_SIZEWE:
|
||||||
nscursor = [NSCursor resizeLeftRightCursor];
|
nscursor = [NSCursor resizeLeftRightCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_SIZENS:
|
case SDL_SYSTEM_CURSOR_SIZENS:
|
||||||
nscursor = [NSCursor resizeUpDownCursor];
|
nscursor = [NSCursor resizeUpDownCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_SIZEALL:
|
case SDL_SYSTEM_CURSOR_SIZEALL:
|
||||||
nscursor = [NSCursor closedHandCursor];
|
nscursor = [NSCursor closedHandCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_NO:
|
case SDL_SYSTEM_CURSOR_NO:
|
||||||
nscursor = [NSCursor operationNotAllowedCursor];
|
nscursor = [NSCursor operationNotAllowedCursor];
|
||||||
break;
|
break;
|
||||||
case SDL_SYSTEM_CURSOR_HAND:
|
case SDL_SYSTEM_CURSOR_HAND:
|
||||||
nscursor = [NSCursor pointingHandCursor];
|
nscursor = [NSCursor pointingHandCursor];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_assert(!"Unknown system cursor");
|
SDL_assert(!"Unknown system cursor");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (nscursor) {
|
|
||||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
|
||||||
if (cursor) {
|
|
||||||
// We'll free it later, so retain it here
|
|
||||||
[nscursor retain];
|
|
||||||
cursor->driverdata = nscursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nscursor) {
|
||||||
|
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||||
|
if (cursor) {
|
||||||
|
// We'll free it later, so retain it here
|
||||||
|
[nscursor retain];
|
||||||
|
cursor->driverdata = nscursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Cocoa_FreeCursor(SDL_Cursor * cursor)
|
Cocoa_FreeCursor(SDL_Cursor * cursor)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||||
|
|
||||||
[nscursor release];
|
[nscursor release];
|
||||||
SDL_free(cursor);
|
SDL_free(cursor);
|
||||||
}
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
Cocoa_ShowCursor(SDL_Cursor * cursor)
|
Cocoa_ShowCursor(SDL_Cursor * cursor)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
if (cursor) {
|
|
||||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
|
||||||
|
|
||||||
[nscursor set];
|
if (cursor) {
|
||||||
[NSCursor unhide];
|
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||||
} else {
|
|
||||||
[NSCursor hide];
|
[nscursor set];
|
||||||
}
|
[NSCursor unhide];
|
||||||
|
} else {
|
||||||
|
[NSCursor hide];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
const int wantver = (_this->gl_config.major_version << 8) |
|
const int wantver = (_this->gl_config.major_version << 8) |
|
||||||
(_this->gl_config.minor_version);
|
(_this->gl_config.minor_version);
|
||||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||||
NSOpenGLPixelFormatAttribute attr[32];
|
NSOpenGLPixelFormatAttribute attr[32];
|
||||||
|
@ -99,116 +100,121 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
/* specify a profile if we're on Lion (10.7) or later. */
|
|
||||||
if (data->osversion >= 0x1070) {
|
|
||||||
NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy;
|
|
||||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
|
||||||
if (wantver == 0x0302) {
|
|
||||||
profile = kCGLOGLPVersion_3_2_Core;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
attr[i++] = kCGLPFAOpenGLProfile;
|
|
||||||
attr[i++] = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef FULLSCREEN_TOGGLEABLE
|
/* specify a profile if we're on Lion (10.7) or later. */
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if (data->osversion >= 0x1070) {
|
||||||
attr[i++] = NSOpenGLPFAFullScreen;
|
NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy;
|
||||||
}
|
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||||
#endif
|
if (wantver == 0x0302) {
|
||||||
|
profile = kCGLOGLPVersion_3_2_Core;
|
||||||
attr[i++] = NSOpenGLPFAColorSize;
|
|
||||||
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
|
|
||||||
|
|
||||||
attr[i++] = NSOpenGLPFADepthSize;
|
|
||||||
attr[i++] = _this->gl_config.depth_size;
|
|
||||||
|
|
||||||
if (_this->gl_config.double_buffer) {
|
|
||||||
attr[i++] = NSOpenGLPFADoubleBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_this->gl_config.stereo) {
|
|
||||||
attr[i++] = NSOpenGLPFAStereo;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_this->gl_config.stencil_size) {
|
|
||||||
attr[i++] = NSOpenGLPFAStencilSize;
|
|
||||||
attr[i++] = _this->gl_config.stencil_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((_this->gl_config.accum_red_size +
|
|
||||||
_this->gl_config.accum_green_size +
|
|
||||||
_this->gl_config.accum_blue_size +
|
|
||||||
_this->gl_config.accum_alpha_size) > 0) {
|
|
||||||
attr[i++] = NSOpenGLPFAAccumSize;
|
|
||||||
attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_this->gl_config.multisamplebuffers) {
|
|
||||||
attr[i++] = NSOpenGLPFASampleBuffers;
|
|
||||||
attr[i++] = _this->gl_config.multisamplebuffers;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_this->gl_config.multisamplesamples) {
|
|
||||||
attr[i++] = NSOpenGLPFASamples;
|
|
||||||
attr[i++] = _this->gl_config.multisamplesamples;
|
|
||||||
attr[i++] = NSOpenGLPFANoRecovery;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_this->gl_config.accelerated >= 0) {
|
|
||||||
if (_this->gl_config.accelerated) {
|
|
||||||
attr[i++] = NSOpenGLPFAAccelerated;
|
|
||||||
} else {
|
|
||||||
attr[i++] = NSOpenGLPFARendererID;
|
|
||||||
attr[i++] = kCGLRendererGenericFloatID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
attr[i++] = kCGLPFAOpenGLProfile;
|
||||||
|
attr[i++] = profile;
|
||||||
|
}
|
||||||
|
|
||||||
attr[i++] = NSOpenGLPFAScreenMask;
|
#ifndef FULLSCREEN_TOGGLEABLE
|
||||||
attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display);
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
attr[i] = 0;
|
attr[i++] = NSOpenGLPFAFullScreen;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
attr[i++] = NSOpenGLPFAColorSize;
|
||||||
if (fmt == nil) {
|
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
|
||||||
SDL_SetError ("Failed creating OpenGL pixel format");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
|
attr[i++] = NSOpenGLPFADepthSize;
|
||||||
|
attr[i++] = _this->gl_config.depth_size;
|
||||||
|
|
||||||
[fmt release];
|
if (_this->gl_config.double_buffer) {
|
||||||
|
attr[i++] = NSOpenGLPFADoubleBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
if (context == nil) {
|
if (_this->gl_config.stereo) {
|
||||||
SDL_SetError ("Failed creating OpenGL context");
|
attr[i++] = NSOpenGLPFAStereo;
|
||||||
return NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if (_this->gl_config.stencil_size) {
|
||||||
* Wisdom from Apple engineer in reference to UT2003's OpenGL performance:
|
attr[i++] = NSOpenGLPFAStencilSize;
|
||||||
* "You are blowing a couple of the internal OpenGL function caches. This
|
attr[i++] = _this->gl_config.stencil_size;
|
||||||
* appears to be happening in the VAO case. You can tell OpenGL to up
|
}
|
||||||
* the cache size by issuing the following calls right after you create
|
|
||||||
* the OpenGL context. The default cache size is 16." --ryan.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GLI_ARRAY_FUNC_CACHE_MAX
|
if ((_this->gl_config.accum_red_size +
|
||||||
#define GLI_ARRAY_FUNC_CACHE_MAX 284
|
_this->gl_config.accum_green_size +
|
||||||
#endif
|
_this->gl_config.accum_blue_size +
|
||||||
|
_this->gl_config.accum_alpha_size) > 0) {
|
||||||
|
attr[i++] = NSOpenGLPFAAccumSize;
|
||||||
|
attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef GLI_SUBMIT_FUNC_CACHE_MAX
|
if (_this->gl_config.multisamplebuffers) {
|
||||||
#define GLI_SUBMIT_FUNC_CACHE_MAX 280
|
attr[i++] = NSOpenGLPFASampleBuffers;
|
||||||
#endif
|
attr[i++] = _this->gl_config.multisamplebuffers;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
if (_this->gl_config.multisamplesamples) {
|
||||||
GLint cache_max = 64;
|
attr[i++] = NSOpenGLPFASamples;
|
||||||
CGLContextObj ctx = [context CGLContextObj];
|
attr[i++] = _this->gl_config.multisamplesamples;
|
||||||
CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
|
attr[i++] = NSOpenGLPFANoRecovery;
|
||||||
CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
|
}
|
||||||
|
|
||||||
|
if (_this->gl_config.accelerated >= 0) {
|
||||||
|
if (_this->gl_config.accelerated) {
|
||||||
|
attr[i++] = NSOpenGLPFAAccelerated;
|
||||||
|
} else {
|
||||||
|
attr[i++] = NSOpenGLPFARendererID;
|
||||||
|
attr[i++] = kCGLRendererGenericFloatID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attr[i++] = NSOpenGLPFAScreenMask;
|
||||||
|
attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display);
|
||||||
|
attr[i] = 0;
|
||||||
|
|
||||||
|
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
||||||
|
if (fmt == nil) {
|
||||||
|
SDL_SetError ("Failed creating OpenGL pixel format");
|
||||||
|
[pool release];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
|
||||||
|
|
||||||
|
[fmt release];
|
||||||
|
|
||||||
|
if (context == nil) {
|
||||||
|
SDL_SetError ("Failed creating OpenGL context");
|
||||||
|
[pool release];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wisdom from Apple engineer in reference to UT2003's OpenGL performance:
|
||||||
|
* "You are blowing a couple of the internal OpenGL function caches. This
|
||||||
|
* appears to be happening in the VAO case. You can tell OpenGL to up
|
||||||
|
* the cache size by issuing the following calls right after you create
|
||||||
|
* the OpenGL context. The default cache size is 16." --ryan.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GLI_ARRAY_FUNC_CACHE_MAX
|
||||||
|
#define GLI_ARRAY_FUNC_CACHE_MAX 284
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLI_SUBMIT_FUNC_CACHE_MAX
|
||||||
|
#define GLI_SUBMIT_FUNC_CACHE_MAX 280
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
GLint cache_max = 64;
|
||||||
|
CGLContextObj ctx = [context CGLContextObj];
|
||||||
|
CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
|
||||||
|
CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
|
||||||
|
}
|
||||||
|
|
||||||
/* End Wisdom from Apple Engineer section. --ryan. */
|
/* End Wisdom from Apple Engineer section. --ryan. */
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
|
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
|
||||||
Cocoa_GL_DeleteContext(_this, context);
|
Cocoa_GL_DeleteContext(_this, context);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -220,94 +226,107 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
int
|
int
|
||||||
Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool;
|
||||||
if (context) {
|
|
||||||
SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
|
|
||||||
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_SHOWN) {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
#ifndef FULLSCREEN_TOGGLEABLE
|
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if (context) {
|
||||||
[nscontext setFullScreen];
|
SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
|
||||||
} else
|
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
||||||
#endif
|
|
||||||
{
|
if (window->flags & SDL_WINDOW_SHOWN) {
|
||||||
[nscontext setView:[windowdata->nswindow contentView]];
|
#ifndef FULLSCREEN_TOGGLEABLE
|
||||||
[nscontext update];
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
}
|
[nscontext setFullScreen];
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
[nscontext setView:[windowdata->nswindow contentView]];
|
||||||
|
[nscontext update];
|
||||||
}
|
}
|
||||||
[nscontext makeCurrentContext];
|
|
||||||
} else {
|
|
||||||
[NSOpenGLContext clearCurrentContext];
|
|
||||||
}
|
}
|
||||||
|
[nscontext makeCurrentContext];
|
||||||
|
} else {
|
||||||
|
[NSOpenGLContext clearCurrentContext];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSOpenGLContext *nscontext;
|
NSOpenGLContext *nscontext;
|
||||||
GLint value;
|
GLint value;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
nscontext = [NSOpenGLContext currentContext];
|
|
||||||
if (nscontext != nil) {
|
nscontext = [NSOpenGLContext currentContext];
|
||||||
value = interval;
|
if (nscontext != nil) {
|
||||||
[nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
value = interval;
|
||||||
status = 0;
|
[nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||||
} else {
|
status = 0;
|
||||||
SDL_SetError("No current OpenGL context");
|
} else {
|
||||||
status = -1;
|
SDL_SetError("No current OpenGL context");
|
||||||
}
|
status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Cocoa_GL_GetSwapInterval(_THIS)
|
Cocoa_GL_GetSwapInterval(_THIS)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSOpenGLContext *nscontext;
|
NSOpenGLContext *nscontext;
|
||||||
GLint value;
|
GLint value;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
nscontext = [NSOpenGLContext currentContext];
|
|
||||||
if (nscontext != nil) {
|
nscontext = [NSOpenGLContext currentContext];
|
||||||
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
|
if (nscontext != nil) {
|
||||||
status = (int)value;
|
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||||
}
|
status = (int)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
|
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSOpenGLContext *nscontext;
|
NSOpenGLContext *nscontext;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
/* FIXME: Do we need to get the context for the window? */
|
|
||||||
nscontext = [NSOpenGLContext currentContext];
|
/* FIXME: Do we need to get the context for the window? */
|
||||||
if (nscontext != nil) {
|
nscontext = [NSOpenGLContext currentContext];
|
||||||
[nscontext flushBuffer];
|
if (nscontext != nil) {
|
||||||
}
|
[nscontext flushBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
|
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
[nscontext clearDrawable];
|
|
||||||
[nscontext release];
|
[nscontext clearDrawable];
|
||||||
}
|
[nscontext release];
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_OPENGL_CGL */
|
#endif /* SDL_VIDEO_OPENGL_CGL */
|
||||||
|
|
|
@ -74,7 +74,7 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
|
||||||
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
||||||
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
||||||
SDL_CocoaClosure closure;
|
SDL_CocoaClosure closure;
|
||||||
|
NSAutoreleasePool *pool = NULL;
|
||||||
if(data->saved == SDL_TRUE) {
|
if(data->saved == SDL_TRUE) {
|
||||||
[data->context restoreGraphicsState];
|
[data->context restoreGraphicsState];
|
||||||
data->saved = SDL_FALSE;
|
data->saved = SDL_FALSE;
|
||||||
|
@ -88,13 +88,12 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
|
||||||
NSRectFill([[windata->nswindow contentView] frame]);
|
NSRectFill([[windata->nswindow contentView] frame]);
|
||||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
closure.view = [windata->nswindow contentView];
|
closure.view = [windata->nswindow contentView];
|
||||||
closure.path = [[NSBezierPath bezierPath] autorelease];
|
closure.path = [[NSBezierPath bezierPath] autorelease];
|
||||||
closure.window = shaper->window;
|
closure.window = shaper->window;
|
||||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||||
[closure.path addClip];
|
[closure.path addClip];
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,37 +250,39 @@ SDL_PromptAssertion_cocoa(const SDL_assert_data *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSString *msg = [NSString stringWithFormat:
|
|
||||||
@"Assertion failure at %s (%s:%d), triggered %u time%s:\n '%s'",
|
|
||||||
data->function, data->filename, data->linenum,
|
|
||||||
data->trigger_count, (data->trigger_count == 1) ? "" : "s",
|
|
||||||
data->condition];
|
|
||||||
|
|
||||||
NSLog(@"%@", msg);
|
NSString *msg = [NSString stringWithFormat:
|
||||||
|
@"Assertion failure at %s (%s:%d), triggered %u time%s:\n '%s'",
|
||||||
|
data->function, data->filename, data->linenum,
|
||||||
|
data->trigger_count, (data->trigger_count == 1) ? "" : "s",
|
||||||
|
data->condition];
|
||||||
|
|
||||||
/*
|
NSLog(@"%@", msg);
|
||||||
* !!! FIXME: this code needs to deal with fullscreen modes:
|
|
||||||
* !!! FIXME: reset to default desktop, runModal, reset to current?
|
|
||||||
*/
|
|
||||||
|
|
||||||
NSAlert* alert = [[NSAlert alloc] init];
|
/*
|
||||||
[alert setAlertStyle:NSCriticalAlertStyle];
|
* !!! FIXME: this code needs to deal with fullscreen modes:
|
||||||
[alert setMessageText:msg];
|
* !!! FIXME: reset to default desktop, runModal, reset to current?
|
||||||
[alert addButtonWithTitle:@"Retry"];
|
*/
|
||||||
[alert addButtonWithTitle:@"Break"];
|
|
||||||
[alert addButtonWithTitle:@"Abort"];
|
|
||||||
[alert addButtonWithTitle:@"Ignore"];
|
|
||||||
[alert addButtonWithTitle:@"Always Ignore"];
|
|
||||||
const NSInteger clicked = [alert runModal];
|
|
||||||
[alert release];
|
|
||||||
|
|
||||||
if (!initialized) {
|
NSAlert* alert = [[NSAlert alloc] init];
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
[alert setAlertStyle:NSCriticalAlertStyle];
|
||||||
}
|
[alert setMessageText:msg];
|
||||||
|
[alert addButtonWithTitle:@"Retry"];
|
||||||
|
[alert addButtonWithTitle:@"Break"];
|
||||||
|
[alert addButtonWithTitle:@"Abort"];
|
||||||
|
[alert addButtonWithTitle:@"Ignore"];
|
||||||
|
[alert addButtonWithTitle:@"Always Ignore"];
|
||||||
|
const NSInteger clicked = [alert runModal];
|
||||||
|
[alert release];
|
||||||
|
|
||||||
return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
|
[pool release];
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||||
|
|
|
@ -507,6 +507,7 @@ GetWindowStyle(SDL_Window * window)
|
||||||
static int
|
static int
|
||||||
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
|
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||||
SDL_WindowData *data;
|
SDL_WindowData *data;
|
||||||
|
|
||||||
|
@ -521,297 +522,313 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
||||||
data->created = created;
|
data->created = created;
|
||||||
data->videodata = videodata;
|
data->videodata = videodata;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
/* Create an event listener for the window */
|
|
||||||
data->listener = [[Cocoa_WindowListener alloc] init];
|
|
||||||
|
|
||||||
/* Fill in the SDL window with the window data */
|
/* Create an event listener for the window */
|
||||||
{
|
data->listener = [[Cocoa_WindowListener alloc] init];
|
||||||
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
|
||||||
ConvertNSRect(&rect);
|
|
||||||
window->x = (int)rect.origin.x;
|
|
||||||
window->y = (int)rect.origin.y;
|
|
||||||
window->w = (int)rect.size.width;
|
|
||||||
window->h = (int)rect.size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up the listener after we create the view */
|
/* Fill in the SDL window with the window data */
|
||||||
[data->listener listen:data];
|
{
|
||||||
|
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
||||||
if ([nswindow isVisible]) {
|
ConvertNSRect(&rect);
|
||||||
window->flags |= SDL_WINDOW_SHOWN;
|
window->x = (int)rect.origin.x;
|
||||||
} else {
|
window->y = (int)rect.origin.y;
|
||||||
window->flags &= ~SDL_WINDOW_SHOWN;
|
window->w = (int)rect.size.width;
|
||||||
}
|
window->h = (int)rect.size.height;
|
||||||
{
|
|
||||||
unsigned int style = [nswindow styleMask];
|
|
||||||
|
|
||||||
if (style == NSBorderlessWindowMask) {
|
|
||||||
window->flags |= SDL_WINDOW_BORDERLESS;
|
|
||||||
} else {
|
|
||||||
window->flags &= ~SDL_WINDOW_BORDERLESS;
|
|
||||||
}
|
|
||||||
if (style & NSResizableWindowMask) {
|
|
||||||
window->flags |= SDL_WINDOW_RESIZABLE;
|
|
||||||
} else {
|
|
||||||
window->flags &= ~SDL_WINDOW_RESIZABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* isZoomed always returns true if the window is not resizable */
|
|
||||||
if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
|
||||||
window->flags |= SDL_WINDOW_MAXIMIZED;
|
|
||||||
} else {
|
|
||||||
window->flags &= ~SDL_WINDOW_MAXIMIZED;
|
|
||||||
}
|
|
||||||
if ([nswindow isMiniaturized]) {
|
|
||||||
window->flags |= SDL_WINDOW_MINIMIZED;
|
|
||||||
} else {
|
|
||||||
window->flags &= ~SDL_WINDOW_MINIMIZED;
|
|
||||||
}
|
|
||||||
if ([nswindow isKeyWindow]) {
|
|
||||||
window->flags |= SDL_WINDOW_INPUT_FOCUS;
|
|
||||||
SDL_SetKeyboardFocus(data->window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* All done! */
|
|
||||||
window->driverdata = data;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set up the listener after we create the view */
|
||||||
|
[data->listener listen:data];
|
||||||
|
|
||||||
|
if ([nswindow isVisible]) {
|
||||||
|
window->flags |= SDL_WINDOW_SHOWN;
|
||||||
|
} else {
|
||||||
|
window->flags &= ~SDL_WINDOW_SHOWN;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
unsigned int style = [nswindow styleMask];
|
||||||
|
|
||||||
|
if (style == NSBorderlessWindowMask) {
|
||||||
|
window->flags |= SDL_WINDOW_BORDERLESS;
|
||||||
|
} else {
|
||||||
|
window->flags &= ~SDL_WINDOW_BORDERLESS;
|
||||||
|
}
|
||||||
|
if (style & NSResizableWindowMask) {
|
||||||
|
window->flags |= SDL_WINDOW_RESIZABLE;
|
||||||
|
} else {
|
||||||
|
window->flags &= ~SDL_WINDOW_RESIZABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* isZoomed always returns true if the window is not resizable */
|
||||||
|
if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
||||||
|
window->flags |= SDL_WINDOW_MAXIMIZED;
|
||||||
|
} else {
|
||||||
|
window->flags &= ~SDL_WINDOW_MAXIMIZED;
|
||||||
|
}
|
||||||
|
if ([nswindow isMiniaturized]) {
|
||||||
|
window->flags |= SDL_WINDOW_MINIMIZED;
|
||||||
|
} else {
|
||||||
|
window->flags &= ~SDL_WINDOW_MINIMIZED;
|
||||||
|
}
|
||||||
|
if ([nswindow isKeyWindow]) {
|
||||||
|
window->flags |= SDL_WINDOW_INPUT_FOCUS;
|
||||||
|
SDL_SetKeyboardFocus(data->window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All done! */
|
||||||
|
[pool release];
|
||||||
|
window->driverdata = data;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow;
|
NSWindow *nswindow;
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
unsigned int style;
|
unsigned int style;
|
||||||
|
|
||||||
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
||||||
rect.origin.x = window->x;
|
rect.origin.x = window->x;
|
||||||
rect.origin.y = window->y;
|
rect.origin.y = window->y;
|
||||||
rect.size.width = window->w;
|
rect.size.width = window->w;
|
||||||
rect.size.height = window->h;
|
rect.size.height = window->h;
|
||||||
ConvertNSRect(&rect);
|
ConvertNSRect(&rect);
|
||||||
|
|
||||||
style = GetWindowStyle(window);
|
style = GetWindowStyle(window);
|
||||||
|
|
||||||
/* Figure out which screen to place this window */
|
/* Figure out which screen to place this window */
|
||||||
NSArray *screens = [NSScreen screens];
|
NSArray *screens = [NSScreen screens];
|
||||||
NSScreen *screen = nil;
|
NSScreen *screen = nil;
|
||||||
NSScreen *candidate;
|
NSScreen *candidate;
|
||||||
int i, count = [screens count];
|
int i, count = [screens count];
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
candidate = [screens objectAtIndex:i];
|
candidate = [screens objectAtIndex:i];
|
||||||
NSRect screenRect = [candidate frame];
|
NSRect screenRect = [candidate frame];
|
||||||
if (rect.origin.x >= screenRect.origin.x &&
|
if (rect.origin.x >= screenRect.origin.x &&
|
||||||
rect.origin.x < screenRect.origin.x + screenRect.size.width &&
|
rect.origin.x < screenRect.origin.x + screenRect.size.width &&
|
||||||
rect.origin.y >= screenRect.origin.y &&
|
rect.origin.y >= screenRect.origin.y &&
|
||||||
rect.origin.y < screenRect.origin.y + screenRect.size.height) {
|
rect.origin.y < screenRect.origin.y + screenRect.size.height) {
|
||||||
screen = candidate;
|
screen = candidate;
|
||||||
rect.origin.x -= screenRect.origin.x;
|
rect.origin.x -= screenRect.origin.x;
|
||||||
rect.origin.y -= screenRect.origin.y;
|
rect.origin.y -= screenRect.origin.y;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen];
|
|
||||||
|
|
||||||
// Create a default view for this window
|
|
||||||
rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
|
||||||
NSView *contentView = [[SDLView alloc] initWithFrame:rect];
|
|
||||||
[nswindow setContentView: contentView];
|
|
||||||
[contentView release];
|
|
||||||
|
|
||||||
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
|
|
||||||
[nswindow release];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen];
|
||||||
|
|
||||||
|
// Create a default view for this window
|
||||||
|
rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
||||||
|
NSView *contentView = [[SDLView alloc] initWithFrame:rect];
|
||||||
|
[nswindow setContentView: contentView];
|
||||||
|
[contentView release];
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
|
||||||
|
[nswindow release];
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSWindow *nswindow = (NSWindow *) data;
|
NSWindow *nswindow = (NSWindow *) data;
|
||||||
NSString *title;
|
NSString *title;
|
||||||
|
|
||||||
@autoreleasepool {
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
/* Query the title from the existing window */
|
|
||||||
title = [nswindow title];
|
/* Query the title from the existing window */
|
||||||
if (title) {
|
title = [nswindow title];
|
||||||
window->title = SDL_strdup([title UTF8String]);
|
if (title) {
|
||||||
}
|
window->title = SDL_strdup([title UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return SetupWindowData(_this, window, nswindow, SDL_FALSE);
|
return SetupWindowData(_this, window, nswindow, SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
NSString *string;
|
NSString *string;
|
||||||
|
|
||||||
if(window->title) {
|
if(window->title) {
|
||||||
string = [[NSString alloc] initWithUTF8String:window->title];
|
string = [[NSString alloc] initWithUTF8String:window->title];
|
||||||
} else {
|
} else {
|
||||||
string = [[NSString alloc] init];
|
string = [[NSString alloc] init];
|
||||||
}
|
|
||||||
[nswindow setTitle:string];
|
|
||||||
[string release];
|
|
||||||
}
|
}
|
||||||
|
[nswindow setTitle:string];
|
||||||
|
[string release];
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSImage *nsimage = Cocoa_CreateImage(icon);
|
NSImage *nsimage = Cocoa_CreateImage(icon);
|
||||||
|
|
||||||
if (nsimage) {
|
if (nsimage) {
|
||||||
[NSApp setApplicationIconImage:nsimage];
|
[NSApp setApplicationIconImage:nsimage];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
Uint32 moveHack;
|
Uint32 moveHack;
|
||||||
|
|
||||||
rect.origin.x = window->x;
|
rect.origin.x = window->x;
|
||||||
rect.origin.y = window->y;
|
rect.origin.y = window->y;
|
||||||
rect.size.width = window->w;
|
rect.size.width = window->w;
|
||||||
rect.size.height = window->h;
|
rect.size.height = window->h;
|
||||||
ConvertNSRect(&rect);
|
ConvertNSRect(&rect);
|
||||||
|
|
||||||
moveHack = s_moveHack;
|
moveHack = s_moveHack;
|
||||||
s_moveHack = 0;
|
s_moveHack = 0;
|
||||||
[nswindow setFrameOrigin:rect.origin];
|
[nswindow setFrameOrigin:rect.origin];
|
||||||
s_moveHack = moveHack;
|
s_moveHack = moveHack;
|
||||||
|
|
||||||
if (window == _this->current_glwin) {
|
if (window == _this->current_glwin) {
|
||||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||||
NSWindow *nswindow = windata->nswindow;
|
NSWindow *nswindow = windata->nswindow;
|
||||||
NSSize size;
|
NSSize size;
|
||||||
|
|
||||||
size.width = window->w;
|
size.width = window->w;
|
||||||
size.height = window->h;
|
size.height = window->h;
|
||||||
[nswindow setContentSize:size];
|
[nswindow setContentSize:size];
|
||||||
|
|
||||||
if (window == _this->current_glwin) {
|
if (window == _this->current_glwin) {
|
||||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||||
|
|
||||||
NSSize minSize;
|
NSSize minSize;
|
||||||
minSize.width = window->min_w;
|
minSize.width = window->min_w;
|
||||||
minSize.height = window->min_h;
|
minSize.height = window->min_h;
|
||||||
|
|
||||||
[windata->nswindow setContentMinSize:minSize];
|
[windata->nswindow setContentMinSize:minSize];
|
||||||
}
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||||
|
|
||||||
NSSize maxSize;
|
NSSize maxSize;
|
||||||
maxSize.width = window->max_w;
|
maxSize.width = window->max_w;
|
||||||
maxSize.height = window->max_h;
|
maxSize.height = window->max_h;
|
||||||
|
|
||||||
[windata->nswindow setContentMaxSize:maxSize];
|
[windata->nswindow setContentMaxSize:maxSize];
|
||||||
}
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
|
|
||||||
if (![nswindow isMiniaturized]) {
|
if (![nswindow isMiniaturized]) {
|
||||||
[nswindow makeKeyAndOrderFront:nil];
|
[nswindow makeKeyAndOrderFront:nil];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_HideWindow(_THIS, SDL_Window * window)
|
Cocoa_HideWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
[nswindow orderOut:nil];
|
|
||||||
}
|
[nswindow orderOut:nil];
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_RaiseWindow(_THIS, SDL_Window * window)
|
Cocoa_RaiseWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
[nswindow makeKeyAndOrderFront:nil];
|
|
||||||
}
|
[nswindow makeKeyAndOrderFront:nil];
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
|
Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
[nswindow zoom:nil];
|
|
||||||
|
|
||||||
if (window == _this->current_glwin) {
|
[nswindow zoom:nil];
|
||||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
|
||||||
}
|
if (window == _this->current_glwin) {
|
||||||
|
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
|
Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
[nswindow miniaturize:nil];
|
|
||||||
}
|
[nswindow miniaturize:nil];
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
|
|
||||||
if ([nswindow isMiniaturized]) {
|
if ([nswindow isMiniaturized]) {
|
||||||
[nswindow deminiaturize:nil];
|
[nswindow deminiaturize:nil];
|
||||||
} else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
} else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
||||||
[nswindow zoom:nil];
|
[nswindow zoom:nil];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSWindow *
|
static NSWindow *
|
||||||
|
@ -837,95 +854,96 @@ Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
||||||
{
|
{
|
||||||
/* this message arrived in 10.6. You're out of luck on older OSes. */
|
/* this message arrived in 10.6. You're out of luck on older OSes. */
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
|
if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
|
||||||
[nswindow setStyleMask:GetWindowStyle(window)];
|
[nswindow setStyleMask:GetWindowStyle(window)];
|
||||||
if (bordered) {
|
if (bordered) {
|
||||||
Cocoa_SetWindowTitle(_this, window); // this got blanked out.
|
Cocoa_SetWindowTitle(_this, window); // this got blanked out.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[pool release];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||||
NSWindow *nswindow = data->nswindow;
|
NSWindow *nswindow = data->nswindow;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
/* The view responder chain gets messed with during setStyleMask */
|
/* The view responder chain gets messed with during setStyleMask */
|
||||||
if ([[nswindow contentView] nextResponder] == data->listener) {
|
if ([[nswindow contentView] nextResponder] == data->listener) {
|
||||||
[[nswindow contentView] setNextResponder:nil];
|
[[nswindow contentView] setNextResponder:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
SDL_Rect bounds;
|
||||||
|
|
||||||
|
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
||||||
|
rect.origin.x = bounds.x;
|
||||||
|
rect.origin.y = bounds.y;
|
||||||
|
rect.size.width = bounds.w;
|
||||||
|
rect.size.height = bounds.h;
|
||||||
|
ConvertNSRect(&rect);
|
||||||
|
|
||||||
|
/* Hack to fix origin on Mac OS X 10.4 */
|
||||||
|
NSRect screenRect = [[nswindow screen] frame];
|
||||||
|
if (screenRect.size.height >= 1.0f) {
|
||||||
|
rect.origin.y += (screenRect.size.height - rect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen) {
|
if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
||||||
SDL_Rect bounds;
|
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
|
||||||
|
|
||||||
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
|
||||||
rect.origin.x = bounds.x;
|
|
||||||
rect.origin.y = bounds.y;
|
|
||||||
rect.size.width = bounds.w;
|
|
||||||
rect.size.height = bounds.h;
|
|
||||||
ConvertNSRect(&rect);
|
|
||||||
|
|
||||||
/* Hack to fix origin on Mac OS X 10.4 */
|
|
||||||
NSRect screenRect = [[nswindow screen] frame];
|
|
||||||
if (screenRect.size.height >= 1.0f) {
|
|
||||||
rect.origin.y += (screenRect.size.height - rect.size.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
|
||||||
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
|
|
||||||
} else {
|
|
||||||
nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
rect.origin.x = window->windowed.x;
|
nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
|
||||||
rect.origin.y = window->windowed.y;
|
|
||||||
rect.size.width = window->windowed.w;
|
|
||||||
rect.size.height = window->windowed.h;
|
|
||||||
ConvertNSRect(&rect);
|
|
||||||
|
|
||||||
if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
|
||||||
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
|
|
||||||
} else {
|
|
||||||
nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
rect.origin.x = window->windowed.x;
|
||||||
|
rect.origin.y = window->windowed.y;
|
||||||
|
rect.size.width = window->windowed.w;
|
||||||
|
rect.size.height = window->windowed.h;
|
||||||
|
ConvertNSRect(&rect);
|
||||||
|
|
||||||
/* The view responder chain gets messed with during setStyleMask */
|
if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
||||||
if ([[nswindow contentView] nextResponder] != data->listener) {
|
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
|
||||||
[[nswindow contentView] setNextResponder:data->listener];
|
|
||||||
}
|
|
||||||
|
|
||||||
s_moveHack = 0;
|
|
||||||
[nswindow setFrameOrigin:rect.origin];
|
|
||||||
[nswindow setContentSize:rect.size];
|
|
||||||
s_moveHack = SDL_GetTicks();
|
|
||||||
|
|
||||||
/* When the window style changes the title is cleared */
|
|
||||||
if (!fullscreen) {
|
|
||||||
Cocoa_SetWindowTitle(_this, window);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FULLSCREEN_TOGGLEABLE
|
|
||||||
if (SDL_ShouldAllowTopmost() && fullscreen) {
|
|
||||||
/* OpenGL is rendering to the window, so make it visible! */
|
|
||||||
[nswindow setLevel:CGShieldingWindowLevel()];
|
|
||||||
} else {
|
} else {
|
||||||
[nswindow setLevel:kCGNormalWindowLevel];
|
nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
|
||||||
}
|
|
||||||
#endif
|
|
||||||
[nswindow makeKeyAndOrderFront:nil];
|
|
||||||
|
|
||||||
if (window == _this->current_glwin) {
|
|
||||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The view responder chain gets messed with during setStyleMask */
|
||||||
|
if ([[nswindow contentView] nextResponder] != data->listener) {
|
||||||
|
[[nswindow contentView] setNextResponder:data->listener];
|
||||||
|
}
|
||||||
|
|
||||||
|
s_moveHack = 0;
|
||||||
|
[nswindow setFrameOrigin:rect.origin];
|
||||||
|
[nswindow setContentSize:rect.size];
|
||||||
|
s_moveHack = SDL_GetTicks();
|
||||||
|
|
||||||
|
/* When the window style changes the title is cleared */
|
||||||
|
if (!fullscreen) {
|
||||||
|
Cocoa_SetWindowTitle(_this, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef FULLSCREEN_TOGGLEABLE
|
||||||
|
if (SDL_ShouldAllowTopmost() && fullscreen) {
|
||||||
|
/* OpenGL is rendering to the window, so make it visible! */
|
||||||
|
[nswindow setLevel:CGShieldingWindowLevel()];
|
||||||
|
} else {
|
||||||
|
[nswindow setLevel:kCGNormalWindowLevel];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
[nswindow makeKeyAndOrderFront:nil];
|
||||||
|
|
||||||
|
if (window == _this->current_glwin) {
|
||||||
|
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||||
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1009,18 +1027,18 @@ Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||||
void
|
void
|
||||||
Cocoa_DestroyWindow(_THIS, SDL_Window * window)
|
Cocoa_DestroyWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
[data->listener close];
|
[data->listener close];
|
||||||
[data->listener release];
|
[data->listener release];
|
||||||
if (data->created) {
|
if (data->created) {
|
||||||
[data->nswindow close];
|
[data->nswindow close];
|
||||||
}
|
|
||||||
SDL_free(data);
|
|
||||||
}
|
}
|
||||||
|
SDL_free(data);
|
||||||
}
|
}
|
||||||
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool
|
SDL_bool
|
||||||
|
|
|
@ -21,23 +21,30 @@ FILE* TestSupportRWops_OpenFPFromReadDir(const char *file, const char *mode)
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
|
|
||||||
// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
|
// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
|
||||||
if (strcmp("r", mode) && strcmp("rb", mode)) {
|
if(strcmp("r", mode) && strcmp("rb", mode))
|
||||||
|
{
|
||||||
return fopen(file, mode);
|
return fopen(file, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
|
||||||
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
|
||||||
|
|
||||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
|
||||||
|
|
||||||
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
|
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||||
if ([file_manager fileExistsAtPath:full_path_with_file_to_try]) {
|
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
||||||
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
|
||||||
} else {
|
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||||
fp = fopen(file, mode);
|
|
||||||
}
|
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
|
||||||
}
|
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
|
||||||
|
{
|
||||||
|
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fp = fopen(file, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[autorelease_pool drain];
|
||||||
|
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
@ -46,14 +53,16 @@ FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode)
|
||||||
{
|
{
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
|
|
||||||
@autoreleasepool {
|
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
|
||||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||||
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
|
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||||
|
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
|
||||||
|
|
||||||
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
||||||
}
|
|
||||||
|
[autorelease_pool drain];
|
||||||
|
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +75,15 @@ SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *
|
||||||
{
|
{
|
||||||
SDL_RWops* rw = NULL;
|
SDL_RWops* rw = NULL;
|
||||||
|
|
||||||
@autoreleasepool {
|
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
|
||||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||||
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
|
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||||
|
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
|
||||||
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
|
|
||||||
}
|
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
|
||||||
|
|
||||||
|
[autorelease_pool drain];
|
||||||
return rw;
|
return rw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue