make RageDisplay::Init virtual to remove dupe code
This commit is contained in:
@@ -135,6 +135,8 @@ public:
|
||||
/* This is needed or the overridden classes' dtors will not be called. */
|
||||
virtual ~RageDisplay() { }
|
||||
|
||||
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer ) = 0;
|
||||
|
||||
virtual RString GetApiDescription() const = 0;
|
||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const = 0;
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ RageDisplay_D3D::RageDisplay_D3D()
|
||||
"DirectX 8.1 or greater is not installed. You can download it from:\n" \
|
||||
"http://www.microsoft.com/downloads/details.aspx?FamilyID=a19bed22-0b25-4e5d-a584-6389d8a3dad0&displaylang=en"
|
||||
|
||||
RString RageDisplay_D3D::Init( VideoModeParams p )
|
||||
RString RageDisplay_D3D::Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer )
|
||||
{
|
||||
GraphicsWindow::Initialize( true );
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class RageDisplay_D3D: public RageDisplay
|
||||
public:
|
||||
RageDisplay_D3D();
|
||||
virtual ~RageDisplay_D3D();
|
||||
RString Init( VideoModeParams p );
|
||||
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer );
|
||||
|
||||
virtual RString GetApiDescription() const { return "D3D"; }
|
||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
||||
|
||||
@@ -71,11 +71,16 @@ static RageDisplay::PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PixelFormat] = {
|
||||
};
|
||||
|
||||
|
||||
RageDisplay_Null::RageDisplay_Null( VideoModeParams p )
|
||||
RageDisplay_Null::RageDisplay_Null()
|
||||
{
|
||||
LOG->MapLog("renderer", "Current renderer: null");
|
||||
}
|
||||
|
||||
RString RageDisplay_Null::Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer )
|
||||
{
|
||||
bool bIgnore = false;
|
||||
SetVideoMode( p, bIgnore );
|
||||
return RString();
|
||||
}
|
||||
|
||||
void RageDisplay_Null::GetDisplayResolutions( DisplayResolutions &out ) const
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
class RageDisplay_Null: public RageDisplay
|
||||
{
|
||||
public:
|
||||
RageDisplay_Null( VideoModeParams p );
|
||||
RageDisplay_Null();
|
||||
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer );
|
||||
|
||||
virtual RString GetApiDescription() const { return "Null"; }
|
||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
||||
|
||||
@@ -387,7 +387,7 @@ void InitScalingScript()
|
||||
GLExt.glVertexAttrib2fARB( ATTRIB_TEXTURE_MATRIX_SCALE, 1, 1 );
|
||||
}
|
||||
|
||||
RString RageDisplay_OGL::Init( VideoModeParams p, bool bAllowUnacceleratedRenderer )
|
||||
RString RageDisplay_OGL::Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer )
|
||||
{
|
||||
g_pWind = MakeLowLevelWindow();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class RageDisplay_OGL: public RageDisplay
|
||||
public:
|
||||
RageDisplay_OGL();
|
||||
virtual ~RageDisplay_OGL();
|
||||
RString Init( VideoModeParams p, bool bAllowUnacceleratedRenderer );
|
||||
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer );
|
||||
|
||||
virtual RString GetApiDescription() const { return "OpenGL"; }
|
||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
||||
|
||||
+44
-36
@@ -102,30 +102,30 @@ void StepMania::GetPreferredVideoModeParams( VideoModeParams ¶msOut )
|
||||
CommonMetrics::WINDOW_TITLE,
|
||||
THEME->GetPathG("Common","window icon"),
|
||||
PREFSMAN->m_bPAL,
|
||||
ScreenDimensions::GetScreenAspectRatio()
|
||||
PREFSMAN->m_fDisplayAspectRatio
|
||||
);
|
||||
}
|
||||
|
||||
static LocalizedString COLOR ("StepMania","color");
|
||||
static LocalizedString TEXTURE ("StepMania","texture");
|
||||
static LocalizedString WINDOWED ("StepMania","Windowed");
|
||||
static LocalizedString FULLSCREEN ("StepMania","Fullscreen");
|
||||
static LocalizedString ANNOUNCER_ ("StepMania","Announcer");
|
||||
static LocalizedString VSYNC ("StepMania","Vsync");
|
||||
static LocalizedString NO_VSYNC ("StepMania","NoVsync");
|
||||
static LocalizedString SMOOTH_LINES ("StepMania","SmoothLines");
|
||||
static LocalizedString COLOR ("StepMania","color");
|
||||
static LocalizedString TEXTURE ("StepMania","texture");
|
||||
static LocalizedString WINDOWED ("StepMania","Windowed");
|
||||
static LocalizedString FULLSCREEN ("StepMania","Fullscreen");
|
||||
static LocalizedString ANNOUNCER_ ("StepMania","Announcer");
|
||||
static LocalizedString VSYNC ("StepMania","Vsync");
|
||||
static LocalizedString NO_VSYNC ("StepMania","NoVsync");
|
||||
static LocalizedString SMOOTH_LINES ("StepMania","SmoothLines");
|
||||
static LocalizedString NO_SMOOTH_LINES ("StepMania","NoSmoothLines");
|
||||
|
||||
static void StoreActualGraphicOptions( bool initial )
|
||||
{
|
||||
// find out what we actually have
|
||||
const VideoModeParams ¶ms = DISPLAY->GetActualVideoModeParams();
|
||||
PREFSMAN->m_bWindowed .Set( params.windowed );
|
||||
PREFSMAN->m_iDisplayWidth .Set( params.width );
|
||||
PREFSMAN->m_iDisplayHeight .Set( params.height );
|
||||
PREFSMAN->m_iDisplayColorDepth .Set( params.bpp );
|
||||
PREFSMAN->m_iRefreshRate .Set( params.rate );
|
||||
PREFSMAN->m_bVsync .Set( params.vsync );
|
||||
PREFSMAN->m_bWindowed .Set( params.windowed );
|
||||
PREFSMAN->m_iDisplayWidth .Set( params.width );
|
||||
PREFSMAN->m_iDisplayHeight .Set( params.height );
|
||||
PREFSMAN->m_iDisplayColorDepth .Set( params.bpp );
|
||||
PREFSMAN->m_iRefreshRate .Set( params.rate );
|
||||
PREFSMAN->m_bVsync .Set( params.vsync );
|
||||
|
||||
RString sFormat = "%s %s %dx%d %d "+COLOR.GetValue()+" %d "+TEXTURE.GetValue()+" %dHz %s %s";
|
||||
RString log = ssprintf( sFormat,
|
||||
@@ -155,6 +155,7 @@ static void StartDisplay()
|
||||
|
||||
DISPLAY = CreateDisplay();
|
||||
|
||||
|
||||
DISPLAY->ChangeCentering(
|
||||
PREFSMAN->m_iCenterImageTranslateX,
|
||||
PREFSMAN->m_iCenterImageTranslateY,
|
||||
@@ -579,7 +580,7 @@ static RString GetVideoDriverName()
|
||||
#endif
|
||||
}
|
||||
|
||||
static void CheckVideoDefaultSettings()
|
||||
static bool CheckVideoDefaultSettings()
|
||||
{
|
||||
// Video card changed since last run
|
||||
RString sVideoDriver = GetVideoDriverName();
|
||||
@@ -604,19 +605,19 @@ static void CheckVideoDefaultSettings()
|
||||
|
||||
found_defaults:
|
||||
|
||||
bool SetDefaultVideoParams=false;
|
||||
bool bSetDefaultVideoParams = false;
|
||||
if( PREFSMAN->m_sVideoRenderers.Get() == "" )
|
||||
{
|
||||
SetDefaultVideoParams = true;
|
||||
bSetDefaultVideoParams = true;
|
||||
LOG->Trace( "Applying defaults for %s.", sVideoDriver.c_str() );
|
||||
}
|
||||
else if( PREFSMAN->m_sLastSeenVideoDriver.Get() != sVideoDriver )
|
||||
{
|
||||
SetDefaultVideoParams = true;
|
||||
bSetDefaultVideoParams = true;
|
||||
LOG->Trace( "Video card has changed from %s to %s. Applying new defaults.", PREFSMAN->m_sLastSeenVideoDriver.Get().c_str(), sVideoDriver.c_str() );
|
||||
}
|
||||
|
||||
if( SetDefaultVideoParams )
|
||||
if( bSetDefaultVideoParams )
|
||||
{
|
||||
PREFSMAN->m_sVideoRenderers.Set( defaults.sVideoRenderers );
|
||||
PREFSMAN->m_iDisplayWidth.Set( defaults.iWidth );
|
||||
@@ -634,10 +635,10 @@ found_defaults:
|
||||
{
|
||||
LOG->Warn("Video renderer list has been changed from '%s' to '%s'",
|
||||
defaults.sVideoRenderers.c_str(), PREFSMAN->m_sVideoRenderers.Get().c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
LOG->Info( "Video renderers: '%s'", PREFSMAN->m_sVideoRenderers.Get().c_str() );
|
||||
return bSetDefaultVideoParams;
|
||||
}
|
||||
|
||||
static LocalizedString ERROR_INITIALIZING_CARD ( "StepMania", "There was an error while initializing your video card." );
|
||||
@@ -672,7 +673,7 @@ RageDisplay *CreateDisplay()
|
||||
* Actually, right now we're falling back. I'm not sure which behavior is better.
|
||||
*/
|
||||
|
||||
CheckVideoDefaultSettings();
|
||||
bool bAppliedDefaults = CheckVideoDefaultSettings();
|
||||
|
||||
VideoModeParams params;
|
||||
StepMania::GetPreferredVideoModeParams( params );
|
||||
@@ -688,6 +689,7 @@ RageDisplay *CreateDisplay()
|
||||
if( asRenderers.empty() )
|
||||
RageException::Throw( ERROR_NO_VIDEO_RENDERERS.GetValue() );
|
||||
|
||||
RageDisplay *pRet = NULL;
|
||||
for( unsigned i=0; i<asRenderers.size(); i++ )
|
||||
{
|
||||
RString sRenderer = asRenderers[i];
|
||||
@@ -695,38 +697,44 @@ RageDisplay *CreateDisplay()
|
||||
if( sRenderer.CompareNoCase("opengl")==0 )
|
||||
{
|
||||
#if defined(SUPPORT_OPENGL)
|
||||
RageDisplay_OGL *pRet = new RageDisplay_OGL;
|
||||
RString sError = pRet->Init( params, PREFSMAN->m_bAllowUnacceleratedRenderer );
|
||||
if( sError == "" )
|
||||
return pRet;
|
||||
error += ssprintf(ERROR_INITIALIZING.GetValue(),"OpenGL")+"\n" + sError;
|
||||
delete pRet;
|
||||
pRet = new RageDisplay_OGL;
|
||||
#endif
|
||||
}
|
||||
else if( sRenderer.CompareNoCase("d3d")==0 )
|
||||
{
|
||||
#if defined(SUPPORT_D3D)
|
||||
RageDisplay_D3D *pRet = new RageDisplay_D3D;
|
||||
RString sError = pRet->Init( params );
|
||||
if( sError == "" )
|
||||
return pRet;
|
||||
error += ssprintf(ERROR_INITIALIZING.GetValue(),"Direct3D")+"\n" + sError;
|
||||
delete pRet;
|
||||
#endif
|
||||
}
|
||||
else if( sRenderer.CompareNoCase("null")==0 )
|
||||
{
|
||||
return new RageDisplay_Null( params );
|
||||
return new RageDisplay_Null();
|
||||
}
|
||||
else
|
||||
{
|
||||
RageException::Throw( ERROR_UNKNOWN_VIDEO_RENDERER.GetValue(), sRenderer.c_str() );
|
||||
}
|
||||
|
||||
error += "\n\n\n";
|
||||
if( pRet == NULL )
|
||||
continue;
|
||||
|
||||
RString sError = pRet->Init( params, PREFSMAN->m_bAllowUnacceleratedRenderer );
|
||||
if( sError.empty() )
|
||||
{
|
||||
break; // we have a display, don't try any more
|
||||
}
|
||||
else
|
||||
{
|
||||
error += ssprintf(ERROR_INITIALIZING.GetValue(),sRenderer)+"\n" + sError;
|
||||
SAFE_DELETE( pRet );
|
||||
error += "\n\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
RageException::Throw( error );
|
||||
if( pRet == NULL)
|
||||
RageException::Throw( error );
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
extern const RString STATIC_INI_PATH;
|
||||
|
||||
Reference in New Issue
Block a user