2012-07-25 10:07:31 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#import "AppController.h"
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
|
|
|
@implementation AppController
|
|
|
|
|
|
|
|
static AppDelegate s_sharedApplication;
|
|
|
|
|
|
|
|
@synthesize window, glView;
|
|
|
|
|
|
|
|
-(void) applicationDidFinishLaunching:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
// create the window
|
|
|
|
// note that using NSResizableWindowMask causes the window to be a little
|
|
|
|
// smaller and therefore ipad graphics are not loaded
|
2012-11-23 14:22:50 +08:00
|
|
|
NSRect rect = NSMakeRect(200, 200, 480, 320);
|
2012-07-25 10:07:31 +08:00
|
|
|
window = [[NSWindow alloc] initWithContentRect:rect
|
|
|
|
styleMask:( NSClosableWindowMask | NSTitledWindowMask )
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
defer:YES];
|
2012-11-23 14:22:50 +08:00
|
|
|
|
|
|
|
NSOpenGLPixelFormatAttribute attributes[] = {
|
|
|
|
NSOpenGLPFADoubleBuffer,
|
|
|
|
NSOpenGLPFADepthSize, 24,
|
|
|
|
NSOpenGLPFAStencilSize, 8,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease];
|
2012-07-25 10:07:31 +08:00
|
|
|
|
|
|
|
// allocate our GL view
|
2013-06-21 11:14:03 +08:00
|
|
|
// (isn't there already a shared CCEAGLView?)
|
2013-06-21 08:46:22 +08:00
|
|
|
glView = [[CCEAGLView alloc] initWithFrame:rect pixelFormat:pixelFormat];
|
2012-07-25 10:07:31 +08:00
|
|
|
|
|
|
|
// set window parameters
|
|
|
|
[window becomeFirstResponder];
|
|
|
|
[window setContentView:glView];
|
|
|
|
[window setTitle:@"TestCpp"];
|
|
|
|
[window makeKeyAndOrderFront:self];
|
|
|
|
[window setAcceptsMouseMovedEvents:NO];
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
cocos2d::Application::sharedApplication()->run();
|
2012-07-25 10:07:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) dealloc
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
cocos2d::Director::sharedDirector()->end();
|
2012-07-25 10:07:31 +08:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark IB Actions
|
|
|
|
|
|
|
|
-(IBAction) toggleFullScreen:(id)sender
|
|
|
|
{
|
2013-06-21 08:46:22 +08:00
|
|
|
CCEAGLView* pView = [CCEAGLView sharedEGLView];
|
2012-07-25 10:07:31 +08:00
|
|
|
[pView setFullScreen:!pView.isFullScreen];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(IBAction) exitFullScreen:(id)sender
|
|
|
|
{
|
2013-06-21 08:46:22 +08:00
|
|
|
[[CCEAGLView sharedEGLView] setFullScreen:NO];
|
2012-07-25 10:07:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|