Work on improving error messages when video init fails
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user