internal/graphicsdriver/opengl: remove webGLVersion

This commit is contained in:
Hajime Hoshi 2022-11-17 12:27:26 +09:00
parent 74d9515345
commit 4082223aec
2 changed files with 9 additions and 25 deletions

View File

@ -46,14 +46,6 @@ const (
invalidUniform = -1
)
type webGLVersion int
const (
webGLVersionUnknown webGLVersion = iota
webGLVersion1
webGLVersion2
)
func webGL2MightBeAvailable() bool {
env := os.Getenv("EBITENGINE_OPENGL")
for _, t := range strings.Split(env, ",") {
@ -68,19 +60,13 @@ func webGL2MightBeAvailable() bool {
type contextImpl struct {
ctx gl.Context
canvas js.Value
webGLVersion webGLVersion
webGL2 bool
fnGetExtension js.Value
fnIsContextLost js.Value
}
func (c *context) usesWebGL2() bool {
return c.webGLVersion == webGLVersion2
}
func (c *context) initGL() error {
c.webGLVersion = webGLVersionUnknown
var glContext js.Value
if doc := js.Global().Get("document"); doc.Truthy() {
@ -93,7 +79,7 @@ func (c *context) initGL() error {
if webGL2MightBeAvailable() {
glContext = canvas.Call("getContext", "webgl2", attr)
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)
}
if glContext.Truthy() {
c.webGLVersion = webGLVersion1
c.webGL2 = false
}
}
if !glContext.Truthy() {
c.webGL2 = false
return fmt.Errorf("opengl: getContext failed")
}
}
@ -146,7 +133,7 @@ func (c *context) reset() error {
f := c.ctx.GetInteger(gl.FRAMEBUFFER_BINDING)
c.screenFramebuffer = framebufferNative(f)
if !c.usesWebGL2() {
if !c.webGL2 {
c.fnGetExtension.Invoke("OES_standard_derivatives")
}
return nil

View File

@ -19,11 +19,8 @@ import (
)
func (c *context) glslVersion() glsl.GLSLVersion {
switch c.webGLVersion {
case webGLVersion1:
return glsl.GLSLVersionES100
case webGLVersion2:
if c.webGL2 {
return glsl.GLSLVersionES300
}
panic("opengl: WebGL context is not initialized yet at glslVersion")
return glsl.GLSLVersionES100
}