Skip to content

Commit 2105d79

Browse files
Nopeyhacknus
authored andcommitted
egui_glow: Only disable sRGB framebuffer on supported platforms (emilk#3994)
This solves a GL_INVALID_ENUM error common on Windows (occurs on my Windows 10 machine with a GTX 1070 Ti). <!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to add commits to your PR. * Remember to run `cargo fmt` and `cargo cranky`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> ARB_framebuffer_SRGB is entirely unsupported on WebGL, hence why latest egui (master branch) doesn't try to disable SRGB framebuffers on wasm32 and this PR's code doesn't even check for ARB_framebuffer_sRGB on wasm32. * For <servo/servo#30782>
1 parent dfb2358 commit 2105d79

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/egui_glow/src/painter.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub struct Painter {
8686
is_webgl_1: bool,
8787
vao: crate::vao::VertexArrayObject,
8888
srgb_textures: bool,
89+
supports_srgb_framebuffer: bool,
8990
vbo: glow::Buffer,
9091
element_array_buffer: glow::Buffer,
9192

@@ -173,6 +174,13 @@ impl Painter {
173174
});
174175
log::debug!("SRGB texture Support: {:?}", srgb_textures);
175176

177+
let supports_srgb_framebuffer = !cfg!(target_arch = "wasm32")
178+
&& supported_extensions.iter().any(|extension| {
179+
// {GL,GLX,WGL}_ARB_framebuffer_sRGB, …
180+
extension.ends_with("ARB_framebuffer_sRGB")
181+
});
182+
log::debug!("SRGB framebuffer Support: {:?}", supports_srgb_framebuffer);
183+
176184
unsafe {
177185
let vert = compile_shader(
178186
&gl,
@@ -253,6 +261,7 @@ impl Painter {
253261
is_webgl_1,
254262
vao,
255263
srgb_textures,
264+
supports_srgb_framebuffer,
256265
vbo,
257266
element_array_buffer,
258267
textures: Default::default(),
@@ -314,7 +323,7 @@ impl Painter {
314323
glow::ONE,
315324
);
316325

317-
if !cfg!(target_arch = "wasm32") {
326+
if self.supports_srgb_framebuffer {
318327
self.gl.disable(glow::FRAMEBUFFER_SRGB);
319328
check_for_gl_error!(&self.gl, "FRAMEBUFFER_SRGB");
320329
}

0 commit comments

Comments
 (0)