make SetVideoMode not throw

This commit is contained in:
Glenn Maynard
2004-11-30 20:01:07 +00:00
parent 388fb41404
commit 6f46898f69
6 changed files with 30 additions and 19 deletions
+9 -9
View File
@@ -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()
+1 -1
View File
@@ -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() { }
+10 -2
View File
@@ -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,
+2 -1
View File
@@ -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()
+5 -5
View File
@@ -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
+3 -1
View File
@@ -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,