abstreet/widgetry/shaders/fragment_140.glsl

19 lines
385 B
Plaintext
Raw Normal View History

Fix glow backend on mac Without this change, the screen was blank when using the glow backend on macos. Some debugging traced it down to the shader attribute configuration. @dabreegster suggested trying to declare a newer version of the shader language which supports the syntax for explicit attribute layout, which fixed it. Specifically, before this commit, this diff was interesting on macos: diff --git a/ezgui/src/backend_glow.rs b/ezgui/src/backend_glow.rs index 2046bccd..f834a4fa 100644 --- a/ezgui/src/backend_glow.rs +++ b/ezgui/src/backend_glow.rs @@ -244,31 +244,7 @@ impl PrerenderInnards { glow::FLOAT, false, stride, - // WTF: this offset seems correct, but on macos (OpenGL 4.1) - // a blank screen is rendered. - // - // To debug, I've hardcoded a color assignment in the fragment shader. - // - // What's fascinating is that, even if we don't use this second "style" - // input for anything, the mere act of passing it in with the expected - // offset causes all the geometries to not be visible. - // - // That is: - // - with a hardcoded color in the fragment shader - // - set offset `0` here (which is surely wrong?) - // - I can see the correct shapes with my hardcoded color - // - // - with a hardcoded color in the fragment shader - // - set offset `2*size_of(f32)` here (which should be right) - // - I'd expect to see the correct shapes with my hardcoded color - // - But instead I can no longer see any shapes on the screen - // - // So it seems like something about setting the offset on this second attribute - // configuration is corrupting our vertex data, even if we never read from that - // attribute data. - // - // 2 * std::mem::size_of::<f32>() as i32, - 0 + 2 * std::mem::size_of::<f32>() as i32, );
2020-08-19 18:30:20 +03:00
#version 410
// (x offset, y offset, zoom)
uniform vec3 transform;
// (window width, window height, z value)
uniform vec3 window;
// textures grid
uniform sampler2DArray textures;
in vec4 fs_color;
in vec3 fs_texture_coord;
out vec4 out_color;
void main() {
vec4 x = fs_color * texture(textures, fs_texture_coord);
out_color = vec4(x.a * x.r, x.a * x.g, x.a * x.b, x.a);
}