Refactoring

This commit is contained in:
Hajime Hoshi 2013-06-18 21:16:37 +09:00
parent 80c666b266
commit ab558db683
2 changed files with 6 additions and 12 deletions

View File

@ -76,21 +76,19 @@ func main() {
game := &DemoGame{}
device = graphics.NewDevice(screenWidth, screenHeight, screenScale,
func(g *graphics.GraphicsContext, offscreen *graphics.Texture) {
<-ch
ticket := <-ch
game.Draw(g, offscreen)
ch<- true
ch<- ticket
})
go func() {
const frameTime = time.Second / 60
lastTime := time.Now()
tick := time.Tick(frameTime)
for {
<-ch
<-tick
ticket := <-ch
game.Update()
ch<- true
now := time.Now()
time.Sleep(frameTime - now.Sub(lastTime))
lastTime = now
ch<- ticket
}
}()
ch<- true

View File

@ -92,7 +92,3 @@ func NewTextureFromRGBA(image *image.RGBA) *Texture {
func (texture *Texture) IsAvailable() bool {
return texture.id != 0
}
func init() {
// TODO: Initialize OpenGL here?
}