mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
graphics: Bug fix: Initialize must be done even when Draw is called first
This commit is contained in:
parent
218df19ead
commit
b852f5a0f7
@ -65,7 +65,7 @@ func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error)
|
|||||||
return c.screen.impl.isInvalidated(context), nil
|
return c.screen.impl.isInvalidated(context), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) UpdateAndDraw() error {
|
func (c *graphicsContext) initializeIfNeeded() error {
|
||||||
if !c.initialized {
|
if !c.initialized {
|
||||||
if err := graphics.Initialize(ui.GLContext()); err != nil {
|
if err := graphics.Initialize(ui.GLContext()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -81,6 +81,13 @@ func (c *graphicsContext) UpdateAndDraw() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *graphicsContext) UpdateAndDraw() error {
|
||||||
|
if err := c.initializeIfNeeded(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := c.screen.Clear(); err != nil {
|
if err := c.screen.Clear(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -113,6 +120,9 @@ func (c *graphicsContext) UpdateAndDraw() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) Draw() error {
|
func (c *graphicsContext) Draw() error {
|
||||||
|
if err := c.initializeIfNeeded(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := c.defaultRenderTarget.Clear(); err != nil {
|
if err := c.defaultRenderTarget.Clear(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user