glium
glium copied to clipboard
Texture seems to be brighter on MacOS
as shown above texture is displaying correctly on Windows but brighter on MacOS.
image is loaded by
let image = image::load(Cursor::new(&include_bytes!("car.png")[..]), image::PNG)
.unwrap()
.to_rgba();
let image_dimensions = image.dimensions();
let image = glium::texture::RawImage2d::from_raw_rgba_reversed(&image.into_raw(), image_dimensions);
let texture = glium::texture::Texture2d::new(&display, image).unwrap();
Using almost the same code from the tutorial examples. And I haven't seen this problem with raw OpenGL or other wrappers. What could be the cause?
I changed to glium::texture::SrgbTexture2d
and it's not bright anymore, but I'm still getting some extra pixels.
original image: in glium app:
I just found that the extra pixels are caused by gl::Enable(gl::DEPTH_TEST);
but still don't know how to solve it..
edit:
it's not caused by gl::Enable(gl::DEPTH_TEST);
, it's caused by gl::Enable(gl::BLEND | gl::DEPTH_TEST);
(using as bitflags), which is not how it's supposed to be used, but I don't find any of this in glium's code, so still no clue
@slmjkdbtl I wonder if it's related to how transparency is handled or depth buffer?
In addition to the colors, surfaces can also have a depth buffer attached to it. In this situation, just like each pixel has a color, each pixel of the surface also has an associated depth value.
If a depth buffer is present, the GPU will compare the depth value of the pixel currently being processed, with the existing depth value. Depending on the value of depth_test in the draw parameters, the depth test will either pass, in which case the pipeline continues, or fail, in which case the pixel is discarded. If the value of depth_write is true and the test passed, it will then also write the depth value of the pixel on the depth buffer.
The purpose of this test is to avoid drawing elements that are in the background of the scene over elements that are in the foreground.
See the documentation of DepthTest for more informations.