mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-14 21:12:03 +01:00
36 lines
608 B
Go
36 lines
608 B
Go
package glfw
|
|
|
|
import (
|
|
glfw "github.com/go-gl/glfw3"
|
|
"github.com/hajimehoshi/ebiten/ui"
|
|
"log"
|
|
)
|
|
|
|
func init() {
|
|
glfw.SetErrorCallback(func(err glfw.ErrorCode, desc string) {
|
|
log.Fatalf("%v: %v\n", err, desc)
|
|
})
|
|
}
|
|
|
|
type UI struct {
|
|
canvas *Canvas
|
|
}
|
|
|
|
func (u *UI) Start(width, height, scale int, title string) ui.Canvas {
|
|
if !glfw.Init() {
|
|
panic("glfw.Init() fails")
|
|
}
|
|
glfw.WindowHint(glfw.Resizable, glfw.False)
|
|
u.canvas = NewCanvas(width, height, scale, title)
|
|
return u.canvas
|
|
}
|
|
|
|
func (u *UI) DoEvents() {
|
|
glfw.PollEvents()
|
|
u.canvas.update()
|
|
}
|
|
|
|
func (u *UI) Terminate() {
|
|
glfw.Terminate()
|
|
}
|