graphics: Bug fix: Initialize must be done even when Draw is called first

This commit is contained in:
Hajime Hoshi 2016-06-14 00:55:25 +09:00
parent 218df19ead
commit b852f5a0f7

View File

@ -65,7 +65,7 @@ func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error)
return c.screen.impl.isInvalidated(context), nil
}
func (c *graphicsContext) UpdateAndDraw() error {
func (c *graphicsContext) initializeIfNeeded() error {
if !c.initialized {
if err := graphics.Initialize(ui.GLContext()); err != nil {
return err
@ -81,6 +81,13 @@ func (c *graphicsContext) UpdateAndDraw() error {
return err
}
}
return nil
}
func (c *graphicsContext) UpdateAndDraw() error {
if err := c.initializeIfNeeded(); err != nil {
return err
}
if err := c.screen.Clear(); err != nil {
return err
}
@ -113,6 +120,9 @@ func (c *graphicsContext) UpdateAndDraw() error {
}
func (c *graphicsContext) Draw() error {
if err := c.initializeIfNeeded(); err != nil {
return err
}
if err := c.defaultRenderTarget.Clear(); err != nil {
return err
}