From d73d3b448094688bcc8cd543d5cfdbf282b43d2d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 9 Sep 2018 21:52:48 -0400 Subject: [PATCH] Adds a left border to complement the right. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 4 +++- Outputs/CRT/Internals/CRTOpenGL.hpp | 1 + Outputs/CRT/Internals/Shaders/OutputShader.cpp | 5 +++++ Outputs/CRT/Internals/Shaders/OutputShader.hpp | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index 6510dc471..2342ccb99 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -228,7 +228,8 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out last_output_width_ = output_width; last_output_height_ = output_height; - // Configure a right gutter to crop the right-hand 2% of the display. + // Configure right and left gutters to crop the left- and right-hand 1% of the display. + left_overlay_.reset(new OpenGL::Rectangle(output_shader_program_->get_left_extent() * 0.98f, -1.0f, -1.0f, 2.0f)); right_overlay_.reset(new OpenGL::Rectangle(output_shader_program_->get_right_extent() * 0.98f, -1.0f, 1.0f, 2.0f)); } output_shader_program_->bind(); @@ -238,6 +239,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out // mask off the gutter glDisable(GL_BLEND); + left_overlay_->draw(0.0, 0.0, 0.0); right_overlay_->draw(0.0, 0.0, 0.0); } diff --git a/Outputs/CRT/Internals/CRTOpenGL.hpp b/Outputs/CRT/Internals/CRTOpenGL.hpp index b0c554eff..c50ac4560 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.hpp +++ b/Outputs/CRT/Internals/CRTOpenGL.hpp @@ -118,6 +118,7 @@ class OpenGLOutputBuilder { // The fix: just always treat that area as invisible. This is acceptable thanks to // the concept of overscan. One is allowed not to display extreme ends of the image. std::unique_ptr right_overlay_; + std::unique_ptr left_overlay_; public: // These two are protected by output_mutex_. diff --git a/Outputs/CRT/Internals/Shaders/OutputShader.cpp b/Outputs/CRT/Internals/Shaders/OutputShader.cpp index bad5bc1d5..91ec8049a 100644 --- a/Outputs/CRT/Internals/Shaders/OutputShader.cpp +++ b/Outputs/CRT/Internals/Shaders/OutputShader.cpp @@ -96,6 +96,7 @@ void OutputShader::set_output_size(unsigned int output_width, unsigned int outpu GLfloat outputAspectRatioMultiplier = (static_cast(output_width) / static_cast(output_height)) / (4.0f / 3.0f); GLfloat bonusWidth = (outputAspectRatioMultiplier - 1.0f) * visible_area.size.width; + left_extent_ = (-1.0f / outputAspectRatioMultiplier) / visible_area.size.width; right_extent_ = (1.0f / outputAspectRatioMultiplier) / visible_area.size.width; visible_area.origin.x -= bonusWidth * 0.5f; @@ -105,6 +106,10 @@ void OutputShader::set_output_size(unsigned int output_width, unsigned int outpu set_uniform("boundsSize", (GLfloat)visible_area.size.width, (GLfloat)visible_area.size.height); } +float OutputShader::get_left_extent() { + return left_extent_; +} + float OutputShader::get_right_extent() { return right_extent_; } diff --git a/Outputs/CRT/Internals/Shaders/OutputShader.hpp b/Outputs/CRT/Internals/Shaders/OutputShader.hpp index 2ca65b572..5a43832d2 100644 --- a/Outputs/CRT/Internals/Shaders/OutputShader.hpp +++ b/Outputs/CRT/Internals/Shaders/OutputShader.hpp @@ -88,12 +88,18 @@ public: */ void set_input_width_scaler(float input_scaler); + /*! + @returns The location, in eye coordinates, of the left edge of the output area. + */ + float get_left_extent(); + /*! @returns The location, in eye coordinates, of the right edge of the output area. */ float get_right_extent(); private: + float left_extent_ = 0.0f; float right_extent_ = 0.0f; };