diff --git a/ui/app/internal/gpu/context.go b/ui/app/internal/gpu/context.go index e3cf0cb9..00c9672c 100644 --- a/ui/app/internal/gpu/context.go +++ b/ui/app/internal/gpu/context.go @@ -18,6 +18,8 @@ type caps struct { // floatTriple holds the settings for floating point // textures. floatTriple textureTriple + // Single channel alpha textures. + alphaTriple textureTriple } // textureTriple holds the type settings for @@ -57,10 +59,20 @@ func newContext(glctx gl.Context) (*context, error) { EXT_disjoint_timer_query: strings.Contains(exts, "GL_EXT_disjoint_timer_query"), srgbMode: srgbMode, floatTriple: floatTriple, + alphaTriple: alphaTripleFor(ver), } return ctx, nil } +func alphaTripleFor(ver [2]int) textureTriple { + intf, f := gl.R8, gl.Enum(gl.RED) + if ver[0] < 3 { + // R8, RED not supported on OpenGL ES 2.0. + intf, f = gl.LUMINANCE, gl.Enum(gl.LUMINANCE) + } + return textureTriple{intf, f, gl.UNSIGNED_BYTE} +} + func floatTripleFor(ver [2]int, exts string) (textureTriple, error) { switch { case ver[0] >= 3: diff --git a/ui/app/internal/gpu/path.go b/ui/app/internal/gpu/path.go index 3450cece..380511e7 100644 --- a/ui/app/internal/gpu/path.go +++ b/ui/app/internal/gpu/path.go @@ -376,13 +376,8 @@ func loadLUT(ctx *context, lut *image.Gray) (gl.Texture, error) { if lut.Stride != lut.Bounds().Dx() { panic("unsupported LUT stride") } - ver, _ := gl.ParseGLVersion(ctx.GetString(gl.VERSION)) - intf, f := gl.R8, gl.RED - if ver[0] < 3 { - // R8, RED not supported on OpenGL ES 2.0. - intf, f = gl.LUMINANCE, gl.LUMINANCE - } - ctx.TexImage2D(gl.TEXTURE_2D, 0, intf, lut.Bounds().Dx(), lut.Bounds().Dy(), gl.Enum(f), gl.UNSIGNED_BYTE, lut.Pix) + tt := ctx.caps.alphaTriple + ctx.TexImage2D(gl.TEXTURE_2D, 0, tt.internalFormat, lut.Bounds().Dx(), lut.Bounds().Dy(), tt.format, tt.typ, lut.Pix) ctx.PixelStorei(gl.UNPACK_ALIGNMENT, 4) return tex, nil }