diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index ddefdcfa2..baf99f97b 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -188,6 +188,16 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out defaultFramebuffer = 0; } + // lock down any further work on the current frame + _output_mutex->lock(); + + // release the mapping, giving up on trying to draw if data has been lost + glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, source_array_buffer); + glUnmapBuffer(GL_ARRAY_BUFFER); + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + // make sure there's a target to draw to if(!framebuffer || framebuffer->get_height() != output_height || framebuffer->get_width() != output_width) { @@ -203,16 +213,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _input_texture_array); } - // lock down any further work on the current frame - _output_mutex->lock(); - - // release the mapping, giving up on trying to draw if data has been lost - glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer); - glUnmapBuffer(GL_ARRAY_BUFFER); - glBindBuffer(GL_ARRAY_BUFFER, source_array_buffer); - glUnmapBuffer(GL_ARRAY_BUFFER); - glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); - // upload more source pixel data if any; we'll always resubmit the last line submitted last // time as it may have had extra data appended to it if(_buffer_builder->_write_y_position < _buffer_builder->last_uploaded_line) diff --git a/Outputs/CRT/Internals/TextureTarget.cpp b/Outputs/CRT/Internals/TextureTarget.cpp index 9391dbfc1..de1348b32 100644 --- a/Outputs/CRT/Internals/TextureTarget.cpp +++ b/Outputs/CRT/Internals/TextureTarget.cpp @@ -75,7 +75,6 @@ void TextureTarget::draw(float aspect_ratio) "texCoordVarying = texCoord;" "gl_Position = vec4(position, 0.0, 1.0);" "}"; - const char *fragment_shader = "#version 150\n" @@ -85,7 +84,7 @@ void TextureTarget::draw(float aspect_ratio) "void main(void)" "{" - "fragColour = vec4(0.5);"//texture(texID, texCoordVarying);" + "fragColour = texture(texID, texCoordVarying);" "}"; _pixel_shader = std::unique_ptr(new Shader(vertex_shader, fragment_shader, nullptr)); @@ -127,18 +126,18 @@ void TextureTarget::draw(float aspect_ratio) if(aspect_ratio_ratio >= 1.0f) { // output is thinner than we are; letterbox - fl_buffer[0] = -1.0f; fl_buffer[1] = 1.0f / aspect_ratio_ratio; - fl_buffer[3] = -1.0f; fl_buffer[4] = -1.0f / aspect_ratio_ratio; - fl_buffer[6] = 1.0f; fl_buffer[7] = 1.0f / aspect_ratio_ratio; - fl_buffer[9] = 1.0f; fl_buffer[10] = -1.0f / aspect_ratio_ratio; + fl_buffer[0] = -1.0f; fl_buffer[1] = -1.0f / aspect_ratio_ratio; + fl_buffer[3] = 1.0f; fl_buffer[4] = -1.0f / aspect_ratio_ratio; + fl_buffer[6] = -1.0f; fl_buffer[7] = 1.0f / aspect_ratio_ratio; + fl_buffer[9] = 1.0f; fl_buffer[10] = 1.0f / aspect_ratio_ratio; } else { // output is wider than we are; pillarbox - fl_buffer[0] = -aspect_ratio_ratio; fl_buffer[1] = 1.0f; - fl_buffer[3] = -aspect_ratio_ratio; fl_buffer[4] = -1.0f; - fl_buffer[6] = aspect_ratio_ratio; fl_buffer[7] = 1.0f; - fl_buffer[9] = aspect_ratio_ratio; fl_buffer[10] = -1.0f; + fl_buffer[0] = -aspect_ratio_ratio; fl_buffer[1] = -1.0f; + fl_buffer[3] = aspect_ratio_ratio; fl_buffer[4] = -1.0f; + fl_buffer[6] = -aspect_ratio_ratio; fl_buffer[7] = 1.0f; + fl_buffer[9] = aspect_ratio_ratio; fl_buffer[10] = 1.0f; } // upload buffer @@ -146,6 +145,7 @@ void TextureTarget::draw(float aspect_ratio) glBufferData(GL_ARRAY_BUFFER, sizeof(buffer), buffer, GL_STATIC_DRAW); } + _pixel_shader->bind(); glBindVertexArray(_drawing_vertex_array); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); }