Skip to content

Commit

Permalink
Port the possibility to turn off OpenGL completely from 3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nohal committed May 23, 2013
1 parent 6c87098 commit 440d51c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
1 change: 1 addition & 0 deletions NSIS.template.in
Expand Up @@ -784,6 +784,7 @@ SectionGroup /e "!Shortcuts Section Group" SecGrpShortcuts
;# Create shortcuts
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\OpenCPN @CPACK_PACKAGE_VERSION@.lnk" "$INSTDIR\opencpn.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\OpenCPN @CPACK_PACKAGE_VERSION@ - No OpenGL.lnk" "$INSTDIR\opencpn.exe" "/no_opengl"
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER\$(Uninstall_Folder_Name)"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$(Uninstall_Folder_Name)\$(Uninstall_Link).lnk" "$INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe"
!insertmacro MUI_STARTMENU_WRITE_END
Expand Down
21 changes: 15 additions & 6 deletions src/chart1.cpp
Expand Up @@ -421,6 +421,8 @@ bool g_bQuiltStart;

bool g_bportable;

bool g_bdisable_opengl;

ChartGroupArray *g_pGroupArray;
int g_GroupIndex;

Expand Down Expand Up @@ -754,12 +756,15 @@ void MyApp::OnInitCmdLine( wxCmdLineParser& parser )
parser.AddSwitch( _T("unit_test_1") );

parser.AddSwitch( _T("p") );

parser.AddSwitch( _T("no_opengl") );
}

bool MyApp::OnCmdLineParsed( wxCmdLineParser& parser )
{
g_unit_test_1 = parser.Found( _T("unit_test_1") );
g_bportable = parser.Found( _T("p") );
g_bdisable_opengl = parser.Found( _T("no_opengl") );

return true;
}
Expand Down Expand Up @@ -2073,12 +2078,16 @@ if( 0 == g_memCacheLimit )
// We need a deferred resize to get glDrawPixels() to work right.
// So we set a trigger to generate a resize after 5 seconds....
// See the "UniChrome" hack elsewhere
glChartCanvas *pgl = (glChartCanvas *) cc1->GetglCanvas();
if( pgl && ( pgl->GetRendererString().Find( _T("UniChrome") ) != wxNOT_FOUND ) ) {
gFrame->m_defer_size = gFrame->GetSize();
gFrame->SetSize( gFrame->m_defer_size.x - 10, gFrame->m_defer_size.y );
g_pauimgr->Update();
gFrame->m_bdefer_resize = true;
if ( !g_bdisable_opengl )
{
glChartCanvas *pgl = (glChartCanvas *) cc1->GetglCanvas();
if( pgl && ( pgl->GetRendererString().Find( _T("UniChrome") ) != wxNOT_FOUND ) )
{
gFrame->m_defer_size = gFrame->GetSize();
gFrame->SetSize( gFrame->m_defer_size.x - 10, gFrame->m_defer_size.y );
g_pauimgr->Update();
gFrame->m_bdefer_resize = true;
}
}
return TRUE;
}
Expand Down
35 changes: 20 additions & 15 deletions src/chcanv.cpp
Expand Up @@ -256,6 +256,7 @@ extern wxAuiManager *g_pauimgr;

extern bool g_bskew_comp;
extern bool g_bopengl;
extern bool g_bdisable_opengl;

extern bool g_bFullScreenQuilt;
extern wxProgressDialog *s_ProgDialog;
Expand Down Expand Up @@ -971,20 +972,22 @@ ChartCanvas::ChartCanvas ( wxFrame *frame ) :
m_bzooming_out = false;;

EnableAutoPan(true);

undo = new Undo;

VPoint.Invalidate();

m_glcc = new glChartCanvas(this);

#if wxCHECK_VERSION(2, 9, 0)
m_pGLcontext = new wxGLContext(m_glcc);
m_glcc->SetContext(m_pGLcontext);
#else
m_pGLcontext = m_glcc->GetContext();
#endif
if ( !g_bdisable_opengl )
{
m_glcc = new glChartCanvas(this);

#if wxCHECK_VERSION(2, 9, 0)
m_pGLcontext = new wxGLContext(m_glcc);
m_glcc->SetContext(m_pGLcontext);
#else
m_pGLcontext = m_glcc->GetContext();
#endif
}

singleClickEventIsValid = false;

Expand Down Expand Up @@ -1383,7 +1386,8 @@ ChartCanvas::~ChartCanvas()
delete m_pos_image_user_grey_dusk;
delete m_pos_image_user_grey_night;
delete undo;
delete m_glcc;
if( !g_bdisable_opengl )
delete m_glcc;
}

int ChartCanvas::GetCanvasChartNativeScale()
Expand Down Expand Up @@ -1672,7 +1676,7 @@ void ChartCanvas::OnKeyDown( wxKeyEvent &event )
case WXK_F12: {
if( m_modkeys == wxMOD_ALT )
m_nMeasureState = *(int *)(0); // generate a fault for testing

parent_frame->ToggleChartOutlines();
break;
}
Expand Down Expand Up @@ -1977,7 +1981,7 @@ void ChartCanvas::Do_Pankeys( wxTimerEvent& event )

if( !m_benable_autopan )
return;

const int slowpan = 2, maxpan = 100;
int repeat = 100;

Expand Down Expand Up @@ -4822,8 +4826,8 @@ void ChartCanvas::EnableAutoPan(bool b_enable )
m_pany = 0;
m_panspeed = 0;
}
}
}

bool ChartCanvas::CheckEdgePan( int x, int y, bool bdragging )
{
bool bft = false;
Expand Down Expand Up @@ -7895,7 +7899,8 @@ void ChartCanvas::OnPaint( wxPaintEvent& event )

wxPaintDC dc( this );

m_glcc->Show( g_bopengl );
if( !g_bdisable_opengl )
m_glcc->Show( g_bopengl );

if( g_bopengl ) {
if( !s_in_update ) { // no recursion allowed, seen on lo-spec Mac
Expand Down
7 changes: 3 additions & 4 deletions src/navutil.cpp
Expand Up @@ -124,6 +124,7 @@ extern bool g_bShowDepthUnits;
extern bool g_bAutoAnchorMark;
extern bool g_bskew_comp;
extern bool g_bopengl;
extern bool g_bdisable_opengl;
extern bool g_bsmoothpanzoom;

extern bool g_bShowOutlines;
Expand Down Expand Up @@ -1102,10 +1103,8 @@ int MyConfig::LoadMyConfig( int iteration )
Read( _T ( "LookAheadMode" ), &g_bLookAhead, 0 );
Read( _T ( "SkewToNorthUp" ), &g_bskew_comp, 0 );
Read( _T ( "OpenGL" ), &g_bopengl, 0 );

//#ifdef __WXMAC__
// g_bopengl = 0;
//#endif
if ( g_bdisable_opengl )
g_bopengl = false;

Read( _T ( "ActiveChartGroup" ), &g_GroupIndex, 0 );

Expand Down
2 changes: 2 additions & 0 deletions src/options.cpp
Expand Up @@ -174,6 +174,7 @@ extern s52plib *ps52plib;

extern wxString g_locale;
extern bool g_bportable;
extern bool g_bdisable_opengl;
extern wxString *pHome_Locn;

extern ChartGroupArray *g_pGroupArray;
Expand Down Expand Up @@ -1367,6 +1368,7 @@ void options::CreatePanel_Display( size_t parent, int border_size, int group_ite
// OpenGL Render checkbox
pOpenGL = new wxCheckBox( itemPanelUI, ID_OPENGLBOX, _("Use Accelerated Graphics (OpenGL)") );
itemStaticBoxSizerCDO->Add( pOpenGL, 1, wxALL, border_size );
pOpenGL->Enable(!g_bdisable_opengl);

// Smooth Pan/Zoom checkbox
pSmoothPanZoom = new wxCheckBox( itemPanelUI, ID_SMOOTHPANZOOMBOX,
Expand Down

0 comments on commit 440d51c

Please sign in to comment.