Commit 9e8719d3 authored by Maciej Suminski's avatar Maciej Suminski

Fixed overlapping segment endings in OpenGL view.

parent 45d0448b
......@@ -248,3 +248,7 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const
return VECTOR2D( round( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
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;
......@@ -42,7 +42,7 @@ using namespace KIGFX;
// Prototypes
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;
......
......@@ -27,16 +27,16 @@
#version 120
// Shader types
const float SHADER_LINE = 1.0f;
const float SHADER_FILLED_CIRCLE = 2.0f;
const float SHADER_STROKED_CIRCLE = 3.0f;
const float SHADER_LINE = 1.0;
const float SHADER_FILLED_CIRCLE = 2.0;
const float SHADER_STROKED_CIRCLE = 3.0;
varying vec4 shaderParams;
varying vec2 circleCoords;
void filledCircle( vec2 aCoord )
{
if( dot( aCoord, aCoord ) < 1.0f )
if( dot( aCoord, aCoord ) < 1.0 )
gl_FragColor = gl_Color;
else
discard;
......@@ -49,7 +49,7 @@ void strokedCircle( vec2 aCoord, float aRadius, float aWidth )
float innerRadius = aRadius - ( aWidth / 2 );
float relWidth = innerRadius / outerRadius;
if( ( dot( aCoord, aCoord ) < 1.0f ) &&
if( ( dot( aCoord, aCoord ) < 1.0 ) &&
( dot( aCoord, aCoord ) > relWidth * relWidth ) )
gl_FragColor = gl_Color;
else
......
......@@ -27,12 +27,12 @@
#version 120
// Shader types
const float SHADER_LINE = 1.0f;
const float SHADER_FILLED_CIRCLE = 2.0f;
const float SHADER_STROKED_CIRCLE = 3.0f;
const float SHADER_LINE = 1.0;
const float SHADER_FILLED_CIRCLE = 2.0;
const float SHADER_STROKED_CIRCLE = 3.0;
// Minimum line width
const float MIN_WIDTH = 1.0f;
const float MIN_WIDTH = 1.0;
attribute vec4 attrShaderParams;
varying vec4 shaderParams;
......@@ -47,42 +47,39 @@ void main()
{
float lineWidth = shaderParams[3];
float worldScale = gl_ModelViewMatrix[0][0];
float scale;
// Make lines appear to be at least 1 pixel wide
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
scale = 1.0f;
gl_Position = gl_ModelViewProjectionMatrix *
( gl_Vertex + vec4( shaderParams.yz * scale, 0.0, 0.0 ) );
gl_Position = gl_ModelViewProjectionMatrix *
( gl_Vertex + vec4( shaderParams.yz, 0.0, 0.0 ) );
}
else if( ( shaderParams[0] == SHADER_STROKED_CIRCLE ) ||
( shaderParams[0] == SHADER_FILLED_CIRCLE ) )
{
// Compute relative circle coordinates basing on indices
// Circle
if( shaderParams[1] == 1.0f )
circleCoords = vec2( -sqrt( 3.0f ), -1.0f );
else if( shaderParams[1] == 2.0f )
circleCoords = vec2( sqrt( 3.0f ), -1.0f );
else if( shaderParams[1] == 3.0f )
circleCoords = vec2( 0.0f, 2.0f );
if( shaderParams[1] == 1.0 )
circleCoords = vec2( -sqrt( 3.0 ), -1.0 );
else if( shaderParams[1] == 2.0 )
circleCoords = vec2( sqrt( 3.0 ), -1.0 );
else if( shaderParams[1] == 3.0 )
circleCoords = vec2( 0.0, 2.0 );
// Semicircle
else if( shaderParams[1] == 4.0f )
circleCoords = vec2( -3.0f / sqrt( 3.0f ), 0.0f );
else if( shaderParams[1] == 5.0f )
circleCoords = vec2( 3.0f / sqrt( 3.0f ), 0.0f );
else if( shaderParams[1] == 6.0f )
circleCoords = vec2( 0.0f, 2.0f );
else if( shaderParams[1] == 4.0 )
circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 );
else if( shaderParams[1] == 5.0 )
circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 );
else if( shaderParams[1] == 6.0 )
circleCoords = vec2( 0.0, 2.0 );
// Make the line appear to be at least 1 pixel wide
float lineWidth = shaderParams[3];
float worldScale = gl_ModelViewMatrix[0][0];
// Make lines appear to be at least 1 pixel width
if( worldScale * lineWidth < MIN_WIDTH )
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
......
......@@ -1041,7 +1041,7 @@ struct VIEW::extentsVisitor
};
const BOX2I VIEW::CalculateExtents()
const BOX2I VIEW::CalculateExtents()
{
extentsVisitor v;
BOX2I fullScene;
......@@ -1051,6 +1051,9 @@ const BOX2I VIEW::CalculateExtents()
{
l->items->Query( fullScene, v );
}
return v.extents;
}
const int VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
......@@ -836,9 +836,6 @@ public:
depthStack.pop();
}
/// Depth level on which the grid is drawn
static const int GRID_DEPTH = 1024;
static const double METRIC_UNIT_LENGTH;
protected:
......@@ -903,8 +900,13 @@ protected:
*/
virtual void drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) = 0;
static const int MIN_DEPTH = -2048;
static const int MAX_DEPTH = 2047;
/// Possible depth range
static const int MIN_DEPTH;
static const int MAX_DEPTH;
/// Depth level on which the grid is drawn
static const int GRID_DEPTH;
};
} // namespace KIGFX
......
......@@ -670,7 +670,7 @@ private:
bool m_dirtyTargets[TARGETS_NUMBER];
/// Rendering order modifier for layers that are marked as top layers
static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
static const int TOP_LAYER_MODIFIER;
/// Items to be updated
std::vector<VIEW_ITEM*> m_needsUpdate;
......
......@@ -211,7 +211,7 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal->SetIsFill( true );
aGal->SetIsStroke( false );
aGal->PushDepth();
aGal->SetLayerDepth( -512.0 ); // TODO no hardcoded depths?
aGal->SetLayerDepth( aGal->GetMinDepth() );
float size = m_view->ToWorld( EDIT_POINT::POINT_SIZE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment