ebiten/ui/cocoa/ui.go
2014-01-07 02:14:53 +09:00

56 lines
1018 B
Go

package cocoa
// #cgo CFLAGS: -x objective-c
// #cgo LDFLAGS: -framework Cocoa -framework OpenGL
//
// void Run(void);
// void StartApplication(void);
// void PollEvents(void);
//
import "C"
import (
"github.com/hajimehoshi/go-ebiten/graphics"
"github.com/hajimehoshi/go-ebiten/ui"
)
type cocoaUI struct {
textureFactory *textureFactory
}
var currentUI *cocoaUI
func getCurrentUI() *cocoaUI {
if currentUI != nil {
return currentUI
}
currentUI = &cocoaUI{}
currentUI.textureFactory = newTextureFactory()
return currentUI
}
func UI() ui.UI {
return getCurrentUI()
}
func TextureFactory() graphics.TextureFactory {
return getCurrentUI().textureFactory
}
func (u *cocoaUI) CreateGameWindow(width, height, scale int, title string) ui.GameWindow {
return u.textureFactory.createGameWindow(width, height, scale, title)
}
func (u *cocoaUI) PollEvents() {
C.PollEvents()
}
func (u *cocoaUI) RunMainLoop() {
C.StartApplication()
currentUI.textureFactory.run()
// TODO: Enable the loop
//C.Run()
}