ui/app/internal/gl: move single channel format detection to context

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-05-04 14:48:10 +02:00
parent f5fa968038
commit 871ae34be5
2 changed files with 14 additions and 7 deletions
+2 -7
View File
@@ -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
}