diff options
Diffstat (limited to '')
| -rw-r--r-- | glow/src/quad.rs | 11 | ||||
| -rw-r--r-- | glow/src/shader/quad.frag | 9 | 
2 files changed, 17 insertions, 3 deletions
| diff --git a/glow/src/quad.rs b/glow/src/quad.rs index fd71757f..acac3219 100644 --- a/glow/src/quad.rs +++ b/glow/src/quad.rs @@ -12,6 +12,7 @@ pub struct Pipeline {      instances: <glow::Context as HasContext>::Buffer,      current_transform: Transformation,      current_scale: f32, +    current_target_height: u32,  }  impl Pipeline { @@ -35,6 +36,7 @@ impl Pipeline {                  &Transformation::identity().into(),              );              gl.uniform_1_f32(Some(1), 1.0); +            gl.uniform_1_f32(Some(2), 0.0);              gl.use_program(None);          } @@ -48,6 +50,7 @@ impl Pipeline {              instances,              current_transform: Transformation::identity(),              current_scale: 1.0, +            current_target_height: 0,          }      } @@ -94,6 +97,14 @@ impl Pipeline {              self.current_scale = scale;          } +        if target_height != self.current_target_height { +            unsafe { +                gl.uniform_1_f32(Some(2), target_height as f32); +            } + +            self.current_target_height = target_height; +        } +          let mut i = 0;          let total = instances.len(); diff --git a/glow/src/shader/quad.frag b/glow/src/shader/quad.frag index d9e74664..17e7216f 100644 --- a/glow/src/shader/quad.frag +++ b/glow/src/shader/quad.frag @@ -1,6 +1,7 @@  #version 450 -layout(origin_upper_left) in vec4 gl_FragCoord; +layout(location = 2) uniform float u_Screen_Height; +  layout(location = 0) in vec4 v_Color;  layout(location = 1) in vec4 v_BorderColor;  layout(location = 2) in vec2 v_Pos; @@ -31,12 +32,14 @@ float distance(in vec2 frag_coord, in vec2 position, in vec2 size, float radius)  void main() {      vec4 mixed_color; +    vec2 fragCoord = vec2(gl_FragCoord.x, u_Screen_Height - gl_FragCoord.y); +      // TODO: Remove branching (?)      if(v_BorderWidth > 0) {          float internal_border = max(v_BorderRadius - v_BorderWidth, 0);          float internal_distance = distance( -            gl_FragCoord.xy, +            fragCoord,              v_Pos + vec2(v_BorderWidth),              v_Scale - vec2(v_BorderWidth * 2.0),              internal_border @@ -54,7 +57,7 @@ void main() {      }      float d = distance( -        gl_FragCoord.xy, +        fragCoord,          v_Pos,          v_Scale,          v_BorderRadius | 
