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. */
|
/* This is needed or the overridden classes' dtors will not be called. */
|
||||||
virtual ~RageDisplay() { }
|
virtual ~RageDisplay() { }
|
||||||
|
|
||||||
|
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer ) = 0;
|
||||||
|
|
||||||
virtual RString GetApiDescription() const = 0;
|
virtual RString GetApiDescription() const = 0;
|
||||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) 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" \
|
"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"
|
"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 );
|
GraphicsWindow::Initialize( true );
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class RageDisplay_D3D: public RageDisplay
|
|||||||
public:
|
public:
|
||||||
RageDisplay_D3D();
|
RageDisplay_D3D();
|
||||||
virtual ~RageDisplay_D3D();
|
virtual ~RageDisplay_D3D();
|
||||||
RString Init( VideoModeParams p );
|
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer );
|
||||||
|
|
||||||
virtual RString GetApiDescription() const { return "D3D"; }
|
virtual RString GetApiDescription() const { return "D3D"; }
|
||||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
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");
|
LOG->MapLog("renderer", "Current renderer: null");
|
||||||
|
}
|
||||||
|
|
||||||
|
RString RageDisplay_Null::Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer )
|
||||||
|
{
|
||||||
bool bIgnore = false;
|
bool bIgnore = false;
|
||||||
SetVideoMode( p, bIgnore );
|
SetVideoMode( p, bIgnore );
|
||||||
|
return RString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_Null::GetDisplayResolutions( DisplayResolutions &out ) const
|
void RageDisplay_Null::GetDisplayResolutions( DisplayResolutions &out ) const
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
class RageDisplay_Null: public RageDisplay
|
class RageDisplay_Null: public RageDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageDisplay_Null( VideoModeParams p );
|
RageDisplay_Null();
|
||||||
|
virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer );
|
||||||
|
|
||||||
virtual RString GetApiDescription() const { return "Null"; }
|
virtual RString GetApiDescription() const { return "Null"; }
|
||||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ void InitScalingScript()
|
|||||||
GLExt.glVertexAttrib2fARB( ATTRIB_TEXTURE_MATRIX_SCALE, 1, 1 );
|
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();
|
g_pWind = MakeLowLevelWindow();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class RageDisplay_OGL: public RageDisplay
|
|||||||
public:
|
public:
|
||||||
RageDisplay_OGL();
|
RageDisplay_OGL();
|
||||||
virtual ~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 RString GetApiDescription() const { return "OpenGL"; }
|
||||||
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
virtual void GetDisplayResolutions( DisplayResolutions &out ) const;
|
||||||
|
|||||||
+44
-36
@@ -102,30 +102,30 @@ void StepMania::GetPreferredVideoModeParams( VideoModeParams ¶msOut )
|
|||||||
CommonMetrics::WINDOW_TITLE,
|
CommonMetrics::WINDOW_TITLE,
|
||||||
THEME->GetPathG("Common","window icon"),
|
THEME->GetPathG("Common","window icon"),
|
||||||
PREFSMAN->m_bPAL,
|
PREFSMAN->m_bPAL,
|
||||||
ScreenDimensions::GetScreenAspectRatio()
|
PREFSMAN->m_fDisplayAspectRatio
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LocalizedString COLOR ("StepMania","color");
|
static LocalizedString COLOR ("StepMania","color");
|
||||||
static LocalizedString TEXTURE ("StepMania","texture");
|
static LocalizedString TEXTURE ("StepMania","texture");
|
||||||
static LocalizedString WINDOWED ("StepMania","Windowed");
|
static LocalizedString WINDOWED ("StepMania","Windowed");
|
||||||
static LocalizedString FULLSCREEN ("StepMania","Fullscreen");
|
static LocalizedString FULLSCREEN ("StepMania","Fullscreen");
|
||||||
static LocalizedString ANNOUNCER_ ("StepMania","Announcer");
|
static LocalizedString ANNOUNCER_ ("StepMania","Announcer");
|
||||||
static LocalizedString VSYNC ("StepMania","Vsync");
|
static LocalizedString VSYNC ("StepMania","Vsync");
|
||||||
static LocalizedString NO_VSYNC ("StepMania","NoVsync");
|
static LocalizedString NO_VSYNC ("StepMania","NoVsync");
|
||||||
static LocalizedString SMOOTH_LINES ("StepMania","SmoothLines");
|
static LocalizedString SMOOTH_LINES ("StepMania","SmoothLines");
|
||||||
static LocalizedString NO_SMOOTH_LINES ("StepMania","NoSmoothLines");
|
static LocalizedString NO_SMOOTH_LINES ("StepMania","NoSmoothLines");
|
||||||
|
|
||||||
static void StoreActualGraphicOptions( bool initial )
|
static void StoreActualGraphicOptions( bool initial )
|
||||||
{
|
{
|
||||||
// find out what we actually have
|
// find out what we actually have
|
||||||
const VideoModeParams ¶ms = DISPLAY->GetActualVideoModeParams();
|
const VideoModeParams ¶ms = DISPLAY->GetActualVideoModeParams();
|
||||||
PREFSMAN->m_bWindowed .Set( params.windowed );
|
PREFSMAN->m_bWindowed .Set( params.windowed );
|
||||||
PREFSMAN->m_iDisplayWidth .Set( params.width );
|
PREFSMAN->m_iDisplayWidth .Set( params.width );
|
||||||
PREFSMAN->m_iDisplayHeight .Set( params.height );
|
PREFSMAN->m_iDisplayHeight .Set( params.height );
|
||||||
PREFSMAN->m_iDisplayColorDepth .Set( params.bpp );
|
PREFSMAN->m_iDisplayColorDepth .Set( params.bpp );
|
||||||
PREFSMAN->m_iRefreshRate .Set( params.rate );
|
PREFSMAN->m_iRefreshRate .Set( params.rate );
|
||||||
PREFSMAN->m_bVsync .Set( params.vsync );
|
PREFSMAN->m_bVsync .Set( params.vsync );
|
||||||
|
|
||||||
RString sFormat = "%s %s %dx%d %d "+COLOR.GetValue()+" %d "+TEXTURE.GetValue()+" %dHz %s %s";
|
RString sFormat = "%s %s %dx%d %d "+COLOR.GetValue()+" %d "+TEXTURE.GetValue()+" %dHz %s %s";
|
||||||
RString log = ssprintf( sFormat,
|
RString log = ssprintf( sFormat,
|
||||||
@@ -155,6 +155,7 @@ static void StartDisplay()
|
|||||||
|
|
||||||
DISPLAY = CreateDisplay();
|
DISPLAY = CreateDisplay();
|
||||||
|
|
||||||
|
|
||||||
DISPLAY->ChangeCentering(
|
DISPLAY->ChangeCentering(
|
||||||
PREFSMAN->m_iCenterImageTranslateX,
|
PREFSMAN->m_iCenterImageTranslateX,
|
||||||
PREFSMAN->m_iCenterImageTranslateY,
|
PREFSMAN->m_iCenterImageTranslateY,
|
||||||
@@ -579,7 +580,7 @@ static RString GetVideoDriverName()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckVideoDefaultSettings()
|
static bool CheckVideoDefaultSettings()
|
||||||
{
|
{
|
||||||
// Video card changed since last run
|
// Video card changed since last run
|
||||||
RString sVideoDriver = GetVideoDriverName();
|
RString sVideoDriver = GetVideoDriverName();
|
||||||
@@ -604,19 +605,19 @@ static void CheckVideoDefaultSettings()
|
|||||||
|
|
||||||
found_defaults:
|
found_defaults:
|
||||||
|
|
||||||
bool SetDefaultVideoParams=false;
|
bool bSetDefaultVideoParams = false;
|
||||||
if( PREFSMAN->m_sVideoRenderers.Get() == "" )
|
if( PREFSMAN->m_sVideoRenderers.Get() == "" )
|
||||||
{
|
{
|
||||||
SetDefaultVideoParams = true;
|
bSetDefaultVideoParams = true;
|
||||||
LOG->Trace( "Applying defaults for %s.", sVideoDriver.c_str() );
|
LOG->Trace( "Applying defaults for %s.", sVideoDriver.c_str() );
|
||||||
}
|
}
|
||||||
else if( PREFSMAN->m_sLastSeenVideoDriver.Get() != sVideoDriver )
|
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() );
|
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_sVideoRenderers.Set( defaults.sVideoRenderers );
|
||||||
PREFSMAN->m_iDisplayWidth.Set( defaults.iWidth );
|
PREFSMAN->m_iDisplayWidth.Set( defaults.iWidth );
|
||||||
@@ -634,10 +635,10 @@ found_defaults:
|
|||||||
{
|
{
|
||||||
LOG->Warn("Video renderer list has been changed from '%s' to '%s'",
|
LOG->Warn("Video renderer list has been changed from '%s' to '%s'",
|
||||||
defaults.sVideoRenderers.c_str(), PREFSMAN->m_sVideoRenderers.Get().c_str() );
|
defaults.sVideoRenderers.c_str(), PREFSMAN->m_sVideoRenderers.Get().c_str() );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG->Info( "Video renderers: '%s'", PREFSMAN->m_sVideoRenderers.Get().c_str() );
|
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." );
|
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.
|
* Actually, right now we're falling back. I'm not sure which behavior is better.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CheckVideoDefaultSettings();
|
bool bAppliedDefaults = CheckVideoDefaultSettings();
|
||||||
|
|
||||||
VideoModeParams params;
|
VideoModeParams params;
|
||||||
StepMania::GetPreferredVideoModeParams( params );
|
StepMania::GetPreferredVideoModeParams( params );
|
||||||
@@ -688,6 +689,7 @@ RageDisplay *CreateDisplay()
|
|||||||
if( asRenderers.empty() )
|
if( asRenderers.empty() )
|
||||||
RageException::Throw( ERROR_NO_VIDEO_RENDERERS.GetValue() );
|
RageException::Throw( ERROR_NO_VIDEO_RENDERERS.GetValue() );
|
||||||
|
|
||||||
|
RageDisplay *pRet = NULL;
|
||||||
for( unsigned i=0; i<asRenderers.size(); i++ )
|
for( unsigned i=0; i<asRenderers.size(); i++ )
|
||||||
{
|
{
|
||||||
RString sRenderer = asRenderers[i];
|
RString sRenderer = asRenderers[i];
|
||||||
@@ -695,38 +697,44 @@ RageDisplay *CreateDisplay()
|
|||||||
if( sRenderer.CompareNoCase("opengl")==0 )
|
if( sRenderer.CompareNoCase("opengl")==0 )
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_OPENGL)
|
#if defined(SUPPORT_OPENGL)
|
||||||
RageDisplay_OGL *pRet = new 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;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if( sRenderer.CompareNoCase("d3d")==0 )
|
else if( sRenderer.CompareNoCase("d3d")==0 )
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_D3D)
|
#if defined(SUPPORT_D3D)
|
||||||
RageDisplay_D3D *pRet = new RageDisplay_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
|
#endif
|
||||||
}
|
}
|
||||||
else if( sRenderer.CompareNoCase("null")==0 )
|
else if( sRenderer.CompareNoCase("null")==0 )
|
||||||
{
|
{
|
||||||
return new RageDisplay_Null( params );
|
return new RageDisplay_Null();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RageException::Throw( ERROR_UNKNOWN_VIDEO_RENDERER.GetValue(), sRenderer.c_str() );
|
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;
|
extern const RString STATIC_INI_PATH;
|
||||||
|
|||||||
Reference in New Issue
Block a user