diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 5428572acc..04c7451475 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -45,30 +45,30 @@ CString RageDisplay::PixelFormatToString( PixelFormat pixfmt ) return s[pixfmt]; }; -// Return true if device was re-created and we need to reload textures. -bool RageDisplay::SetVideoMode( VideoModeParams p ) +/* bNeedReloadTextures is set to true if the device was re-created and we need + * to reload textures. On failure, an error message is returned. + * XXX: the renderer itself should probably be the one to try fallback modes */ +CString RageDisplay::SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures ) { - bool bNeedReloadTextures; - CString err; err = this->TryVideoMode(p,bNeedReloadTextures); if( err == "" ) - return bNeedReloadTextures; + return ""; LOG->Trace( "TryVideoMode failed: %s", err.c_str() ); // fall back p.windowed = false; if( this->TryVideoMode(p,bNeedReloadTextures) == "" ) - return bNeedReloadTextures; + return ""; p.bpp = 16; if( this->TryVideoMode(p,bNeedReloadTextures) == "" ) - return bNeedReloadTextures; + return ""; p.width = 640; p.height = 480; if( this->TryVideoMode(p,bNeedReloadTextures) == "" ) - return bNeedReloadTextures; + return ""; - RageException::ThrowNonfatal( "SetVideoMode failed: %s", err.c_str() ); + return ssprintf( "SetVideoMode failed: %s", err.c_str() ); } void RageDisplay::ProcessStatsOnFlip() diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 9485e7adae..d66a59a2c5 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -153,7 +153,7 @@ public: // Don't override this. Override TryVideoMode() instead. // This will set the video mode to be as close as possible to params. // Return true if device was re-created and we need to reload textures. - bool SetVideoMode( VideoModeParams params ); + CString SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures ); /* Call this when the resolution has been changed externally: */ virtual void ResolutionChanged() { } diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 28e383d790..9e74c0e1f4 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -268,7 +268,10 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p ) * actually initialize the window. Do this after as many error conditions * as possible, because if we have to shut it down again we'll flash a window * briefly. */ - SetVideoMode( p ); + bool bIgnore = false; + CString sError = SetVideoMode( p, bIgnore ); + if( sError != "" ) + RageException::ThrowNonfatal( sError ); } catch(...) { // Clean up; ~RageDisplay will not be called. if( g_pd3d ) @@ -629,9 +632,14 @@ bool RageDisplay_D3D::BeginFrame() case D3DERR_DEVICELOST: return false; case D3DERR_DEVICENOTRESET: - SetVideoMode( GraphicsWindow::GetParams() ); + { + bool bIgnore = false; + CString sError = SetVideoMode( GraphicsWindow::GetParams(), bIgnore ); + if( sError != "" ) + RageException::Throw( sError ); break; } + } #endif g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, diff --git a/stepmania/src/RageDisplay_Null.cpp b/stepmania/src/RageDisplay_Null.cpp index 2e507dff1a..60c1fd422d 100644 --- a/stepmania/src/RageDisplay_Null.cpp +++ b/stepmania/src/RageDisplay_Null.cpp @@ -75,7 +75,8 @@ static RageDisplay::PixelFormatDesc PIXEL_FORMAT_DESC[RageDisplay::NUM_PIX_FORMA RageDisplay_Null::RageDisplay_Null( VideoModeParams p ) { LOG->MapLog("renderer", "Current renderer: null"); - SetVideoMode( p ); + bool bIgnore = false; + SetVideoMode( p, bIgnore ); } RageSurface* RageDisplay_Null::CreateScreenshot() diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 04ea3e7c87..d10988bdaf 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -368,12 +368,12 @@ RageDisplay_OGL::RageDisplay_OGL( VideoModeParams p, bool bAllowUnacceleratedRen wind = MakeLowLevelWindow(); - try { - SetVideoMode( p ); - } catch(...) { - /* SetVideoMode can throw. */ + bool bIgnore = false; + CString sError = SetVideoMode( p, bIgnore ); + if( sError != "" ) + { delete wind; - throw; + RageException::ThrowNonfatal( sError ); } // Log driver details diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 993e5a81ba..1c5b784533 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -128,7 +128,9 @@ void ApplyGraphicOptions() { bool bNeedReload = false; - bNeedReload |= DISPLAY->SetVideoMode( GetCurVideoModeParams() ); + CString sError = DISPLAY->SetVideoMode( GetCurVideoModeParams(), bNeedReload ); + if( sError != "" ) + RageException::Throw( sError ); DISPLAY->ChangeCentering( PREFSMAN->m_iCenterImageTranslateX,