ui: Bug fix: Sizing also calls GLContext

This commit is contained in:
Hajime Hoshi 2016-07-24 05:29:47 +09:00
parent efe64d56f4
commit e118a755f5
5 changed files with 7 additions and 0 deletions

View File

@ -115,6 +115,7 @@ func Run(g GraphicsContext, width, height int, scale float64, title string, fps
if err := g.SetSize(e.Width, e.Height, e.ActualScale); err != nil { if err := g.SetSize(e.Width, e.Height, e.ActualScale); err != nil {
return err return err
} }
e.Done <- struct{}{}
case ui.CloseEvent: case ui.CloseEvent:
return nil return nil
case ui.RenderEvent: case ui.RenderEvent:

View File

@ -21,6 +21,7 @@ type ScreenSizeEvent struct {
Width int Width int
Height int Height int
ActualScale float64 ActualScale float64
Done chan struct{}
} }
type RenderEvent struct { type RenderEvent struct {

View File

@ -191,6 +191,7 @@ func (u *userInterface) Update() (interface{}, error) {
Width: u.width, Width: u.width,
Height: u.height, Height: u.height,
ActualScale: u.actualScreenScale(), ActualScale: u.actualScreenScale(),
Done: make(chan struct{}, 1),
} }
return nil return nil
}) })

View File

@ -96,6 +96,7 @@ func (u *userInterface) Update() (interface{}, error) {
Width: w, Width: w,
Height: h, Height: h,
ActualScale: u.ActualScreenScale(), ActualScale: u.ActualScreenScale(),
Done: make(chan struct{}, 1),
} }
return e, nil return e, nil
} }

View File

@ -83,11 +83,14 @@ func (u *userInterface) Terminate() error {
func (u *userInterface) Update() (interface{}, error) { func (u *userInterface) Update() (interface{}, error) {
if u.sizeChanged { if u.sizeChanged {
// Sizing also calls GL functions
<-chRender
u.sizeChanged = false u.sizeChanged = false
e := ScreenSizeEvent{ e := ScreenSizeEvent{
Width: u.width, Width: u.width,
Height: u.height, Height: u.height,
ActualScale: u.actualScreenScale(), ActualScale: u.actualScreenScale(),
Done: chRenderEnd,
} }
return e, nil return e, nil
} }