Loading common/drawpanel_gal.cpp +4 −8 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin m_view = NULL; m_painter = NULL; SwitchBackend( aGalType, true ); SwitchBackend( aGalType ); SetBackgroundStyle( wxBG_STYLE_CUSTOM ); // Initial display settings Loading Loading @@ -149,13 +149,10 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) } void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType ) { wxLogDebug( wxT( "EDA_DRAW_PANEL_GAL::SwitchBackend: using shaders: %s" ), aUseShaders ? "true" : "false" ); // Do not do anything if the currently used GAL is correct if( aGalType == m_currentGal && aUseShaders == m_useShaders && m_gal != NULL ) if( aGalType == m_currentGal && m_gal != NULL ) return; delete m_gal; Loading @@ -163,7 +160,7 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) switch( aGalType ) { case GAL_TYPE_OPENGL: m_gal = new KiGfx::OPENGL_GAL( this, this, this, aUseShaders ); m_gal = new KiGfx::OPENGL_GAL( this, this, this ); break; case GAL_TYPE_CAIRO: Loading Loading @@ -191,5 +188,4 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) m_gal->ResizeScreen( size.GetX(), size.GetY() ); m_currentGal = aGalType; m_useShaders = aUseShaders; } common/gal/opengl/opengl_gal.cpp +122 −334 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ void InitTesselatorCallbacks( GLUtesselator* aTesselator ); const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener, bool isUseShaders, const wxString& aName ) : wxEvtHandler* aPaintListener, const wxString& aName ) : wxGLCanvas( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName ), cachedManager( true ), Loading @@ -70,7 +70,6 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, // Initialize the flags isGlewInitialized = false; isFramebufferInitialized = false; isUseShader = isUseShaders; isShaderInitialized = false; isGrouping = false; wxSize parentSize = aParent->GetSize(); Loading Loading @@ -255,7 +254,7 @@ void OPENGL_GAL::BeginDrawing() } // Compile the shaders if( !isShaderInitialized && isUseShader ) if( !isShaderInitialized ) { if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) ) wxLogFatalError( wxT( "Cannot compile vertex shader!" ) ); Loading Loading @@ -351,9 +350,6 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2 return; VECTOR2D perpendicularVector( -startEndVector.y * scale, startEndVector.x * scale ); if( isUseShader ) { glm::vec4 vector( perpendicularVector.x, perpendicularVector.y, 0.0, 0.0 ); // The perpendicular vector also needs transformations Loading @@ -378,23 +374,6 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2 currentManager->Shader( SHADER_LINE, vector.x, vector.y, lineWidth ); currentManager->Vertex( aEndPoint.x, aEndPoint.y, layerDepth ); // v2 } else { // Compute the edge points of the line VECTOR2D v0 = aStartPoint + perpendicularVector; VECTOR2D v1 = aStartPoint - perpendicularVector; VECTOR2D v2 = aEndPoint + perpendicularVector; VECTOR2D v3 = aEndPoint - perpendicularVector; currentManager->Vertex( v0.x, v0.y, layerDepth ); currentManager->Vertex( v1.x, v1.y, layerDepth ); currentManager->Vertex( v3.x, v3.y, layerDepth ); currentManager->Vertex( v0.x, v0.y, layerDepth ); currentManager->Vertex( v3.x, v3.y, layerDepth ); currentManager->Vertex( v2.x, v2.y, layerDepth ); } } void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, Loading Loading @@ -532,8 +511,6 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) { if( isUseShader ) { if( isFillEnabled ) { Loading Loading @@ -589,89 +566,6 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) layerDepth ); } } else { if( isStrokeEnabled ) { // Compute the factors for the unit circle double outerScale = lineWidth / aRadius / 2; double innerScale = -outerScale; outerScale += 1.0; innerScale += 1.0; if( innerScale < outerScale ) { // Draw the outline VERTEX* circle = circleContainer.GetAllVertices(); int next; currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 ); currentManager->Scale( aRadius, aRadius, 0.0f ); for( int i = 0; i < 3 * CIRCLE_POINTS; ++i ) { // verticesCircle contains precomputed circle points interleaved with vertex // (0,0,0), so filled circles can be drawn as consecutive triangles, ie: // { 0,a,b, 0,c,d, 0,e,f, 0,g,h, ... } // where letters stand for consecutive circle points and 0 for (0,0,0) vertex. // We have to skip all (0,0,0) vertices (every third vertex) if( i % 3 == 0 ) { i++; // Depending on the vertex, next circle point // may be stored in the next vertex.. next = i + 1; } else { // ..or 2 vertices away (in case it is preceded by (0,0,0) vertex) next = i + 2; } currentManager->Vertex( circle[i].x * innerScale, circle[i].y * innerScale, layerDepth ); currentManager->Vertex( circle[i].x * outerScale, circle[i].y * outerScale, layerDepth ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, layerDepth ); currentManager->Vertex( circle[i].x * outerScale, circle[i].y * outerScale, layerDepth ); currentManager->Vertex( circle[next].x * outerScale, circle[next].y * outerScale, layerDepth ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, layerDepth ); } Restore(); } } // Filled circles are easy to draw by using the stored vertices list if( isFillEnabled ) { currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Scale( aRadius, aRadius, 0.0f ); currentManager->Vertices( circleContainer.GetAllVertices(), CIRCLE_POINTS * 3 ); Restore(); } } } void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) Loading @@ -692,8 +586,6 @@ void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, d void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) { if( isUseShader ) { Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f ); Loading @@ -719,25 +611,10 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad Restore(); } else { Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Scale( aRadius, aRadius, 0.0f ); currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); // It is enough just to draw a half of the circle vertices to make a semicircle currentManager->Vertices( circleContainer.GetAllVertices(), ( CIRCLE_POINTS * 3 ) / 2 ); Restore(); } } void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) { if( isUseShader ) { double outerRadius = aRadius + ( lineWidth / 2 ); Loading Loading @@ -766,52 +643,6 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa Restore(); } else { // Compute the factors for the unit circle double innerScale = 1.0 - lineWidth / aRadius; Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Scale( aRadius, aRadius, 0.0f ); currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); // Draw the outline VERTEX* circle = circleContainer.GetAllVertices(); int next; for( int i = 0; i < ( 3 * CIRCLE_POINTS ) / 2; ++i ) { // verticesCircle contains precomputed circle points interleaved with vertex // (0,0,0), so filled circles can be drawn as consecutive triangles, ie: // { 0,a,b, 0,c,d, 0,e,f, 0,g,h, ... } // where letters stand for consecutive circle points and 0 for (0,0,0) vertex. // We have to skip all (0,0,0) vertices (every third vertex) if( i % 3 == 0 ) { i++; // Depending on the vertex, next circle point may be stored in the next vertex.. next = i + 1; } else { // ..or 2 vertices away (in case it is preceded by (0,0,0) vertex) next = i + 2; } currentManager->Vertex( circle[i].x * innerScale, circle[i].y * innerScale, 0.0 ); currentManager->Vertex( circle[i].x, circle[i].y, 0.0 ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, 0.0 ); currentManager->Vertex( circle[i].x, circle[i].y, 0.0 ); currentManager->Vertex( circle[next].x, circle[next].y, 0.0 ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, 0.0 ); } Restore(); } } // FIXME Optimize Loading @@ -833,8 +664,6 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); if( isStrokeEnabled ) { if( isUseShader ) { double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS; currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); Loading @@ -856,46 +685,6 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a DrawLine( p, p_last ); } } else { Scale( VECTOR2D( aRadius, aRadius ) ); double outerScale = lineWidth / aRadius / 2; double innerScale = -outerScale; outerScale += 1.0; innerScale += 1.0; double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS; currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); for( double alpha = aStartAngle; alpha < aEndAngle; ) { double v0[] = { cos( alpha ) * innerScale, sin( alpha ) * innerScale }; double v1[] = { cos( alpha ) * outerScale, sin( alpha ) * outerScale }; alpha += alphaIncrement; if( alpha > aEndAngle ) alpha = aEndAngle; double v2[] = { cos( alpha ) * innerScale, sin( alpha ) * innerScale }; double v3[] = { cos( alpha ) * outerScale, sin( alpha ) * outerScale }; currentManager->Vertex( v0[0], v0[1], 0.0 ); currentManager->Vertex( v1[0], v1[1], 0.0 ); currentManager->Vertex( v2[0], v2[1], 0.0 ); currentManager->Vertex( v1[0], v1[1], 0.0 ); currentManager->Vertex( v3[0], v3[1], 0.0 ); currentManager->Vertex( v2[0], v2[1], 0.0 ); } // Draw line caps drawFilledSemiCircle( startPoint, lineWidth / aRadius / 2.0, aStartAngle + M_PI ); drawFilledSemiCircle( endPoint, lineWidth / aRadius / 2.0, aEndAngle ); } } if( isFillEnabled ) { Loading Loading @@ -1362,6 +1151,7 @@ void OPENGL_GAL::DrawCursor( VECTOR2D aCursorPosition ) void OPENGL_GAL::DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) { // TODO change to simple drawline // We check, if we got a horizontal or a vertical grid line and compute the offset VECTOR2D perpendicularVector; Loading @@ -1382,9 +1172,7 @@ void OPENGL_GAL::DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd VECTOR2D point3 = aEndPoint + perpendicularVector; VECTOR2D point4 = aEndPoint - perpendicularVector; // Set color currentManager->Color( gridColor.r, gridColor.g, gridColor.b, gridColor.a ); currentManager->Shader( SHADER_NONE ); // Draw the quad for the grid line Loading include/class_drawpanel_gal.h +2 −3 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public: * Switches method of rendering graphics. * @param aGalType is a type of rendering engine that you want to use. */ void SwitchBackend( GalType aGalType, bool aUseShaders = false ); void SwitchBackend( GalType aGalType ); /** * Function GetGAL Loading @@ -89,8 +89,7 @@ protected: ///< using GAL KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.) GalType m_currentGal; ///< Currently used GAL bool m_useShaders; ///< Are shaders used? (only for OpenGL GAL) wxLongLong m_timeStamp; wxLongLong m_timeStamp; ///< Timestamp for framelimiter }; #endif include/gal/opengl/opengl_gal.h +1 −7 Original line number Diff line number Diff line Loading @@ -82,14 +82,9 @@ public: * a wxCommandEvent holding EVT_GAL_REDRAW, as sent by PostPaint(). * * @param aName is the name of this window for use by wxWindow::FindWindowByName() * * @param isUseShaders is a flag, that indicates, if shaders should be used * for higher quality rendering. * */ OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener = NULL, wxEvtHandler* aPaintListener = NULL, bool isUseShaders = false, const wxString& aName = wxT( "GLCanvas" ) ); wxEvtHandler* aPaintListener = NULL, const wxString& aName = wxT( "GLCanvas" ) ); virtual ~OPENGL_GAL(); Loading Loading @@ -366,7 +361,6 @@ private: bool isGlewInitialized; ///< Is GLEW initialized? bool isFramebufferInitialized; ///< Are the framebuffers initialized? bool isShaderInitialized; ///< Was the shader initialized? bool isUseShader; ///< Should the shaders be used? bool isGrouping; ///< Was a group started? /** Loading pcbnew/hotkeys.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -85,9 +85,7 @@ static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, GR_KB_ALT + WXK_F9 ); static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, GR_KB_ALT + WXK_F10 ); static EDA_HOTKEY HkCanvasOpenGLShaders( wxT( "Switch to OpenGL canvas with shaders" ), HK_CANVAS_OPENGL_SHADERS, GR_KB_ALT + WXK_F11 ); HK_CANVAS_OPENGL, GR_KB_ALT + WXK_F11 ); static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo canvas" ), HK_CANVAS_CAIRO, GR_KB_ALT + WXK_F12 ); Loading Loading @@ -237,7 +235,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] = &HkRecordMacros6, &HkCallMacros6, &HkRecordMacros7, &HkCallMacros7, &HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9, &HkSwitchHighContrastMode, &HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, &HkCanvasOpenGLShaders, &HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, NULL }; Loading Loading
common/drawpanel_gal.cpp +4 −8 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin m_view = NULL; m_painter = NULL; SwitchBackend( aGalType, true ); SwitchBackend( aGalType ); SetBackgroundStyle( wxBG_STYLE_CUSTOM ); // Initial display settings Loading Loading @@ -149,13 +149,10 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) } void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType ) { wxLogDebug( wxT( "EDA_DRAW_PANEL_GAL::SwitchBackend: using shaders: %s" ), aUseShaders ? "true" : "false" ); // Do not do anything if the currently used GAL is correct if( aGalType == m_currentGal && aUseShaders == m_useShaders && m_gal != NULL ) if( aGalType == m_currentGal && m_gal != NULL ) return; delete m_gal; Loading @@ -163,7 +160,7 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) switch( aGalType ) { case GAL_TYPE_OPENGL: m_gal = new KiGfx::OPENGL_GAL( this, this, this, aUseShaders ); m_gal = new KiGfx::OPENGL_GAL( this, this, this ); break; case GAL_TYPE_CAIRO: Loading Loading @@ -191,5 +188,4 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) m_gal->ResizeScreen( size.GetX(), size.GetY() ); m_currentGal = aGalType; m_useShaders = aUseShaders; }
common/gal/opengl/opengl_gal.cpp +122 −334 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ void InitTesselatorCallbacks( GLUtesselator* aTesselator ); const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener, bool isUseShaders, const wxString& aName ) : wxEvtHandler* aPaintListener, const wxString& aName ) : wxGLCanvas( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName ), cachedManager( true ), Loading @@ -70,7 +70,6 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, // Initialize the flags isGlewInitialized = false; isFramebufferInitialized = false; isUseShader = isUseShaders; isShaderInitialized = false; isGrouping = false; wxSize parentSize = aParent->GetSize(); Loading Loading @@ -255,7 +254,7 @@ void OPENGL_GAL::BeginDrawing() } // Compile the shaders if( !isShaderInitialized && isUseShader ) if( !isShaderInitialized ) { if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) ) wxLogFatalError( wxT( "Cannot compile vertex shader!" ) ); Loading Loading @@ -351,9 +350,6 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2 return; VECTOR2D perpendicularVector( -startEndVector.y * scale, startEndVector.x * scale ); if( isUseShader ) { glm::vec4 vector( perpendicularVector.x, perpendicularVector.y, 0.0, 0.0 ); // The perpendicular vector also needs transformations Loading @@ -378,23 +374,6 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2 currentManager->Shader( SHADER_LINE, vector.x, vector.y, lineWidth ); currentManager->Vertex( aEndPoint.x, aEndPoint.y, layerDepth ); // v2 } else { // Compute the edge points of the line VECTOR2D v0 = aStartPoint + perpendicularVector; VECTOR2D v1 = aStartPoint - perpendicularVector; VECTOR2D v2 = aEndPoint + perpendicularVector; VECTOR2D v3 = aEndPoint - perpendicularVector; currentManager->Vertex( v0.x, v0.y, layerDepth ); currentManager->Vertex( v1.x, v1.y, layerDepth ); currentManager->Vertex( v3.x, v3.y, layerDepth ); currentManager->Vertex( v0.x, v0.y, layerDepth ); currentManager->Vertex( v3.x, v3.y, layerDepth ); currentManager->Vertex( v2.x, v2.y, layerDepth ); } } void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, Loading Loading @@ -532,8 +511,6 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) { if( isUseShader ) { if( isFillEnabled ) { Loading Loading @@ -589,89 +566,6 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) layerDepth ); } } else { if( isStrokeEnabled ) { // Compute the factors for the unit circle double outerScale = lineWidth / aRadius / 2; double innerScale = -outerScale; outerScale += 1.0; innerScale += 1.0; if( innerScale < outerScale ) { // Draw the outline VERTEX* circle = circleContainer.GetAllVertices(); int next; currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 ); currentManager->Scale( aRadius, aRadius, 0.0f ); for( int i = 0; i < 3 * CIRCLE_POINTS; ++i ) { // verticesCircle contains precomputed circle points interleaved with vertex // (0,0,0), so filled circles can be drawn as consecutive triangles, ie: // { 0,a,b, 0,c,d, 0,e,f, 0,g,h, ... } // where letters stand for consecutive circle points and 0 for (0,0,0) vertex. // We have to skip all (0,0,0) vertices (every third vertex) if( i % 3 == 0 ) { i++; // Depending on the vertex, next circle point // may be stored in the next vertex.. next = i + 1; } else { // ..or 2 vertices away (in case it is preceded by (0,0,0) vertex) next = i + 2; } currentManager->Vertex( circle[i].x * innerScale, circle[i].y * innerScale, layerDepth ); currentManager->Vertex( circle[i].x * outerScale, circle[i].y * outerScale, layerDepth ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, layerDepth ); currentManager->Vertex( circle[i].x * outerScale, circle[i].y * outerScale, layerDepth ); currentManager->Vertex( circle[next].x * outerScale, circle[next].y * outerScale, layerDepth ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, layerDepth ); } Restore(); } } // Filled circles are easy to draw by using the stored vertices list if( isFillEnabled ) { currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Scale( aRadius, aRadius, 0.0f ); currentManager->Vertices( circleContainer.GetAllVertices(), CIRCLE_POINTS * 3 ); Restore(); } } } void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) Loading @@ -692,8 +586,6 @@ void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, d void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) { if( isUseShader ) { Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f ); Loading @@ -719,25 +611,10 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad Restore(); } else { Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Scale( aRadius, aRadius, 0.0f ); currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); // It is enough just to draw a half of the circle vertices to make a semicircle currentManager->Vertices( circleContainer.GetAllVertices(), ( CIRCLE_POINTS * 3 ) / 2 ); Restore(); } } void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) { if( isUseShader ) { double outerRadius = aRadius + ( lineWidth / 2 ); Loading Loading @@ -766,52 +643,6 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa Restore(); } else { // Compute the factors for the unit circle double innerScale = 1.0 - lineWidth / aRadius; Save(); currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); currentManager->Scale( aRadius, aRadius, 0.0f ); currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); // Draw the outline VERTEX* circle = circleContainer.GetAllVertices(); int next; for( int i = 0; i < ( 3 * CIRCLE_POINTS ) / 2; ++i ) { // verticesCircle contains precomputed circle points interleaved with vertex // (0,0,0), so filled circles can be drawn as consecutive triangles, ie: // { 0,a,b, 0,c,d, 0,e,f, 0,g,h, ... } // where letters stand for consecutive circle points and 0 for (0,0,0) vertex. // We have to skip all (0,0,0) vertices (every third vertex) if( i % 3 == 0 ) { i++; // Depending on the vertex, next circle point may be stored in the next vertex.. next = i + 1; } else { // ..or 2 vertices away (in case it is preceded by (0,0,0) vertex) next = i + 2; } currentManager->Vertex( circle[i].x * innerScale, circle[i].y * innerScale, 0.0 ); currentManager->Vertex( circle[i].x, circle[i].y, 0.0 ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, 0.0 ); currentManager->Vertex( circle[i].x, circle[i].y, 0.0 ); currentManager->Vertex( circle[next].x, circle[next].y, 0.0 ); currentManager->Vertex( circle[next].x * innerScale, circle[next].y * innerScale, 0.0 ); } Restore(); } } // FIXME Optimize Loading @@ -833,8 +664,6 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a currentManager->Translate( aCenterPoint.x, aCenterPoint.y, layerDepth ); if( isStrokeEnabled ) { if( isUseShader ) { double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS; currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); Loading @@ -856,46 +685,6 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a DrawLine( p, p_last ); } } else { Scale( VECTOR2D( aRadius, aRadius ) ); double outerScale = lineWidth / aRadius / 2; double innerScale = -outerScale; outerScale += 1.0; innerScale += 1.0; double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS; currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); for( double alpha = aStartAngle; alpha < aEndAngle; ) { double v0[] = { cos( alpha ) * innerScale, sin( alpha ) * innerScale }; double v1[] = { cos( alpha ) * outerScale, sin( alpha ) * outerScale }; alpha += alphaIncrement; if( alpha > aEndAngle ) alpha = aEndAngle; double v2[] = { cos( alpha ) * innerScale, sin( alpha ) * innerScale }; double v3[] = { cos( alpha ) * outerScale, sin( alpha ) * outerScale }; currentManager->Vertex( v0[0], v0[1], 0.0 ); currentManager->Vertex( v1[0], v1[1], 0.0 ); currentManager->Vertex( v2[0], v2[1], 0.0 ); currentManager->Vertex( v1[0], v1[1], 0.0 ); currentManager->Vertex( v3[0], v3[1], 0.0 ); currentManager->Vertex( v2[0], v2[1], 0.0 ); } // Draw line caps drawFilledSemiCircle( startPoint, lineWidth / aRadius / 2.0, aStartAngle + M_PI ); drawFilledSemiCircle( endPoint, lineWidth / aRadius / 2.0, aEndAngle ); } } if( isFillEnabled ) { Loading Loading @@ -1362,6 +1151,7 @@ void OPENGL_GAL::DrawCursor( VECTOR2D aCursorPosition ) void OPENGL_GAL::DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) { // TODO change to simple drawline // We check, if we got a horizontal or a vertical grid line and compute the offset VECTOR2D perpendicularVector; Loading @@ -1382,9 +1172,7 @@ void OPENGL_GAL::DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd VECTOR2D point3 = aEndPoint + perpendicularVector; VECTOR2D point4 = aEndPoint - perpendicularVector; // Set color currentManager->Color( gridColor.r, gridColor.g, gridColor.b, gridColor.a ); currentManager->Shader( SHADER_NONE ); // Draw the quad for the grid line Loading
include/class_drawpanel_gal.h +2 −3 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public: * Switches method of rendering graphics. * @param aGalType is a type of rendering engine that you want to use. */ void SwitchBackend( GalType aGalType, bool aUseShaders = false ); void SwitchBackend( GalType aGalType ); /** * Function GetGAL Loading @@ -89,8 +89,7 @@ protected: ///< using GAL KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.) GalType m_currentGal; ///< Currently used GAL bool m_useShaders; ///< Are shaders used? (only for OpenGL GAL) wxLongLong m_timeStamp; wxLongLong m_timeStamp; ///< Timestamp for framelimiter }; #endif
include/gal/opengl/opengl_gal.h +1 −7 Original line number Diff line number Diff line Loading @@ -82,14 +82,9 @@ public: * a wxCommandEvent holding EVT_GAL_REDRAW, as sent by PostPaint(). * * @param aName is the name of this window for use by wxWindow::FindWindowByName() * * @param isUseShaders is a flag, that indicates, if shaders should be used * for higher quality rendering. * */ OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener = NULL, wxEvtHandler* aPaintListener = NULL, bool isUseShaders = false, const wxString& aName = wxT( "GLCanvas" ) ); wxEvtHandler* aPaintListener = NULL, const wxString& aName = wxT( "GLCanvas" ) ); virtual ~OPENGL_GAL(); Loading Loading @@ -366,7 +361,6 @@ private: bool isGlewInitialized; ///< Is GLEW initialized? bool isFramebufferInitialized; ///< Are the framebuffers initialized? bool isShaderInitialized; ///< Was the shader initialized? bool isUseShader; ///< Should the shaders be used? bool isGrouping; ///< Was a group started? /** Loading
pcbnew/hotkeys.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -85,9 +85,7 @@ static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, GR_KB_ALT + WXK_F9 ); static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, GR_KB_ALT + WXK_F10 ); static EDA_HOTKEY HkCanvasOpenGLShaders( wxT( "Switch to OpenGL canvas with shaders" ), HK_CANVAS_OPENGL_SHADERS, GR_KB_ALT + WXK_F11 ); HK_CANVAS_OPENGL, GR_KB_ALT + WXK_F11 ); static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo canvas" ), HK_CANVAS_CAIRO, GR_KB_ALT + WXK_F12 ); Loading Loading @@ -237,7 +235,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] = &HkRecordMacros6, &HkCallMacros6, &HkRecordMacros7, &HkCallMacros7, &HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9, &HkSwitchHighContrastMode, &HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, &HkCanvasOpenGLShaders, &HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, NULL }; Loading