From bb8d46a3fdf925b4b2fa9e7db76e48caf020b212 Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Mon, 10 Oct 2022 20:55:43 -0700 Subject: Fixed fragment shader compatibility issues with GLES 3.0+ --- glow/src/shader/common/gradient.frag | 26 +++++++++++++------------- glow/src/window/compositor.rs | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'glow/src') diff --git a/glow/src/shader/common/gradient.frag b/glow/src/shader/common/gradient.frag index 82c7e251..42d0201f 100644 --- a/glow/src/shader/common/gradient.frag +++ b/glow/src/shader/common/gradient.frag @@ -1,14 +1,14 @@ #ifdef GL_ES -#ifdef GL_FRAGMENT_PRECISION_HIGH -precision highp float; -#else -precision mediump float; -#endif + #ifdef GL_FRAGMENT_PRECISION_HIGH + precision highp float; + #else + precision mediump float; + #endif #endif #ifdef HIGHER_THAN_300 -layout (location = 0) out vec4 fragColor; -#define gl_FragColor fragColor + layout (location = 0) out vec4 fragColor; + #define gl_FragColor fragColor #endif in vec2 raw_position; @@ -31,11 +31,11 @@ void main() { fragColor = vec4(0.0, 0.0, 0.0, 0.0); float min_offset = color_stops[1].x; - float max_offset = color_stops[color_stops_size - 1].x; + float max_offset = color_stops[color_stops_size - 1u].x; - for (uint i = 0; i < color_stops_size - 2; i += 2) { - float curr_offset = color_stops[i+1].x; - float next_offset = color_stops[i+3].x; + for (uint i = 0u; i < color_stops_size - 2u; i += 2u) { + float curr_offset = color_stops[i+1u].x; + float next_offset = color_stops[i+3u].x; if (coord_offset <= min_offset) { //current coordinate is before the first defined offset, set it to the start color @@ -44,7 +44,7 @@ void main() { if (curr_offset <= coord_offset && coord_offset <= next_offset) { //current fragment is between the current offset processing & the next one, interpolate colors - fragColor = mix(color_stops[i], color_stops[i+2], smoothstep( + fragColor = mix(color_stops[i], color_stops[i+2u], smoothstep( curr_offset, next_offset, coord_offset @@ -53,7 +53,7 @@ void main() { if (coord_offset >= max_offset) { //current coordinate is before the last defined offset, set it to the last color - fragColor = color_stops[color_stops_size - 2]; + fragColor = color_stops[color_stops_size - 2u]; } } } diff --git a/glow/src/window/compositor.rs b/glow/src/window/compositor.rs index e9cf6015..6459dbce 100644 --- a/glow/src/window/compositor.rs +++ b/glow/src/window/compositor.rs @@ -26,7 +26,7 @@ impl iced_graphics::window::GLCompositor for Compositor { log::info!("{:#?}", settings); let version = gl.version(); - log::info!("OpenGL version: {:?} (Embedded: {}", version, version.is_embedded); + log::info!("OpenGL version: {:?} (Embedded: {})", version, version.is_embedded); let renderer = gl.get_parameter_string(glow::RENDERER); log::info!("Renderer: {}", renderer); -- cgit