egui_glow: Only disable sRGB framebuffer on supported platforms (#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>
This commit is contained in:
parent
377f86efb5
commit
21f08afcbb
|
|
@ -86,6 +86,7 @@ pub struct Painter {
|
|||
is_webgl_1: bool,
|
||||
vao: crate::vao::VertexArrayObject,
|
||||
srgb_textures: bool,
|
||||
supports_srgb_framebuffer: bool,
|
||||
vbo: glow::Buffer,
|
||||
element_array_buffer: glow::Buffer,
|
||||
|
||||
|
|
@ -173,6 +174,13 @@ impl Painter {
|
|||
});
|
||||
log::debug!("SRGB texture Support: {:?}", srgb_textures);
|
||||
|
||||
let supports_srgb_framebuffer = !cfg!(target_arch = "wasm32")
|
||||
&& supported_extensions.iter().any(|extension| {
|
||||
// {GL,GLX,WGL}_ARB_framebuffer_sRGB, …
|
||||
extension.ends_with("ARB_framebuffer_sRGB")
|
||||
});
|
||||
log::debug!("SRGB framebuffer Support: {:?}", supports_srgb_framebuffer);
|
||||
|
||||
unsafe {
|
||||
let vert = compile_shader(
|
||||
&gl,
|
||||
|
|
@ -253,6 +261,7 @@ impl Painter {
|
|||
is_webgl_1,
|
||||
vao,
|
||||
srgb_textures,
|
||||
supports_srgb_framebuffer,
|
||||
vbo,
|
||||
element_array_buffer,
|
||||
textures: Default::default(),
|
||||
|
|
@ -314,7 +323,7 @@ impl Painter {
|
|||
glow::ONE,
|
||||
);
|
||||
|
||||
if !cfg!(target_arch = "wasm32") {
|
||||
if self.supports_srgb_framebuffer {
|
||||
self.gl.disable(glow::FRAMEBUFFER_SRGB);
|
||||
check_for_gl_error!(&self.gl, "FRAMEBUFFER_SRGB");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue