ebiten/ui/glfw/ui.go

37 lines
687 B
Go
Raw Normal View History

2014-12-05 18:26:02 +01:00
package glfw
import (
glfw "github.com/go-gl/glfw3"
"github.com/hajimehoshi/ebiten/graphics"
"github.com/hajimehoshi/ebiten/ui"
"log"
)
func init() {
2014-12-06 14:56:57 +01:00
glfw.SetErrorCallback(func(err glfw.ErrorCode, desc string) {
2014-12-05 18:26:02 +01:00
log.Fatalf("%v: %v\n", err, desc)
})
}
type UI struct {
canvas *Canvas
}
2014-12-06 17:09:59 +01:00
func (u *UI) Start(width, height, scale int, title string) (ui.Canvas, graphics.TextureFactory) {
2014-12-05 18:26:02 +01:00
if !glfw.Init() {
panic("glfw.Init() fails")
}
glfw.WindowHint(glfw.Resizable, glfw.False)
u.canvas = NewCanvas(width, height, scale, title)
2014-12-06 17:09:59 +01:00
return u.canvas, u.canvas
2014-12-05 18:26:02 +01:00
}
func (u *UI) DoEvents() {
2014-12-06 14:56:57 +01:00
glfw.PollEvents()
2014-12-05 19:10:17 +01:00
u.canvas.update()
2014-12-05 18:26:02 +01:00
}
func (u *UI) Terminate() {
glfw.Terminate()
}