Simplify exception handling. Improve fallback if we can't set up an

OpenGL window.
This commit is contained in:
Glenn Maynard
2003-06-25 20:44:49 +00:00
parent 1d655dcb7a
commit 2206e32cef
4 changed files with 28 additions and 15 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ bool RageDisplay::SetVideoMode( VideoModeParams p )
if( this->TryVideoMode(p,bNeedReloadTextures) ) if( this->TryVideoMode(p,bNeedReloadTextures) )
return bNeedReloadTextures; return bNeedReloadTextures;
RageException::Throw( "SetVideoMode failed. Tried to fall back to other modes, but nothing worked." ); RageException::ThrowNonfatal( "SetVideoMode failed. Tried to fall back to other modes, but nothing worked." );
} }
void RageDisplay::ProcessStatsOnFlip() void RageDisplay::ProcessStatsOnFlip()
+18 -2
View File
@@ -232,7 +232,7 @@ static void FlushGLErrors()
; ;
} }
RageDisplay_OGL::RageDisplay_OGL( VideoModeParams p ) RageDisplay_OGL::RageDisplay_OGL( VideoModeParams p, bool bAllowUnacceleratedRenderer )
{ {
LOG->Trace( "RageDisplay_OGL::RageDisplay_OGL()" ); LOG->Trace( "RageDisplay_OGL::RageDisplay_OGL()" );
LOG->MapLog("renderer", "Current renderer: OpenGL"); LOG->MapLog("renderer", "Current renderer: OpenGL");
@@ -241,15 +241,31 @@ RageDisplay_OGL::RageDisplay_OGL( VideoModeParams p )
wind = MakeLowLevelWindow(); wind = MakeLowLevelWindow();
SetVideoMode( p ); try {
SetVideoMode( p );
} catch(...) {
/* SetVideoMode can throw. */
delete wind;
throw;
}
// Log driver details // Log driver details
LOG->Info("OGL Vendor: %s", glGetString(GL_VENDOR)); LOG->Info("OGL Vendor: %s", glGetString(GL_VENDOR));
LOG->Info("OGL Renderer: %s", glGetString(GL_RENDERER)); LOG->Info("OGL Renderer: %s", glGetString(GL_RENDERER));
LOG->Info("OGL Version: %s", glGetString(GL_VERSION)); LOG->Info("OGL Version: %s", glGetString(GL_VERSION));
LOG->Info("OGL Extensions: %s", glGetString(GL_EXTENSIONS)); LOG->Info("OGL Extensions: %s", glGetString(GL_EXTENSIONS));
if( IsSoftwareRenderer() ) if( IsSoftwareRenderer() )
{
if( !bAllowUnacceleratedRenderer )
{
delete wind;
RageException::ThrowNonfatal(
"Your system is reporting that OpenGL hardware acceleration is not available. "
"Please obtain an updated driver from your video card manufacturer.\n\n" );
}
LOG->Warn("This is a software renderer!"); LOG->Warn("This is a software renderer!");
}
/* Log this, so if people complain that the radar looks bad on their /* Log this, so if people complain that the radar looks bad on their
+1 -1
View File
@@ -4,7 +4,7 @@
class RageDisplay_OGL: public RageDisplay class RageDisplay_OGL: public RageDisplay
{ {
public: public:
RageDisplay_OGL( VideoModeParams params ); RageDisplay_OGL( VideoModeParams params, bool bAllowUnacceleratedRenderer );
virtual ~RageDisplay_OGL(); virtual ~RageDisplay_OGL();
void Update(float fDeltaTime); void Update(float fDeltaTime);
+8 -11
View File
@@ -378,17 +378,12 @@ RageDisplay *CreateDisplay()
* SDL may throw, but that only happens with broken driver installations, and * SDL may throw, but that only happens with broken driver installations, and
* we probably don't want to fall back on D3D in that case anyway.) */ * we probably don't want to fall back on D3D in that case anyway.) */
error += "Initializing OpenGL...\n"; error += "Initializing OpenGL...\n";
try {
RageDisplay *ret = new RageDisplay_OGL( params ); return new RageDisplay_OGL( params, PREFSMAN->m_bAllowUnacceleratedRenderer );
} catch(RageException e) {
if( PREFSMAN->m_bAllowUnacceleratedRenderer || !ret->IsSoftwareRenderer() ) error += CString(e.what()) + "\n";
return ret; continue;
else };
{
error += "Your system is reporting that OpenGL hardware acceleration is not available. "
"Please obtain an updated driver from your video card manufacturer.\n\n";
delete ret;
}
#endif #endif
} }
else if( sRenderer.CompareNoCase("d3d")==0 ) else if( sRenderer.CompareNoCase("d3d")==0 )
@@ -402,6 +397,8 @@ RageDisplay *CreateDisplay()
} catch(RageException_D3DNoAcceleration e) { } catch(RageException_D3DNoAcceleration e) {
error += "Your system is reporting that Direct3D hardware acceleration is not available. " error += "Your system is reporting that Direct3D hardware acceleration is not available. "
"Please obtain an updated driver from your video card manufacturer.\n\n"; "Please obtain an updated driver from your video card manufacturer.\n\n";
} catch(RageException e) {
error += CString(e.what()) + "\n";
}; };
#endif #endif
} }