From f1a60832e0c45d3276c151c5f46113177b0b2084 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 16 Feb 2019 19:55:58 -0800 Subject: [PATCH] opengl: Handle stroked semi-circles And filled but we don't use those yet. No pixel-alignment needed for stroked semi-circles (I think) as we set the pixel width to be 1 regardless of the zoom level. Fixes: lp:1816263 * https://bugs.launchpad.net/kicad/+bug/1816263 --- common/gal/opengl/gl_builtin_shaders.cpp | 29 +++++++++++++++++------- common/gal/opengl/opengl_gal.cpp | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/common/gal/opengl/gl_builtin_shaders.cpp b/common/gal/opengl/gl_builtin_shaders.cpp index 23df68522b..313472065c 100644 --- a/common/gal/opengl/gl_builtin_shaders.cpp +++ b/common/gal/opengl/gl_builtin_shaders.cpp @@ -149,10 +149,9 @@ void computeLineCoords( bool posture, vec2 vs, vec2 vp, vec2 texcoord, vec2 dir, void computeCircleCoords( float vertexIndex, float radius, float lineWidth ) { vec4 delta; - vec4 center = roundv(gl_ModelViewProjectionMatrix * gl_Vertex + vec4(1, 1, 0, 0), screenPixelSize); - float pixelWidth = roundr(lineWidth / worldPixelSize, 1.0); - float pixelR = roundr(radius / worldPixelSize, 1.0); - //float pixelWidth = lineWidth / worldPixelSize; + vec4 center = roundv( gl_ModelViewProjectionMatrix * gl_Vertex + vec4(1, 1, 0, 0), screenPixelSize ); + float pixelWidth = roundr( lineWidth / worldPixelSize, 1.0); + float pixelR = roundr( radius / worldPixelSize, 1.0); vec4 adjust = vec4(-1, -1, 0, 0); @@ -162,19 +161,33 @@ void computeCircleCoords( float vertexIndex, float radius, float lineWidth ) if( vertexIndex == 1.0 ) { circleCoords = vec2( -sqrt( 3.0 ), -1.0 ); - delta = vec4(- pixelR * sqrt(3.0), -pixelR, 0, 0); + delta = vec4( -pixelR * sqrt(3.0), -pixelR, 0, 0 ); } else if( vertexIndex == 2.0 ) { circleCoords = vec2( sqrt( 3.0 ), -1.0 ); - delta = vec4( pixelR * sqrt(3.0), -pixelR, 0, 0); + delta = vec4( pixelR * sqrt( 3.0 ), -pixelR, 0, 0 ); } else if( vertexIndex == 3.0 ) { circleCoords = vec2( 0.0, 2.0 ); - delta = vec4(0, 2*pixelR, 0, 0); + delta = vec4( 0, 2 * pixelR, 0, 0 ); + } + else if( vertexIndex == 4.0 ) + { + circleCoords = vec2( -sqrt( 3.0 ), 0.0 ); + delta = vec4( 0, 0, 0, 0 ); + } + else if( vertexIndex == 5.0 ) + { + circleCoords = vec2( sqrt( 3.0 ), 0.0 ); + delta = vec4( 0, 0, 0, 0 ); + } + else if( vertexIndex == 6.0 ) + { + circleCoords = vec2( 0.0, 2.0 ); + delta = vec4( 0, 0, 0, 0 ); } - shaderParams[2] = pixelR; shaderParams[3] = pixelWidth; diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 2abc276ca1..b8d7f10e98 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -617,6 +617,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP // Outlined tracks double lineLength = startEndVector.EuclideanNorm(); + SetLineWidth( 1.0 ); currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); Save();