Loading common/gal/graphics_abstraction_layer.cpp +4 −0 Original line number Original line Diff line number Diff line Loading @@ -248,3 +248,7 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const return VECTOR2D( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x, return VECTOR2D( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x, round( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y ); round( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y ); } } const int GAL::MIN_DEPTH = -256; const int GAL::MAX_DEPTH = 255; const int GAL::GRID_DEPTH = MAX_DEPTH - 1; common/gal/opengl/opengl_gal.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ using namespace KIGFX; // Prototypes // Prototypes void InitTesselatorCallbacks( GLUtesselator* aTesselator ); void InitTesselatorCallbacks( GLUtesselator* aTesselator ); const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 }; wxGLContext* OPENGL_GAL::glContext = NULL; wxGLContext* OPENGL_GAL::glContext = NULL; Loading common/gal/opengl/shader.frag +5 −5 Original line number Original line Diff line number Diff line Loading @@ -27,16 +27,16 @@ #version 120 #version 120 // Shader types // Shader types const float SHADER_LINE = 1.0f; const float SHADER_LINE = 1.0; const float SHADER_FILLED_CIRCLE = 2.0f; const float SHADER_FILLED_CIRCLE = 2.0; const float SHADER_STROKED_CIRCLE = 3.0f; const float SHADER_STROKED_CIRCLE = 3.0; varying vec4 shaderParams; varying vec4 shaderParams; varying vec2 circleCoords; varying vec2 circleCoords; void filledCircle( vec2 aCoord ) void filledCircle( vec2 aCoord ) { { if( dot( aCoord, aCoord ) < 1.0f ) if( dot( aCoord, aCoord ) < 1.0 ) gl_FragColor = gl_Color; gl_FragColor = gl_Color; else else discard; discard; Loading @@ -49,7 +49,7 @@ void strokedCircle( vec2 aCoord, float aRadius, float aWidth ) float innerRadius = aRadius - ( aWidth / 2 ); float innerRadius = aRadius - ( aWidth / 2 ); float relWidth = innerRadius / outerRadius; float relWidth = innerRadius / outerRadius; if( ( dot( aCoord, aCoord ) < 1.0f ) && if( ( dot( aCoord, aCoord ) < 1.0 ) && ( dot( aCoord, aCoord ) > relWidth * relWidth ) ) ( dot( aCoord, aCoord ) > relWidth * relWidth ) ) gl_FragColor = gl_Color; gl_FragColor = gl_Color; else else Loading common/gal/opengl/shader.vert +20 −23 Original line number Original line Diff line number Diff line Loading @@ -27,12 +27,12 @@ #version 120 #version 120 // Shader types // Shader types const float SHADER_LINE = 1.0f; const float SHADER_LINE = 1.0; const float SHADER_FILLED_CIRCLE = 2.0f; const float SHADER_FILLED_CIRCLE = 2.0; const float SHADER_STROKED_CIRCLE = 3.0f; const float SHADER_STROKED_CIRCLE = 3.0; // Minimum line width // Minimum line width const float MIN_WIDTH = 1.0f; const float MIN_WIDTH = 1.0; attribute vec4 attrShaderParams; attribute vec4 attrShaderParams; varying vec4 shaderParams; varying vec4 shaderParams; Loading @@ -47,42 +47,39 @@ void main() { { float lineWidth = shaderParams[3]; float lineWidth = shaderParams[3]; float worldScale = gl_ModelViewMatrix[0][0]; float worldScale = gl_ModelViewMatrix[0][0]; float scale; // Make lines appear to be at least 1 pixel wide // Make lines appear to be at least 1 pixel wide if( worldScale * lineWidth < MIN_WIDTH ) if( worldScale * lineWidth < MIN_WIDTH ) scale = MIN_WIDTH / ( worldScale * lineWidth ); gl_Position = gl_ModelViewProjectionMatrix * ( gl_Vertex + vec4( shaderParams.yz * MIN_WIDTH / ( worldScale * lineWidth ), 0.0, 0.0 ) ); else else scale = 1.0f; gl_Position = gl_ModelViewProjectionMatrix * gl_Position = gl_ModelViewProjectionMatrix * ( gl_Vertex + vec4( shaderParams.yz * scale, 0.0, 0.0 ) ); ( gl_Vertex + vec4( shaderParams.yz, 0.0, 0.0 ) ); } } else if( ( shaderParams[0] == SHADER_STROKED_CIRCLE ) || else if( ( shaderParams[0] == SHADER_STROKED_CIRCLE ) || ( shaderParams[0] == SHADER_FILLED_CIRCLE ) ) ( shaderParams[0] == SHADER_FILLED_CIRCLE ) ) { { // Compute relative circle coordinates basing on indices // Compute relative circle coordinates basing on indices // Circle // Circle if( shaderParams[1] == 1.0f ) if( shaderParams[1] == 1.0 ) circleCoords = vec2( -sqrt( 3.0f ), -1.0f ); circleCoords = vec2( -sqrt( 3.0 ), -1.0 ); else if( shaderParams[1] == 2.0f ) else if( shaderParams[1] == 2.0 ) circleCoords = vec2( sqrt( 3.0f ), -1.0f ); circleCoords = vec2( sqrt( 3.0 ), -1.0 ); else if( shaderParams[1] == 3.0f ) else if( shaderParams[1] == 3.0 ) circleCoords = vec2( 0.0f, 2.0f ); circleCoords = vec2( 0.0, 2.0 ); // Semicircle // Semicircle else if( shaderParams[1] == 4.0f ) else if( shaderParams[1] == 4.0 ) circleCoords = vec2( -3.0f / sqrt( 3.0f ), 0.0f ); circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 ); else if( shaderParams[1] == 5.0f ) else if( shaderParams[1] == 5.0 ) circleCoords = vec2( 3.0f / sqrt( 3.0f ), 0.0f ); circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 ); else if( shaderParams[1] == 6.0f ) else if( shaderParams[1] == 6.0 ) circleCoords = vec2( 0.0f, 2.0f ); circleCoords = vec2( 0.0, 2.0 ); // Make the line appear to be at least 1 pixel wide // Make the line appear to be at least 1 pixel wide float lineWidth = shaderParams[3]; float lineWidth = shaderParams[3]; float worldScale = gl_ModelViewMatrix[0][0]; float worldScale = gl_ModelViewMatrix[0][0]; // Make lines appear to be at least 1 pixel width if( worldScale * lineWidth < MIN_WIDTH ) if( worldScale * lineWidth < MIN_WIDTH ) shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth ); shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth ); Loading common/view/view.cpp +5 −2 Original line number Original line Diff line number Diff line Loading @@ -1054,3 +1054,6 @@ const BOX2I VIEW::CalculateExtents() return v.extents; return v.extents; } } const int VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS; Loading
common/gal/graphics_abstraction_layer.cpp +4 −0 Original line number Original line Diff line number Diff line Loading @@ -248,3 +248,7 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const return VECTOR2D( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x, return VECTOR2D( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x, round( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y ); round( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y ); } } const int GAL::MIN_DEPTH = -256; const int GAL::MAX_DEPTH = 255; const int GAL::GRID_DEPTH = MAX_DEPTH - 1;
common/gal/opengl/opengl_gal.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ using namespace KIGFX; // Prototypes // Prototypes void InitTesselatorCallbacks( GLUtesselator* aTesselator ); void InitTesselatorCallbacks( GLUtesselator* aTesselator ); const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 }; wxGLContext* OPENGL_GAL::glContext = NULL; wxGLContext* OPENGL_GAL::glContext = NULL; Loading
common/gal/opengl/shader.frag +5 −5 Original line number Original line Diff line number Diff line Loading @@ -27,16 +27,16 @@ #version 120 #version 120 // Shader types // Shader types const float SHADER_LINE = 1.0f; const float SHADER_LINE = 1.0; const float SHADER_FILLED_CIRCLE = 2.0f; const float SHADER_FILLED_CIRCLE = 2.0; const float SHADER_STROKED_CIRCLE = 3.0f; const float SHADER_STROKED_CIRCLE = 3.0; varying vec4 shaderParams; varying vec4 shaderParams; varying vec2 circleCoords; varying vec2 circleCoords; void filledCircle( vec2 aCoord ) void filledCircle( vec2 aCoord ) { { if( dot( aCoord, aCoord ) < 1.0f ) if( dot( aCoord, aCoord ) < 1.0 ) gl_FragColor = gl_Color; gl_FragColor = gl_Color; else else discard; discard; Loading @@ -49,7 +49,7 @@ void strokedCircle( vec2 aCoord, float aRadius, float aWidth ) float innerRadius = aRadius - ( aWidth / 2 ); float innerRadius = aRadius - ( aWidth / 2 ); float relWidth = innerRadius / outerRadius; float relWidth = innerRadius / outerRadius; if( ( dot( aCoord, aCoord ) < 1.0f ) && if( ( dot( aCoord, aCoord ) < 1.0 ) && ( dot( aCoord, aCoord ) > relWidth * relWidth ) ) ( dot( aCoord, aCoord ) > relWidth * relWidth ) ) gl_FragColor = gl_Color; gl_FragColor = gl_Color; else else Loading
common/gal/opengl/shader.vert +20 −23 Original line number Original line Diff line number Diff line Loading @@ -27,12 +27,12 @@ #version 120 #version 120 // Shader types // Shader types const float SHADER_LINE = 1.0f; const float SHADER_LINE = 1.0; const float SHADER_FILLED_CIRCLE = 2.0f; const float SHADER_FILLED_CIRCLE = 2.0; const float SHADER_STROKED_CIRCLE = 3.0f; const float SHADER_STROKED_CIRCLE = 3.0; // Minimum line width // Minimum line width const float MIN_WIDTH = 1.0f; const float MIN_WIDTH = 1.0; attribute vec4 attrShaderParams; attribute vec4 attrShaderParams; varying vec4 shaderParams; varying vec4 shaderParams; Loading @@ -47,42 +47,39 @@ void main() { { float lineWidth = shaderParams[3]; float lineWidth = shaderParams[3]; float worldScale = gl_ModelViewMatrix[0][0]; float worldScale = gl_ModelViewMatrix[0][0]; float scale; // Make lines appear to be at least 1 pixel wide // Make lines appear to be at least 1 pixel wide if( worldScale * lineWidth < MIN_WIDTH ) if( worldScale * lineWidth < MIN_WIDTH ) scale = MIN_WIDTH / ( worldScale * lineWidth ); gl_Position = gl_ModelViewProjectionMatrix * ( gl_Vertex + vec4( shaderParams.yz * MIN_WIDTH / ( worldScale * lineWidth ), 0.0, 0.0 ) ); else else scale = 1.0f; gl_Position = gl_ModelViewProjectionMatrix * gl_Position = gl_ModelViewProjectionMatrix * ( gl_Vertex + vec4( shaderParams.yz * scale, 0.0, 0.0 ) ); ( gl_Vertex + vec4( shaderParams.yz, 0.0, 0.0 ) ); } } else if( ( shaderParams[0] == SHADER_STROKED_CIRCLE ) || else if( ( shaderParams[0] == SHADER_STROKED_CIRCLE ) || ( shaderParams[0] == SHADER_FILLED_CIRCLE ) ) ( shaderParams[0] == SHADER_FILLED_CIRCLE ) ) { { // Compute relative circle coordinates basing on indices // Compute relative circle coordinates basing on indices // Circle // Circle if( shaderParams[1] == 1.0f ) if( shaderParams[1] == 1.0 ) circleCoords = vec2( -sqrt( 3.0f ), -1.0f ); circleCoords = vec2( -sqrt( 3.0 ), -1.0 ); else if( shaderParams[1] == 2.0f ) else if( shaderParams[1] == 2.0 ) circleCoords = vec2( sqrt( 3.0f ), -1.0f ); circleCoords = vec2( sqrt( 3.0 ), -1.0 ); else if( shaderParams[1] == 3.0f ) else if( shaderParams[1] == 3.0 ) circleCoords = vec2( 0.0f, 2.0f ); circleCoords = vec2( 0.0, 2.0 ); // Semicircle // Semicircle else if( shaderParams[1] == 4.0f ) else if( shaderParams[1] == 4.0 ) circleCoords = vec2( -3.0f / sqrt( 3.0f ), 0.0f ); circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 ); else if( shaderParams[1] == 5.0f ) else if( shaderParams[1] == 5.0 ) circleCoords = vec2( 3.0f / sqrt( 3.0f ), 0.0f ); circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 ); else if( shaderParams[1] == 6.0f ) else if( shaderParams[1] == 6.0 ) circleCoords = vec2( 0.0f, 2.0f ); circleCoords = vec2( 0.0, 2.0 ); // Make the line appear to be at least 1 pixel wide // Make the line appear to be at least 1 pixel wide float lineWidth = shaderParams[3]; float lineWidth = shaderParams[3]; float worldScale = gl_ModelViewMatrix[0][0]; float worldScale = gl_ModelViewMatrix[0][0]; // Make lines appear to be at least 1 pixel width if( worldScale * lineWidth < MIN_WIDTH ) if( worldScale * lineWidth < MIN_WIDTH ) shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth ); shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth ); Loading
common/view/view.cpp +5 −2 Original line number Original line Diff line number Diff line Loading @@ -1054,3 +1054,6 @@ const BOX2I VIEW::CalculateExtents() return v.extents; return v.extents; } } const int VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;