Add 'release'

This commit is contained in:
Hajime Hoshi 2013-12-30 01:36:11 +09:00
parent 51fa65bf2f
commit fbd35ac6a8
2 changed files with 19 additions and 12 deletions

View File

@ -2,10 +2,10 @@
#import "ebiten_window.h"
#include <OpenGL/gl.h>
#import "ebiten_content_view.h"
@class NSOpenGLContext;
void ebiten_WindowClosed(void* nativeWindow);
@implementation EbitenWindow {
@ -16,6 +16,7 @@ void ebiten_WindowClosed(void* nativeWindow);
- (id)initWithSize:(NSSize)size
glContext:(NSOpenGLContext*)glContext {
self->glContext_ = glContext;
[self->glContext_ retain];
NSUInteger style = (NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask);
@ -35,14 +36,16 @@ void ebiten_WindowClosed(void* nativeWindow);
styleMask:style
backing:NSBackingStoreBuffered
defer:YES];
assert(self != nil);
[self setReleasedWhenClosed:YES];
[self setDelegate:self];
[self setDocumentEdited:YES];
if (self != nil) {
[self setReleasedWhenClosed:YES];
[self setDelegate:self];
[self setDocumentEdited:YES];
NSRect rect = NSMakeRect(0, 0, size.width, size.height);
NSView* contentView = [[EbitenContentView alloc] initWithFrame:rect];
[self setContentView:contentView];
NSRect rect = NSMakeRect(0, 0, size.width, size.height);
NSView* contentView = [[EbitenContentView alloc] initWithFrame:rect];
[self setContentView:contentView];
[contentView release];
}
return self;
}

View File

@ -54,11 +54,15 @@ void* CreateWindow(size_t width, size_t height, const char* title, void* glConte
EbitenWindow* window = [[EbitenWindow alloc]
initWithSize:size
glContext:glContext];
[window setTitle: [[NSString alloc]
initWithUTF8String:title]];
NSString* nsTitle = [[NSString alloc]
initWithUTF8String:title];
[window setTitle: nsTitle];
[nsTitle release];
[window makeKeyAndOrderFront:nil];
[(NSOpenGLContext*)glContext setView:[window contentView]];
[glContext setView:[window contentView]];
[glContext release];
return window;
}