Switching to OpenGL using shaders backend on the fly (changed keyboard shortcuts: different backends are available using Alt+F9..F12).
This commit is contained in:
parent
28511cf4fe
commit
04b4f236be
|
@ -58,7 +58,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
|||
wxStandardPaths paths;
|
||||
wxFileName executableFile( paths.GetExecutablePath() );
|
||||
m_galShaderPath = std::string( ( executableFile.GetPath() +
|
||||
wxT( "/../../common/gal/opengl/" ) ).mb_str() );
|
||||
wxT( "/../../common/gal/opengl" ) ).mb_str() );
|
||||
|
||||
SwitchBackend( aGalType, true );
|
||||
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
||||
|
@ -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 )
|
||||
{
|
||||
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;
|
||||
|
||||
if( m_gal )
|
||||
|
@ -186,4 +190,5 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
|
|||
m_gal->ResizeScreen( size.GetX(), size.GetY() );
|
||||
|
||||
m_currentGal = aGalType;
|
||||
m_useShaders = aUseShaders;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,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)
|
||||
|
||||
std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode
|
||||
};
|
||||
|
|
|
@ -83,9 +83,11 @@ static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
|
|||
static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"),
|
||||
HK_SWITCH_HIGHCONTRAST_MODE,'H');
|
||||
#ifdef KICAD_GAL
|
||||
static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, WXK_F10 );
|
||||
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, WXK_F11 );
|
||||
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to Cairo canvas" ), HK_CANVAS_CAIRO, WXK_F12 );
|
||||
static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, WXK_F9 );
|
||||
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, WXK_F10 );
|
||||
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
|
||||
/* Fit on Screen */
|
||||
#if !defined( __WXMAC__ )
|
||||
|
@ -234,7 +236,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
|
|||
&HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9,
|
||||
&HkSwitchHighContrastMode,
|
||||
#ifdef KICAD_GAL
|
||||
&HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL,
|
||||
&HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, &HkCanvasOpenGLShaders,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
|
|
@ -85,6 +85,7 @@ enum hotkey_id_commnand {
|
|||
#ifdef KICAD_GAL
|
||||
HK_CANVAS_DEFAULT,
|
||||
HK_CANVAS_OPENGL,
|
||||
HK_CANVAS_OPENGL_SHADERS,
|
||||
HK_CANVAS_CAIRO,
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -365,6 +365,13 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
|||
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
|
||||
text, _( "Switch the canvas implementation to OpenGL" ),
|
||||
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,
|
||||
HK_CANVAS_CAIRO, IS_ACCELERATOR );
|
||||
|
|
|
@ -157,9 +157,10 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
|
||||
|
||||
// Switching canvases
|
||||
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_OPENGL, 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_OPENGL, PCB_EDIT_FRAME::SwitchCanvas )
|
||||
EVT_MENU( ID_MENU_CANVAS_OPENGL_SHADERS, PCB_EDIT_FRAME::SwitchCanvas )
|
||||
|
||||
// Menu Get Design Rules Editor
|
||||
EVT_MENU( ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, PCB_EDIT_FRAME::ShowDesignRulesEditor )
|
||||
|
@ -587,6 +588,11 @@ void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
|
|||
break;
|
||||
|
||||
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 );
|
||||
UseGalCanvas( true );
|
||||
break;
|
||||
|
|
|
@ -268,6 +268,7 @@ enum pcbnew_ids
|
|||
ID_MENU_PCB_SHOW_3D_FRAME,
|
||||
ID_MENU_CANVAS_DEFAULT,
|
||||
ID_MENU_CANVAS_OPENGL,
|
||||
ID_MENU_CANVAS_OPENGL_SHADERS,
|
||||
ID_MENU_CANVAS_CAIRO,
|
||||
ID_PCB_USER_GRID_SETUP,
|
||||
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
|
||||
|
|
Loading…
Reference in New Issue