ui: Refactoring

This commit is contained in:
Hajime Hoshi 2018-12-28 14:08:44 +09:00
parent b349efaa0a
commit 83787123ac
4 changed files with 14 additions and 9 deletions

View File

@ -596,7 +596,13 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
u.window.SetPos(x, y) u.window.SetPos(x, y)
return nil return nil
}) })
u.setWindowToDriver()
var w uintptr
_ = mainthread.Run(func() error {
w = u.nativeWindow()
return nil
})
graphicscommand.Driver().SetWindow(w)
return u.loop(g) return u.loop(g)
} }

View File

@ -46,8 +46,6 @@ import (
"unsafe" "unsafe"
"github.com/go-gl/glfw/v3.2/glfw" "github.com/go-gl/glfw/v3.2/glfw"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
) )
func glfwScale() float64 { func glfwScale() float64 {
@ -73,6 +71,6 @@ func (u *userInterface) currentMonitorFromPosition() *glfw.Monitor {
return glfw.GetPrimaryMonitor() return glfw.GetPrimaryMonitor()
} }
func (u *userInterface) setWindowToDriver() { func (u *userInterface) nativeWindow() uintptr {
graphicscommand.Driver().SetWindow(u.window.GetCocoaWindow()) return u.window.GetCocoaWindow()
} }

View File

@ -45,6 +45,7 @@ func (u *userInterface) currentMonitorFromPosition() *glfw.Monitor {
return glfw.GetPrimaryMonitor() return glfw.GetPrimaryMonitor()
} }
func (u *userInterface) setWindowToDriver() { func (u *userInterface) nativeWindow() uintptr {
// Do nothing // TODO: Implement this.
return 0
} }

View File

@ -165,6 +165,6 @@ func (u *userInterface) currentMonitorFromPosition() *glfw.Monitor {
return glfw.GetPrimaryMonitor() return glfw.GetPrimaryMonitor()
} }
func (u *userInterface) setWindowToDriver() { func (u *userInterface) nativeWindow() uintptr {
// Do nothing return uintptr(unsafe.Pointer(u.window.GetWin32Window()))
} }