Commit 04b4f236 authored by Maciej Suminski's avatar Maciej Suminski

Switching to OpenGL using shaders backend on the fly (changed keyboard...

Switching to OpenGL using shaders backend on the fly (changed keyboard shortcuts: different backends are available using Alt+F9..F12).
parent 28511cf4
...@@ -58,7 +58,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -58,7 +58,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
wxStandardPaths paths; wxStandardPaths paths;
wxFileName executableFile( paths.GetExecutablePath() ); wxFileName executableFile( paths.GetExecutablePath() );
m_galShaderPath = std::string( ( executableFile.GetPath() + m_galShaderPath = std::string( ( executableFile.GetPath() +
wxT( "/../../common/gal/opengl/" ) ).mb_str() ); wxT( "/../../common/gal/opengl" ) ).mb_str() );
SwitchBackend( aGalType, true ); SwitchBackend( aGalType, true );
SetBackgroundStyle( wxBG_STYLE_CUSTOM ); SetBackgroundStyle( wxBG_STYLE_CUSTOM );
...@@ -151,7 +151,11 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) ...@@ -151,7 +151,11 @@ 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, bool aUseShaders )
{ {
if( aGalType == m_currentGal && m_gal != NULL ) 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 )
return; return;
if( m_gal ) if( m_gal )
...@@ -186,4 +190,5 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders ) ...@@ -186,4 +190,5 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
m_gal->ResizeScreen( size.GetX(), size.GetY() ); m_gal->ResizeScreen( size.GetX(), size.GetY() );
m_currentGal = aGalType; m_currentGal = aGalType;
m_useShaders = aUseShaders;
} }
...@@ -88,6 +88,7 @@ protected: ...@@ -88,6 +88,7 @@ protected:
///< using GAL ///< using GAL
KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.) KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
GalType m_currentGal; ///< Currently used GAL GalType m_currentGal; ///< Currently used GAL
bool m_useShaders; ///< Are shaders used? (only for OpenGL GAL)
std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode
}; };
......
...@@ -83,9 +83,11 @@ static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), ...@@ -83,9 +83,11 @@ static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"),
HK_SWITCH_HIGHCONTRAST_MODE,'H'); HK_SWITCH_HIGHCONTRAST_MODE,'H');
#ifdef KICAD_GAL #ifdef KICAD_GAL
static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, WXK_F10 ); static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, WXK_F9 );
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, WXK_F11 ); static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, WXK_F10 );
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to Cairo canvas" ), HK_CANVAS_CAIRO, WXK_F12 ); static EDA_HOTKEY HkCanvasOpenGLShaders( wxT( "Switch to OpenGL canvas with shaders" ),
HK_CANVAS_OPENGL_SHADERS, WXK_F11 );
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo canvas" ), HK_CANVAS_CAIRO, WXK_F12 );
#endif #endif
/* Fit on Screen */ /* Fit on Screen */
#if !defined( __WXMAC__ ) #if !defined( __WXMAC__ )
...@@ -234,7 +236,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] = ...@@ -234,7 +236,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
&HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9, &HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9,
&HkSwitchHighContrastMode, &HkSwitchHighContrastMode,
#ifdef KICAD_GAL #ifdef KICAD_GAL
&HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, &HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, &HkCanvasOpenGLShaders,
#endif #endif
NULL NULL
}; };
......
...@@ -85,6 +85,7 @@ enum hotkey_id_commnand { ...@@ -85,6 +85,7 @@ enum hotkey_id_commnand {
#ifdef KICAD_GAL #ifdef KICAD_GAL
HK_CANVAS_DEFAULT, HK_CANVAS_DEFAULT,
HK_CANVAS_OPENGL, HK_CANVAS_OPENGL,
HK_CANVAS_OPENGL_SHADERS,
HK_CANVAS_CAIRO, HK_CANVAS_CAIRO,
#endif #endif
}; };
......
...@@ -366,6 +366,13 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -366,6 +366,13 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
text, _( "Switch the canvas implementation to OpenGL" ), text, _( "Switch the canvas implementation to OpenGL" ),
KiBitmap( tools_xpm ) ); KiBitmap( tools_xpm ) );
text = AddHotkeyName( _( "&Switch canvas to OpenGL (shaders)" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_CANVAS_OPENGL_SHADERS, IS_ACCELERATOR );
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL_SHADERS,
text, _( "Switch the canvas implementation to OpenGL that uses shaders" ),
KiBitmap( tools_xpm ) );
text = AddHotkeyName( _( "&Switch canvas to Cairo" ), g_Pcbnew_Editor_Hokeys_Descr, text = AddHotkeyName( _( "&Switch canvas to Cairo" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_CANVAS_CAIRO, IS_ACCELERATOR ); HK_CANVAS_CAIRO, IS_ACCELERATOR );
......
...@@ -160,6 +160,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) ...@@ -160,6 +160,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_MENU_CANVAS_DEFAULT, PCB_EDIT_FRAME::SwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_DEFAULT, PCB_EDIT_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::SwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::SwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL_SHADERS, PCB_EDIT_FRAME::SwitchCanvas )
// Menu Get Design Rules Editor // Menu Get Design Rules Editor
EVT_MENU( ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, PCB_EDIT_FRAME::ShowDesignRulesEditor ) EVT_MENU( ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, PCB_EDIT_FRAME::ShowDesignRulesEditor )
...@@ -587,6 +588,11 @@ void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent ) ...@@ -587,6 +588,11 @@ void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
break; break;
case ID_MENU_CANVAS_OPENGL: case ID_MENU_CANVAS_OPENGL:
m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, false );
UseGalCanvas( true );
break;
case ID_MENU_CANVAS_OPENGL_SHADERS:
m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, true ); m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, true );
UseGalCanvas( true ); UseGalCanvas( true );
break; break;
......
...@@ -268,6 +268,7 @@ enum pcbnew_ids ...@@ -268,6 +268,7 @@ enum pcbnew_ids
ID_MENU_PCB_SHOW_3D_FRAME, ID_MENU_PCB_SHOW_3D_FRAME,
ID_MENU_CANVAS_DEFAULT, ID_MENU_CANVAS_DEFAULT,
ID_MENU_CANVAS_OPENGL, ID_MENU_CANVAS_OPENGL,
ID_MENU_CANVAS_OPENGL_SHADERS,
ID_MENU_CANVAS_CAIRO, ID_MENU_CANVAS_CAIRO,
ID_PCB_USER_GRID_SETUP, ID_PCB_USER_GRID_SETUP,
ID_PCB_GEN_BOM_FILE_FROM_BOARD, ID_PCB_GEN_BOM_FILE_FROM_BOARD,
......
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