From ef0dbc2a419f4c65ebd13f56e74a4aba526a1cab Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 15 Jan 2019 21:33:30 -0500 Subject: [PATCH] Undoes hard-coding of target framebuffer and display gamma. --- Outputs/OpenGL/ScanTarget.cpp | 12 +++++++----- Outputs/OpenGL/ScanTarget.hpp | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Outputs/OpenGL/ScanTarget.cpp b/Outputs/OpenGL/ScanTarget.cpp index 59f37469c..74f7723df 100644 --- a/Outputs/OpenGL/ScanTarget.cpp +++ b/Outputs/OpenGL/ScanTarget.cpp @@ -60,7 +60,9 @@ template void ScanTarget::allocate_buffer(const T &array, GLuint &b glBindBuffer(GL_ARRAY_BUFFER, buffer_name); } -ScanTarget::ScanTarget() : +ScanTarget::ScanTarget(GLuint target_framebuffer, float output_gamma) : + target_framebuffer_(target_framebuffer), + output_gamma_(output_gamma), unprocessed_line_texture_(LineBufferWidth, LineBufferHeight, UnprocessedLineBufferTextureUnit, GL_NEAREST, false), full_display_rectangle_(-1.0f, -1.0f, 2.0f, 2.0f) { @@ -285,8 +287,8 @@ void ScanTarget::setup_pipeline() { // lose any detail when combining the input. processing_width_ = modals_.cycles_per_line / modals_.clocks_per_pixel_greatest_common_divisor; - // Establish an output shader. TODO: don't hard-code gamma. - output_shader_ = conversion_shader(modals_.input_data_type, modals_.display_type, modals_.composite_colour_space, 2.2f / modals_.intended_gamma, modals_.brightness); + // Establish an output shader. + output_shader_ = conversion_shader(modals_.input_data_type, modals_.display_type, modals_.composite_colour_space, output_gamma_ / modals_.intended_gamma, modals_.brightness); glBindVertexArray(line_vertex_array_); glBindBuffer(GL_ARRAY_BUFFER, line_buffer_name_); enable_vertex_attributes(ShaderType::Conversion, *output_shader_); @@ -540,8 +542,8 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) { glDisable(GL_BLEND); } - // Copy the accumulatiion texture to the target (TODO: don't assume framebuffer 0). - glBindFramebuffer(GL_FRAMEBUFFER, 0); + // Copy the accumulatiion texture to the target. + glBindFramebuffer(GL_FRAMEBUFFER, target_framebuffer_); glViewport(0, 0, (GLsizei)output_width, (GLsizei)output_height); glClear(GL_COLOR_BUFFER_BIT); diff --git a/Outputs/OpenGL/ScanTarget.hpp b/Outputs/OpenGL/ScanTarget.hpp index 10dc4dbf9..36c6967e4 100644 --- a/Outputs/OpenGL/ScanTarget.hpp +++ b/Outputs/OpenGL/ScanTarget.hpp @@ -35,7 +35,7 @@ namespace OpenGL { */ class ScanTarget: public Outputs::Display::ScanTarget { public: - ScanTarget(); + ScanTarget(GLuint target_framebuffer = 0, float output_gamma = 2.2f); ~ScanTarget(); void draw(bool synchronous, int output_width, int output_height); @@ -46,6 +46,9 @@ class ScanTarget: public Outputs::Display::ScanTarget { static constexpr int LineBufferWidth = 2048; static constexpr int LineBufferHeight = 2048; + const GLuint target_framebuffer_; + const float output_gamma_; + // Outputs::Display::ScanTarget overrides. void set_modals(Modals) override; Scan *begin_scan() override;