mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Refactoring: ui.Init now returns gl.Context object
This commit is contained in:
parent
63f2c3cb9f
commit
408444842a
3
init.go
3
init.go
@ -22,6 +22,5 @@ import (
|
||||
var glContext *opengl.Context
|
||||
|
||||
func init() {
|
||||
ui.Init()
|
||||
glContext = opengl.NewContext()
|
||||
glContext = ui.Init()
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ func Now() int64 {
|
||||
|
||||
var currentUI *userInterface
|
||||
|
||||
func Init() {
|
||||
func Init() *opengl.Context {
|
||||
// TODO: Is this OK to lock OS thread only for UI?
|
||||
runtime.LockOSThread()
|
||||
|
||||
err := glfw.Init()
|
||||
@ -58,6 +59,8 @@ func Init() {
|
||||
}()
|
||||
|
||||
currentUI = u
|
||||
|
||||
return opengl.NewContext()
|
||||
}
|
||||
|
||||
func Start(width, height, scale int, title string) (actualScale int, err error) {
|
||||
|
@ -111,7 +111,7 @@ func (*userInterface) swapBuffers() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
func Init() {
|
||||
func Init() *opengl.Context {
|
||||
// Do nothing in node.js.
|
||||
if js.Global.Get("require") != js.Undefined {
|
||||
return
|
||||
@ -143,6 +143,8 @@ func Init() {
|
||||
bodyStyle.Set("height", "100%")
|
||||
bodyStyle.Set("margin", "0")
|
||||
bodyStyle.Set("padding", "0")
|
||||
// TODO: This is OK as long as the game is in an independent iframe.
|
||||
// What if the canvas is embedded in a HTML directly?
|
||||
doc.Get("body").Call("addEventListener", "click", func() {
|
||||
canvas.Call("focus")
|
||||
})
|
||||
@ -214,6 +216,8 @@ func Init() {
|
||||
window.Call("addEventListener", "gamepadconnected", func(e *js.Object) {
|
||||
// Do nothing.
|
||||
})
|
||||
|
||||
return opengl.NewContext()
|
||||
}
|
||||
|
||||
func setMouseCursorFromEvent(e *js.Object) {
|
||||
|
Loading…
Reference in New Issue
Block a user