mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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 {
|
type contextImpl struct {
|
||||||
init bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) reset() error {
|
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.locationCache = newLocationCache()
|
||||||
c.lastTexture = invalidTexture
|
c.lastTexture = invalidTexture
|
||||||
c.lastFramebuffer = invalidFramebuffer
|
c.lastFramebuffer = invalidFramebuffer
|
||||||
|
@ -30,7 +30,9 @@ func NewGraphics() (graphicsdriver.Graphics, error) {
|
|||||||
return nil, fmt.Errorf("opengl: OpenGL is not supported on Xbox")
|
return nil, fmt.Errorf("opengl: OpenGL is not supported on Xbox")
|
||||||
}
|
}
|
||||||
g := &Graphics{}
|
g := &Graphics{}
|
||||||
g.init()
|
if err := g.init(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
func (g *Graphics) init() {
|
import (
|
||||||
// Do nothing.
|
"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"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gles"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Graphics) init() {
|
func (g *Graphics) init() error {
|
||||||
g.context.ctx = gles.DefaultContext{}
|
g.context.ctx = gles.DefaultContext{}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,9 @@ import (
|
|||||||
"syscall/js"
|
"syscall/js"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Graphics) init() {
|
func (g *Graphics) init() error {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) SetCanvas(canvas js.Value) {
|
func (g *Graphics) SetCanvas(canvas js.Value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user