diff options
Diffstat (limited to 'src/renderer/mod.rs')
-rw-r--r-- | src/renderer/mod.rs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 3cad4a01..0dad716e 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -119,6 +119,8 @@ pub struct ShaderProgram { padding_x: f32, padding_y: f32, + + u_bg_opacity: GLint, } @@ -604,6 +606,7 @@ impl QuadRenderer { self.program.activate(); self.program.set_term_uniforms(props); self.program.set_visual_bell(visual_bell_intensity as _); + self.program.set_bg_opacity(config.background_opacity().get()); gl::BindVertexArray(self.vao); gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo); @@ -685,12 +688,13 @@ impl QuadRenderer { impl<'a> RenderApi<'a> { pub fn clear(&self, color: Rgb) { + let alpha = self.config.background_opacity().get(); unsafe { gl::ClearColor( - (self.visual_bell_intensity + color.r as f32 / 255.0).min(1.0), - (self.visual_bell_intensity + color.g as f32 / 255.0).min(1.0), - (self.visual_bell_intensity + color.b as f32 / 255.0).min(1.0), - 1.0 + (self.visual_bell_intensity + color.r as f32 / 255.0).min(1.0) * alpha, + (self.visual_bell_intensity + color.g as f32 / 255.0).min(1.0) * alpha, + (self.visual_bell_intensity + color.b as f32 / 255.0).min(1.0) * alpha, + alpha ); gl::Clear(gl::COLOR_BUFFER_BIT); } @@ -916,13 +920,14 @@ impl ShaderProgram { } // get uniform locations - let (projection, term_dim, cell_dim, visual_bell, background) = unsafe { + let (projection, term_dim, cell_dim, visual_bell, background, bg_opacity) = unsafe { ( gl::GetUniformLocation(program, cptr!(b"projection\0")), gl::GetUniformLocation(program, cptr!(b"termDim\0")), gl::GetUniformLocation(program, cptr!(b"cellDim\0")), gl::GetUniformLocation(program, cptr!(b"visualBell\0")), gl::GetUniformLocation(program, cptr!(b"backgroundPass\0")), + gl::GetUniformLocation(program, cptr!(b"bgOpacity\0")), ) }; @@ -937,6 +942,7 @@ impl ShaderProgram { u_background: background, padding_x: config.padding().x.floor(), padding_y: config.padding().y.floor(), + u_bg_opacity: bg_opacity, }; shader.update_projection(*size.width as f32, *size.height as f32); @@ -997,6 +1003,12 @@ impl ShaderProgram { } } + fn set_bg_opacity(&self, bg_opacity: f32) { + unsafe { + gl::Uniform1f(self.u_bg_opacity, bg_opacity); + } + } + fn create_program(vertex: GLuint, fragment: GLuint) -> GLuint { unsafe { let program = gl::CreateProgram(); |