From d8f8740574ce693de541b071de382a5be94f6ce9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 28 Jul 2021 13:47:05 +0200 Subject: [PATCH] gpu/internal/opengl: use the linear colorspace when EXT_sRGB is missing The SRGBFBO emulates a framebuffer in the sRGB colorspace. However, some low-end devices may not have EXT_sRGB support to store framebuffer content in sRGB. This change handles missing EXT_sRGB support by falling back to the linear RGB colorspace. Falling back loses color precision but is better than failing. Updates gio#49 Updates gio#154 Updates gio#97 Updates gio#36 Updates gio#172 Signed-off-by: Elias Naur --- gpu/internal/opengl/srgb.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gpu/internal/opengl/srgb.go b/gpu/internal/opengl/srgb.go index 233f1b85..ff392343 100644 --- a/gpu/internal/opengl/srgb.go +++ b/gpu/internal/opengl/srgb.go @@ -38,7 +38,8 @@ func NewSRGBFBO(f *gl.Functions, state *glState) (*SRGBFBO, error) { exts := strings.Split(f.GetString(gl.EXTENSIONS), " ") srgbTriple, err := srgbaTripleFor(ver, exts) if err != nil { - return nil, fmt.Errorf("srgb: missing sRGB format support") + // Fall back to the linear RGB colorspace, at the cost of color precision loss. + srgbTriple = textureTriple{gl.RGBA, gl.Enum(gl.RGBA), gl.Enum(gl.UNSIGNED_BYTE)} } s := &SRGBFBO{ c: f,