make SetVideoMode not throw
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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() { }
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user