make SetVideoMode not throw
This commit is contained in:
@@ -45,30 +45,30 @@ CString RageDisplay::PixelFormatToString( PixelFormat pixfmt )
|
|||||||
return s[pixfmt];
|
return s[pixfmt];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return true if device was re-created and we need to reload textures.
|
/* bNeedReloadTextures is set to true if the device was re-created and we need
|
||||||
bool RageDisplay::SetVideoMode( VideoModeParams p )
|
* 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;
|
CString err;
|
||||||
err = this->TryVideoMode(p,bNeedReloadTextures);
|
err = this->TryVideoMode(p,bNeedReloadTextures);
|
||||||
if( err == "" )
|
if( err == "" )
|
||||||
return bNeedReloadTextures;
|
return "";
|
||||||
LOG->Trace( "TryVideoMode failed: %s", err.c_str() );
|
LOG->Trace( "TryVideoMode failed: %s", err.c_str() );
|
||||||
|
|
||||||
// fall back
|
// fall back
|
||||||
p.windowed = false;
|
p.windowed = false;
|
||||||
if( this->TryVideoMode(p,bNeedReloadTextures) == "" )
|
if( this->TryVideoMode(p,bNeedReloadTextures) == "" )
|
||||||
return bNeedReloadTextures;
|
return "";
|
||||||
p.bpp = 16;
|
p.bpp = 16;
|
||||||
if( this->TryVideoMode(p,bNeedReloadTextures) == "" )
|
if( this->TryVideoMode(p,bNeedReloadTextures) == "" )
|
||||||
return bNeedReloadTextures;
|
return "";
|
||||||
p.width = 640;
|
p.width = 640;
|
||||||
p.height = 480;
|
p.height = 480;
|
||||||
if( this->TryVideoMode(p,bNeedReloadTextures) == "" )
|
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()
|
void RageDisplay::ProcessStatsOnFlip()
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public:
|
|||||||
// Don't override this. Override TryVideoMode() instead.
|
// Don't override this. Override TryVideoMode() instead.
|
||||||
// This will set the video mode to be as close as possible to params.
|
// 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.
|
// 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: */
|
/* Call this when the resolution has been changed externally: */
|
||||||
virtual void ResolutionChanged() { }
|
virtual void ResolutionChanged() { }
|
||||||
|
|||||||
@@ -268,7 +268,10 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p )
|
|||||||
* actually initialize the window. Do this after as many error conditions
|
* 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
|
* as possible, because if we have to shut it down again we'll flash a window
|
||||||
* briefly. */
|
* briefly. */
|
||||||
SetVideoMode( p );
|
bool bIgnore = false;
|
||||||
|
CString sError = SetVideoMode( p, bIgnore );
|
||||||
|
if( sError != "" )
|
||||||
|
RageException::ThrowNonfatal( sError );
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
// Clean up; ~RageDisplay will not be called.
|
// Clean up; ~RageDisplay will not be called.
|
||||||
if( g_pd3d )
|
if( g_pd3d )
|
||||||
@@ -629,9 +632,14 @@ bool RageDisplay_D3D::BeginFrame()
|
|||||||
case D3DERR_DEVICELOST:
|
case D3DERR_DEVICELOST:
|
||||||
return false;
|
return false;
|
||||||
case D3DERR_DEVICENOTRESET:
|
case D3DERR_DEVICENOTRESET:
|
||||||
SetVideoMode( GraphicsWindow::GetParams() );
|
{
|
||||||
|
bool bIgnore = false;
|
||||||
|
CString sError = SetVideoMode( GraphicsWindow::GetParams(), bIgnore );
|
||||||
|
if( sError != "" )
|
||||||
|
RageException::Throw( sError );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
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 )
|
RageDisplay_Null::RageDisplay_Null( VideoModeParams p )
|
||||||
{
|
{
|
||||||
LOG->MapLog("renderer", "Current renderer: null");
|
LOG->MapLog("renderer", "Current renderer: null");
|
||||||
SetVideoMode( p );
|
bool bIgnore = false;
|
||||||
|
SetVideoMode( p, bIgnore );
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSurface* RageDisplay_Null::CreateScreenshot()
|
RageSurface* RageDisplay_Null::CreateScreenshot()
|
||||||
|
|||||||
@@ -368,12 +368,12 @@ RageDisplay_OGL::RageDisplay_OGL( VideoModeParams p, bool bAllowUnacceleratedRen
|
|||||||
|
|
||||||
wind = MakeLowLevelWindow();
|
wind = MakeLowLevelWindow();
|
||||||
|
|
||||||
try {
|
bool bIgnore = false;
|
||||||
SetVideoMode( p );
|
CString sError = SetVideoMode( p, bIgnore );
|
||||||
} catch(...) {
|
if( sError != "" )
|
||||||
/* SetVideoMode can throw. */
|
{
|
||||||
delete wind;
|
delete wind;
|
||||||
throw;
|
RageException::ThrowNonfatal( sError );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log driver details
|
// Log driver details
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ void ApplyGraphicOptions()
|
|||||||
{
|
{
|
||||||
bool bNeedReload = false;
|
bool bNeedReload = false;
|
||||||
|
|
||||||
bNeedReload |= DISPLAY->SetVideoMode( GetCurVideoModeParams() );
|
CString sError = DISPLAY->SetVideoMode( GetCurVideoModeParams(), bNeedReload );
|
||||||
|
if( sError != "" )
|
||||||
|
RageException::Throw( sError );
|
||||||
|
|
||||||
DISPLAY->ChangeCentering(
|
DISPLAY->ChangeCentering(
|
||||||
PREFSMAN->m_iCenterImageTranslateX,
|
PREFSMAN->m_iCenterImageTranslateX,
|
||||||
|
|||||||
Reference in New Issue
Block a user