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>
|
// #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 "C"
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/go.ebiten"
|
"github.com/hajimehoshi/go.ebiten"
|
||||||
_ "github.com/hajimehoshi/go.ebiten/graphics"
|
_ "github.com/hajimehoshi/go.ebiten/graphics"
|
||||||
_ "github.com/hajimehoshi/go.ebiten/graphics/opengl"
|
_ "github.com/hajimehoshi/go.ebiten/graphics/opengl"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(game ebiten.Game, screenWidth, screenHeight, screenScale int,
|
func Run(game ebiten.Game, screenWidth, screenHeight, screenScale int,
|
||||||
title string) {
|
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 {
|
- (id)initWithWindow:(NSWindow*)window {
|
||||||
self = [super init];
|
if (self = [super init]) {
|
||||||
if (self != nil) {
|
|
||||||
self->window_ = window;
|
self->window_ = window;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -30,7 +30,6 @@ EbitenDisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||||||
CVDisplayLinkRef displayLink_;
|
CVDisplayLinkRef displayLink_;
|
||||||
updating* updating_;
|
updating* updating_;
|
||||||
//ebiten::input* input_;
|
//ebiten::input* input_;
|
||||||
bool isTerminated_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
@ -47,7 +46,6 @@ EbitenDisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||||||
|
|
||||||
- (void)prepareOpenGL {
|
- (void)prepareOpenGL {
|
||||||
[super prepareOpenGL];
|
[super prepareOpenGL];
|
||||||
self->isTerminated_ = false;
|
|
||||||
NSOpenGLContext* openGLContext = [self openGLContext];
|
NSOpenGLContext* openGLContext = [self openGLContext];
|
||||||
assert(openGLContext != nil);
|
assert(openGLContext != nil);
|
||||||
GLint const swapInterval = 1;
|
GLint const swapInterval = 1;
|
||||||
@ -141,12 +139,4 @@ EbitenDisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)terminate {
|
|
||||||
self->isTerminated_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (bool)isTerminated {
|
|
||||||
return self->isTerminated_;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -12,8 +12,6 @@ typedef bool updating(void);
|
|||||||
|
|
||||||
- (CVReturn)getFrameForTime:(CVTimeStamp const*)outputTime;
|
- (CVReturn)getFrameForTime:(CVTimeStamp const*)outputTime;
|
||||||
- (void)setUpdatingFunc:(updating*)updatingFunc;
|
- (void)setUpdatingFunc:(updating*)updatingFunc;
|
||||||
- (void)terminate;
|
|
||||||
- (bool)isTerminated;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
(void)alert;
|
(void)alert;
|
||||||
(void)contextInfo;
|
(void)contextInfo;
|
||||||
if (returnCode == NSAlertDefaultReturn) {
|
if (returnCode == NSAlertDefaultReturn) {
|
||||||
EbitenOpenGLView* glView = [self contentView];
|
[NSApp terminate:nil];
|
||||||
[glView terminate];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ static NSWindow* generateWindow(size_t width, size_t height) {
|
|||||||
return window;
|
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 {
|
@autoreleasepool {
|
||||||
NSWindow* window = generateWindow(width * scale, height * scale);
|
NSWindow* window = generateWindow(width * scale, height * scale);
|
||||||
EbitenController* controller = [[EbitenController alloc]
|
EbitenController* controller = [[EbitenController alloc]
|
||||||
|
Loading…
Reference in New Issue
Block a user