mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
internal/graphicsdriver/opengl: remove webGLVersion
This commit is contained in:
parent
74d9515345
commit
4082223aec
@ -46,14 +46,6 @@ const (
|
|||||||
invalidUniform = -1
|
invalidUniform = -1
|
||||||
)
|
)
|
||||||
|
|
||||||
type webGLVersion int
|
|
||||||
|
|
||||||
const (
|
|
||||||
webGLVersionUnknown webGLVersion = iota
|
|
||||||
webGLVersion1
|
|
||||||
webGLVersion2
|
|
||||||
)
|
|
||||||
|
|
||||||
func webGL2MightBeAvailable() bool {
|
func webGL2MightBeAvailable() bool {
|
||||||
env := os.Getenv("EBITENGINE_OPENGL")
|
env := os.Getenv("EBITENGINE_OPENGL")
|
||||||
for _, t := range strings.Split(env, ",") {
|
for _, t := range strings.Split(env, ",") {
|
||||||
@ -66,21 +58,15 @@ func webGL2MightBeAvailable() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type contextImpl struct {
|
type contextImpl struct {
|
||||||
ctx gl.Context
|
ctx gl.Context
|
||||||
canvas js.Value
|
canvas js.Value
|
||||||
webGLVersion webGLVersion
|
webGL2 bool
|
||||||
|
|
||||||
fnGetExtension js.Value
|
fnGetExtension js.Value
|
||||||
fnIsContextLost js.Value
|
fnIsContextLost js.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) usesWebGL2() bool {
|
|
||||||
return c.webGLVersion == webGLVersion2
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *context) initGL() error {
|
func (c *context) initGL() error {
|
||||||
c.webGLVersion = webGLVersionUnknown
|
|
||||||
|
|
||||||
var glContext js.Value
|
var glContext js.Value
|
||||||
|
|
||||||
if doc := js.Global().Get("document"); doc.Truthy() {
|
if doc := js.Global().Get("document"); doc.Truthy() {
|
||||||
@ -93,7 +79,7 @@ func (c *context) initGL() error {
|
|||||||
if webGL2MightBeAvailable() {
|
if webGL2MightBeAvailable() {
|
||||||
glContext = canvas.Call("getContext", "webgl2", attr)
|
glContext = canvas.Call("getContext", "webgl2", attr)
|
||||||
if glContext.Truthy() {
|
if glContext.Truthy() {
|
||||||
c.webGLVersion = webGLVersion2
|
c.webGL2 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,11 +90,12 @@ func (c *context) initGL() error {
|
|||||||
glContext = canvas.Call("getContext", "experimental-webgl", attr)
|
glContext = canvas.Call("getContext", "experimental-webgl", attr)
|
||||||
}
|
}
|
||||||
if glContext.Truthy() {
|
if glContext.Truthy() {
|
||||||
c.webGLVersion = webGLVersion1
|
c.webGL2 = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !glContext.Truthy() {
|
if !glContext.Truthy() {
|
||||||
|
c.webGL2 = false
|
||||||
return fmt.Errorf("opengl: getContext failed")
|
return fmt.Errorf("opengl: getContext failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +133,7 @@ func (c *context) reset() error {
|
|||||||
f := c.ctx.GetInteger(gl.FRAMEBUFFER_BINDING)
|
f := c.ctx.GetInteger(gl.FRAMEBUFFER_BINDING)
|
||||||
c.screenFramebuffer = framebufferNative(f)
|
c.screenFramebuffer = framebufferNative(f)
|
||||||
|
|
||||||
if !c.usesWebGL2() {
|
if !c.webGL2 {
|
||||||
c.fnGetExtension.Invoke("OES_standard_derivatives")
|
c.fnGetExtension.Invoke("OES_standard_derivatives")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -19,11 +19,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *context) glslVersion() glsl.GLSLVersion {
|
func (c *context) glslVersion() glsl.GLSLVersion {
|
||||||
switch c.webGLVersion {
|
if c.webGL2 {
|
||||||
case webGLVersion1:
|
|
||||||
return glsl.GLSLVersionES100
|
|
||||||
case webGLVersion2:
|
|
||||||
return glsl.GLSLVersionES300
|
return glsl.GLSLVersionES300
|
||||||
}
|
}
|
||||||
panic("opengl: WebGL context is not initialized yet at glslVersion")
|
return glsl.GLSLVersionES100
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user