ui: Remove FinishRendering

This commit is contained in:
Hajime Hoshi 2016-06-10 01:49:21 +09:00
parent 8121b2102f
commit eb8e8b6034
6 changed files with 9 additions and 13 deletions

View File

@ -158,10 +158,6 @@ func Run(g GraphicsContext, width, height, scale int, title string, fps int) err
beforeForUpdate += int64(tt) * int64(time.Second) / int64(fps)
frames++
}
if err := ui.CurrentUI().FinishRendering(); err != nil {
return err
}
// Calc the current FPS.
if time.Second <= time.Duration(n2-beforeForFPS) {
fps := float64(frames) * float64(time.Second) / float64(n2-beforeForFPS)
@ -169,6 +165,7 @@ func Run(g GraphicsContext, width, height, scale int, title string, fps int) err
beforeForFPS = n2
frames = 0
}
e.Done <- struct{}{}
case ui.PauseEvent:
if err := g.Pause(); err != nil {
return err

View File

@ -25,6 +25,7 @@ type ScreenSizeEvent struct {
}
type RenderEvent struct {
Done chan struct{}
}
type PauseEvent struct {

View File

@ -18,7 +18,6 @@ type UserInterface interface {
Start(width, height, scale int, title string) error
Update() (interface{}, error)
SwapBuffers() error
FinishRendering() error
Terminate() error
ScreenScale() int
SetScreenSize(width, height int) bool

View File

@ -230,7 +230,9 @@ func (u *userInterface) Update() (interface{}, error) {
if ferr != nil {
return nil, ferr
}
return RenderEvent{}, nil
// Dummy channel
ch := make(chan struct{}, 1)
return RenderEvent{ch}, nil
}
func (u *userInterface) Terminate() error {

View File

@ -92,7 +92,9 @@ func (u *userInterface) Update() (interface{}, error) {
}
return e, nil
}
return RenderEvent{}, nil
// Dummy channel
ch := make(chan struct{}, 1)
return RenderEvent{ch}, nil
}
func (u *userInterface) Terminate() error {

View File

@ -144,7 +144,7 @@ func (u *userInterface) Update() (interface{}, error) {
chPauseStart <- struct{}{}
return PauseEvent{chPauseEnd}, nil
case <-chRender:
return RenderEvent{}, nil
return RenderEvent{chRenderEnd}, nil
}
}
@ -152,11 +152,6 @@ func (u *userInterface) SwapBuffers() error {
return nil
}
func (u *userInterface) FinishRendering() error {
chRenderEnd <- struct{}{}
return nil
}
func (u *userInterface) SetScreenSize(width, height int) bool {
// TODO: Implement
return false