From 98c7c09cc7100506c0213f7ca5c20bb7da2e94af Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 27 Aug 2003 23:36:09 +0000 Subject: [PATCH] Work on improving error messages when video init fails --- stepmania/src/RageDisplay.cpp | 13 ++++++++----- stepmania/src/RageDisplay.h | 4 ++-- stepmania/src/RageDisplay_D3D.cpp | 6 +++--- stepmania/src/RageDisplay_D3D.h | 2 +- stepmania/src/RageDisplay_OGL.cpp | 6 +++--- stepmania/src/RageDisplay_OGL.h | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 7c0806dd5c..4f3ca12704 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -78,22 +78,25 @@ bool RageDisplay::SetVideoMode( VideoModeParams p ) bool bNeedReloadTextures; - if( this->TryVideoMode(p,bNeedReloadTextures) ) + CString err; + err = this->TryVideoMode(p,bNeedReloadTextures); + if( err == "" ) return bNeedReloadTextures; // fall back p.windowed = false; - if( this->TryVideoMode(p,bNeedReloadTextures) ) + if( this->TryVideoMode(p,bNeedReloadTextures) == "" ) return bNeedReloadTextures; p.bpp = 16; - if( this->TryVideoMode(p,bNeedReloadTextures) ) + if( this->TryVideoMode(p,bNeedReloadTextures) == "" ) return bNeedReloadTextures; p.width = 640; p.height = 480; - if( this->TryVideoMode(p,bNeedReloadTextures) ) + if( this->TryVideoMode(p,bNeedReloadTextures) == "" ) return bNeedReloadTextures; - RageException::ThrowNonfatal( "SetVideoMode failed. Tried to fall back to other modes, but nothing worked." ); + RageException::ThrowNonfatal( "SetVideoMode failed: %s. Tried to fall back to other modes, but nothing worked.", + err.c_str() ); } void RageDisplay::ProcessStatsOnFlip() diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index e97b490e6a..b187f1947b 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -198,10 +198,10 @@ public: virtual CString GetTextureDiagnostics( unsigned id ) const { return ""; } protected: - // Return true if mode change was successful. + // Return "" if mode change was successful, an error message otherwise. // bNewDeviceOut is set true if a new device was created and textures // need to be reloaded. - virtual bool TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ) = 0; + virtual CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ) = 0; virtual void SetViewport(int shift_left, int shift_down) = 0; diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index cabe48819a..496143e992 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -437,14 +437,14 @@ HWND GetHwnd() /* Set the video mode. */ -bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) +CString RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) { g_CurrentParams = p; HRESULT hr; if( FindBackBufferType( p.windowed, p.bpp ) == -1 ) // no possible back buffer formats - return false; // failed to set mode + return ssprintf( "FindBackBufferType(%i,%i) failed", p.windowed, p.bpp ); // failed to set mode #if defined _WINDOWS /* Set SDL window title and icon -before- creating the window */ @@ -563,7 +563,7 @@ bool RageDisplay_D3D::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) /* Palettes were lost by Reset(), so mark them unloaded. */ g_TexResourceToPaletteIndex.clear(); - return true; // mode change successful + return ""; // mode change successful } void RageDisplay_D3D::ResolutionChanged() diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 5d42ac6ac8..e870afc954 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -75,7 +75,7 @@ public: void SaveScreenshot( CString sPath ); protected: - bool TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ); + CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ); void SetViewport(int shift_left, int shift_down); RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 1022b5368e..b7a3673e87 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -535,11 +535,11 @@ void RageDisplay_OGL::ResolutionChanged() // Return true if mode change was successful. // bNewDeviceOut is set true if a new device was created and textures // need to be reloaded. -bool RageDisplay_OGL::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) +CString RageDisplay_OGL::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) { // LOG->Trace( "RageDisplay_OGL::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync ); if( !wind->TryVideoMode( p, bNewDeviceOut ) ) - return false; // failed to set video mode + return "wind->TryVideoMode() failed"; // failed to set video mode XXX: error message if( bNewDeviceOut ) { @@ -563,7 +563,7 @@ bool RageDisplay_OGL::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) ResolutionChanged(); - return true; // successfully set mode + return ""; // successfully set mode } void RageDisplay_OGL::SetViewport(int shift_left, int shift_down) diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index c56358895c..f8e8781266 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -62,7 +62,7 @@ public: void SaveScreenshot( CString sPath ); protected: - bool TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ); + CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ); void SetViewport(int shift_left, int shift_down); RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); PixelFormat GetImgPixelFormat( SDL_Surface* &img, bool &FreeImg, int width, int height );