mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02: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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user