ui: Refactoring on mobile

This commit is contained in:
Hajime Hoshi 2016-09-02 01:34:51 +09:00
parent 453c2c4589
commit 93a994f1d6

View File

@ -79,22 +79,30 @@ func (u *userInterface) Start(width, height int, scale float64, title string) er
func (u *userInterface) AnimationFrameLoop(g GraphicsContext) error { func (u *userInterface) AnimationFrameLoop(g GraphicsContext) error {
for { for {
if err := u.update(g); err != nil {
return err
}
}
}
func (u *userInterface) update(g GraphicsContext) error {
<-chRender
defer func() {
chRenderEnd <- struct{}{}
}()
if u.sizeChanged { if u.sizeChanged {
// Sizing also calls GL functions // Sizing also calls GL functions
<-chRender
u.sizeChanged = false u.sizeChanged = false
if err := g.SetSize(u.width, u.height, u.actualScreenScale()); err != nil { if err := g.SetSize(u.width, u.height, u.actualScreenScale()); err != nil {
return err return err
} }
chRenderEnd <- struct{}{} return nil
continue
} }
<-chRender
if err := g.Update(); err != nil { if err := g.Update(); err != nil {
return err return err
} }
chRenderEnd <- struct{}{} return nil
}
} }
func (u *userInterface) SetScreenSize(width, height int) (bool, error) { func (u *userInterface) SetScreenSize(width, height int) (bool, error) {