hostile-takeover/game/sdl/mac/AppDelegate.mm
Nathan Fulton d926ef0bbe Prevent SDL from rendering when app is backgrounded
On some platforms, the game will crash if SDL attempts to render to the
screen/window while the game is backgrounded. To prevent this, stop
rendering when the game enters a background state and resume rendering
when the game enters a foreground state.
2016-08-24 16:20:31 -04:00

47 lines
1.2 KiB
Plaintext

#import <Cocoa/Cocoa.h>
#import "game/sdl/mac/AppDelegate.h"
#include "game/ht.h"
#include "game/sdl/sysmessages.h"
#include "base/thread.h"
#include "game/sdl/mac/SDLMain.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// MainMenu.xib is set via IB to not be visible on launch.
// So SDL should be the only window open once the game starts
// Start the game
SDL_main();
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
SDL_Quit();
}
#if 0
// As OS X is a desktop where most users are adjusted to multi-window management,
// we probably don't need to suspend the game just because the window goes
// out of focus... The player probobably intends to let the game continute running
// as they do something else.
- (void)applicationDidBecomeActive:(NSNotification *)notification {
wi::HostAppDidEnterForeground();
}
- (void)applicationWillResignActive:(NSNotification *)notification {
wi::HostAppWillEnterBackground();
}
#endif
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
@end