mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/graphicsdriver/opengl: initialize gl at init()
This changes context_gl.go a little closer to context_gles.go. Updates #2451
This commit is contained in:
parent
bb30b85d29
commit
c4abaa32f5
@ -83,18 +83,9 @@ func getProgramID(p program) programID {
|
||||
}
|
||||
|
||||
type contextImpl struct {
|
||||
init bool
|
||||
}
|
||||
|
||||
func (c *context) reset() error {
|
||||
if !c.init {
|
||||
// Note that this initialization must be done after Loop is called.
|
||||
if err := gl.Init(); err != nil {
|
||||
return fmt.Errorf("opengl: initializing error %v", err)
|
||||
}
|
||||
c.init = true
|
||||
}
|
||||
|
||||
c.locationCache = newLocationCache()
|
||||
c.lastTexture = invalidTexture
|
||||
c.lastFramebuffer = invalidFramebuffer
|
||||
|
@ -30,7 +30,9 @@ func NewGraphics() (graphicsdriver.Graphics, error) {
|
||||
return nil, fmt.Errorf("opengl: OpenGL is not supported on Xbox")
|
||||
}
|
||||
g := &Graphics{}
|
||||
g.init()
|
||||
if err := g.init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return g, nil
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,10 @@
|
||||
|
||||
package opengl
|
||||
|
||||
func (g *Graphics) init() {
|
||||
// Do nothing.
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl"
|
||||
)
|
||||
|
||||
func (g *Graphics) init() error {
|
||||
return gl.Init()
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gles"
|
||||
)
|
||||
|
||||
func (g *Graphics) init() {
|
||||
func (g *Graphics) init() error {
|
||||
g.context.ctx = gles.DefaultContext{}
|
||||
return nil
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ import (
|
||||
"syscall/js"
|
||||
)
|
||||
|
||||
func (g *Graphics) init() {
|
||||
func (g *Graphics) init() error {
|
||||
// Do nothing.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Graphics) SetCanvas(canvas js.Value) {
|
||||
|
Loading…
Reference in New Issue
Block a user