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) beforeForUpdate += int64(tt) * int64(time.Second) / int64(fps)
frames++ frames++
} }
if err := ui.CurrentUI().FinishRendering(); err != nil {
return err
}
// Calc the current FPS. // Calc the current FPS.
if time.Second <= time.Duration(n2-beforeForFPS) { if time.Second <= time.Duration(n2-beforeForFPS) {
fps := float64(frames) * float64(time.Second) / float64(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 beforeForFPS = n2
frames = 0 frames = 0
} }
e.Done <- struct{}{}
case ui.PauseEvent: case ui.PauseEvent:
if err := g.Pause(); err != nil { if err := g.Pause(); err != nil {
return err return err

View File

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

View File

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

View File

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

View File

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

View File

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