mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
ui/app/internal/gl: move single channel format detection to context
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -18,6 +18,8 @@ type caps struct {
|
|||||||
// floatTriple holds the settings for floating point
|
// floatTriple holds the settings for floating point
|
||||||
// textures.
|
// textures.
|
||||||
floatTriple textureTriple
|
floatTriple textureTriple
|
||||||
|
// Single channel alpha textures.
|
||||||
|
alphaTriple textureTriple
|
||||||
}
|
}
|
||||||
|
|
||||||
// textureTriple holds the type settings for
|
// 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"),
|
EXT_disjoint_timer_query: strings.Contains(exts, "GL_EXT_disjoint_timer_query"),
|
||||||
srgbMode: srgbMode,
|
srgbMode: srgbMode,
|
||||||
floatTriple: floatTriple,
|
floatTriple: floatTriple,
|
||||||
|
alphaTriple: alphaTripleFor(ver),
|
||||||
}
|
}
|
||||||
return ctx, nil
|
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) {
|
func floatTripleFor(ver [2]int, exts string) (textureTriple, error) {
|
||||||
switch {
|
switch {
|
||||||
case ver[0] >= 3:
|
case ver[0] >= 3:
|
||||||
|
|||||||
@@ -376,13 +376,8 @@ func loadLUT(ctx *context, lut *image.Gray) (gl.Texture, error) {
|
|||||||
if lut.Stride != lut.Bounds().Dx() {
|
if lut.Stride != lut.Bounds().Dx() {
|
||||||
panic("unsupported LUT stride")
|
panic("unsupported LUT stride")
|
||||||
}
|
}
|
||||||
ver, _ := gl.ParseGLVersion(ctx.GetString(gl.VERSION))
|
tt := ctx.caps.alphaTriple
|
||||||
intf, f := gl.R8, gl.RED
|
ctx.TexImage2D(gl.TEXTURE_2D, 0, tt.internalFormat, lut.Bounds().Dx(), lut.Bounds().Dy(), tt.format, tt.typ, lut.Pix)
|
||||||
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)
|
|
||||||
ctx.PixelStorei(gl.UNPACK_ALIGNMENT, 4)
|
ctx.PixelStorei(gl.UNPACK_ALIGNMENT, 4)
|
||||||
return tex, nil
|
return tex, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user