From b86c1ff9edbbc0fe28d77b4a247a1cb7ff596183 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Mon, 29 Jan 2018 23:01:46 +0100 Subject: [PATCH] Switch viewport before rendering rectangles To make sure it is possible to draw over the complete window, the viewport is removed before rendering rectangles now. This makes the visual bell behave properly and flash over the padding of the terminal too, instead of just flashing the grid. However when rendering a rectangle now, the padding has to be taken into consideration. --- src/renderer/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index d08095f7..7c3328f9 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -675,6 +675,9 @@ impl QuadRenderer { // Swap program gl::UseProgram(self.rect_program.id); + // Remove padding from viewport + gl::Viewport(0, 0, props.width as i32, props.height as i32); + // Change blending strategy gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA); @@ -707,6 +710,13 @@ impl QuadRenderer { gl::BindBuffer(gl::ARRAY_BUFFER, 0); gl::BindVertexArray(0); + // Add padding to viewport again + let x_pad = config.padding().x as i32; + let y_pad = config.padding().y as i32; + let width = props.width as i32; + let height = props.height as i32; + gl::Viewport(x_pad, y_pad, width - 2 * y_pad, height - 2 * y_pad); + // Disable program gl::UseProgram(0); }