Update ui/cocoa

This commit is contained in:
Hajime Hoshi 2013-10-13 17:36:18 +09:00
parent e8a4bdcef2
commit c396d5561d
6 changed files with 10 additions and 20 deletions

View File

@ -5,16 +5,20 @@ package cocoa
//
// #include <stdlib.h>
//
// void Run(size_t width, size_t height, size_t scale);
// void Run(size_t width, size_t height, size_t scale, const char* title);
//
import "C"
import (
"github.com/hajimehoshi/go.ebiten"
_ "github.com/hajimehoshi/go.ebiten/graphics"
_ "github.com/hajimehoshi/go.ebiten/graphics/opengl"
"unsafe"
)
func Run(game ebiten.Game, screenWidth, screenHeight, screenScale int,
title string) {
C.Run(C.size_t(screenWidth), C.size_t(screenHeight), C.size_t(screenScale))
cTitle := C.CString(title)
defer C.free(unsafe.Pointer(cTitle))
C.Run(C.size_t(screenWidth), C.size_t(screenHeight), C.size_t(screenScale), cTitle)
}

View File

@ -8,8 +8,7 @@
}
- (id)initWithWindow:(NSWindow*)window {
self = [super init];
if (self != nil) {
if (self = [super init]) {
self->window_ = window;
}
return self;

View File

@ -30,7 +30,6 @@ EbitenDisplayLinkCallback(CVDisplayLinkRef displayLink,
CVDisplayLinkRef displayLink_;
updating* updating_;
//ebiten::input* input_;
bool isTerminated_;
}
- (id)init {
@ -47,7 +46,6 @@ EbitenDisplayLinkCallback(CVDisplayLinkRef displayLink,
- (void)prepareOpenGL {
[super prepareOpenGL];
self->isTerminated_ = false;
NSOpenGLContext* openGLContext = [self openGLContext];
assert(openGLContext != nil);
GLint const swapInterval = 1;
@ -141,12 +139,4 @@ EbitenDisplayLinkCallback(CVDisplayLinkRef displayLink,
}*/
}
- (void)terminate {
self->isTerminated_ = true;
}
- (bool)isTerminated {
return self->isTerminated_;
}
@end

View File

@ -12,8 +12,6 @@ typedef bool updating(void);
- (CVReturn)getFrameForTime:(CVTimeStamp const*)outputTime;
- (void)setUpdatingFunc:(updating*)updatingFunc;
- (void)terminate;
- (bool)isTerminated;
@end

View File

@ -52,8 +52,7 @@
(void)alert;
(void)contextInfo;
if (returnCode == NSAlertDefaultReturn) {
EbitenOpenGLView* glView = [self contentView];
[glView terminate];
[NSApp terminate:nil];
}
}

View File

@ -30,7 +30,7 @@ static NSWindow* generateWindow(size_t width, size_t height) {
return window;
}
void Run(size_t width, size_t height, size_t scale) {
void Run(size_t width, size_t height, size_t scale, const char* title) {
@autoreleasepool {
NSWindow* window = generateWindow(width * scale, height * scale);
EbitenController* controller = [[EbitenController alloc]