From b4159295f61d1789d6a1317afe54128a531020fd Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 11 Jan 2017 21:18:41 -0500 Subject: [PATCH] Switched to using quads for intermediate draws. The specific concern is the flexibility offered in the GL spec as to line drawing algorithms. And even if a driver implements exactly to spec then it should omit the final pixel. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 2 +- Outputs/CRT/Internals/Shaders/IntermediateShader.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index ab0597e10..9938d58f1 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -206,7 +206,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // draw - glDrawArraysInstanced(GL_LINES, 0, 2, (GLsizei)array_submission.input_size / SourceVertexSize); + glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, (GLsizei)array_submission.input_size / SourceVertexSize); active_pipeline++; #ifdef GL_NV_texture_barrier diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index b4a93a1e0..870eef24f 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -58,6 +58,7 @@ std::unique_ptr IntermediateShader::make_shader(const char * "{" // odd vertices are on the left, even on the right "float extent = float(gl_VertexID & 1);" + "float longitudinal = float((gl_VertexID & 2) >> 1);" // inputPosition.x is either inputStart.x or ends.x, depending on whether it is on the left or the right; // outputPosition.x is either outputStart.x or ends.y; @@ -65,6 +66,9 @@ std::unique_ptr IntermediateShader::make_shader(const char * "vec2 inputPosition = vec2(mix(inputStart.x, ends.x, extent)*widthScalers[0], inputStart.y + inputVerticalOffset);" "vec2 outputPosition = vec2(mix(outputStart.x, ends.y, extent)*widthScalers[1], outputStart.y + outputVerticalOffset);" + "inputPosition.y += longitudinal;" + "outputPosition.y += longitudinal;" + // extension is the amount to extend both the input and output by to add a full colour cycle at each end "vec2 extensionVector = vec2(extension, 0.0) * 2.0 * (extent - 0.5);" @@ -75,7 +79,7 @@ std::unique_ptr IntermediateShader::make_shader(const char * // keep iInputPositionVarying in whole source pixels, scale mappedInputPosition to the ordinary normalised range "vec2 textureSize = vec2(textureSize(texID, 0));" "iInputPositionVarying = extendedInputPosition;" - "vec2 mappedInputPosition = (extendedInputPosition) / textureSize;" // + vec2(0.0, 0.5) + "vec2 mappedInputPosition = extendedInputPosition / textureSize;" // + vec2(0.0, 0.5) // setup input positions spaced as per the supplied offsets; these are for filtering where required "inputPositionsVarying[0] = mappedInputPosition - (vec2(5.0, 0.0) / textureSize);"