mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Update ui/cocoa
This commit is contained in:
parent
e8a4bdcef2
commit
c396d5561d
@ -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)
|
||||
}
|
||||
|
@ -8,8 +8,7 @@
|
||||
}
|
||||
|
||||
- (id)initWithWindow:(NSWindow*)window {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
if (self = [super init]) {
|
||||
self->window_ = window;
|
||||
}
|
||||
return self;
|
||||
|
@ -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
|
||||
|
@ -12,8 +12,6 @@ typedef bool updating(void);
|
||||
|
||||
- (CVReturn)getFrameForTime:(CVTimeStamp const*)outputTime;
|
||||
- (void)setUpdatingFunc:(updating*)updatingFunc;
|
||||
- (void)terminate;
|
||||
- (bool)isTerminated;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -52,8 +52,7 @@
|
||||
(void)alert;
|
||||
(void)contextInfo;
|
||||
if (returnCode == NSAlertDefaultReturn) {
|
||||
EbitenOpenGLView* glView = [self contentView];
|
||||
[glView terminate];
|
||||
[NSApp terminate:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user