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
|
2019-01-23 01:34:11 +03:00
|
|
|
|
2019-05-13 04:05:14 +03:00
|
|
|
// (x offset, y offset, zoom)
|
|
|
|
uniform vec3 transform;
|
2020-09-18 04:38:55 +03:00
|
|
|
// (window width, window height, z value)
|
2019-05-13 04:05:14 +03:00
|
|
|
uniform vec3 window;
|
2020-09-18 04:38:55 +03:00
|
|
|
// textures grid
|
|
|
|
uniform sampler2DArray textures;
|
2019-05-13 04:05:14 +03:00
|
|
|
|
2020-09-18 04:38:55 +03:00
|
|
|
in vec4 fs_color;
|
|
|
|
in vec3 fs_texture_coord;
|
2019-01-23 01:34:11 +03:00
|
|
|
|
2020-09-18 04:38:55 +03:00
|
|
|
out vec4 out_color;
|
2020-06-28 02:19:48 +03:00
|
|
|
|
2020-09-18 04:38:55 +03:00
|
|
|
void main() {
|
2021-01-06 05:28:30 +03:00
|
|
|
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);
|
2021-08-06 01:37:49 +03:00
|
|
|
|
|
|
|
// Enable this to quickly see everything in greyscale.
|
|
|
|
// https://en.wikipedia.org/wiki/Grayscale#Luma_coding_in_video_systems
|
|
|
|
//float gray = dot(fs_color.rgb, vec3(0.299, 0.587, 0.114));
|
|
|
|
//out_color = vec4(vec3(gray), fs_color.a);
|
2019-01-23 01:34:11 +03:00
|
|
|
}
|