internal/graphicsdriver/opengl: bug fix: initialization was too early on Windows

Closes #2452
This commit is contained in:
Hajime Hoshi 2022-11-13 18:00:38 +09:00
parent b536b82109
commit f69beffc6c
2 changed files with 9 additions and 4 deletions

View File

@ -82,9 +82,18 @@ func getProgramID(p program) programID {
}
type contextImpl struct {
init bool
}
func (c *context) reset() error {
if !c.init {
// Initialize OpenGL after WGL is initialized especially for Windows (#2452).
if err := gl.Init(); err != nil {
return err
}
c.init = true
}
c.locationCache = newLocationCache()
c.lastTexture = invalidTexture
c.lastFramebuffer = invalidFramebuffer

View File

@ -20,7 +20,6 @@ import (
"fmt"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl"
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
)
@ -31,8 +30,5 @@ func NewGraphics() (graphicsdriver.Graphics, error) {
return nil, fmt.Errorf("opengl: OpenGL is not supported on Xbox")
}
g := &Graphics{}
if err := gl.Init(); err != nil {
return nil, err
}
return g, nil
}