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
+12
View File
@@ -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: