diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 07fa20cf0d..3fdec9ef6a 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -63,6 +63,60 @@ enum PixelFormat }; const CString& PixelFormatToString( PixelFormat i ); +struct VideoModeParams +{ + // Initialize with a constructor so to guarantee all paramters + // are filled (in case new params are added). + VideoModeParams( + bool windowed_, + int width_, + int height_, + int bpp_, + int rate_, + bool vsync_, + bool interlaced_, + bool bSmoothLines_, + bool bTrilinearFiltering_, + bool bAnisotropicFiltering_, + CString sWindowTitle_, + CString sIconFile_, + bool PAL_, + float fDisplayAspectRatio_ + ) + { + windowed = windowed_; + width = width_; + height = height_; + bpp = bpp_; + rate = rate_; + vsync = vsync_; + interlaced = interlaced_; + bSmoothLines = bSmoothLines_; + bTrilinearFiltering = bTrilinearFiltering_; + bAnisotropicFiltering = bAnisotropicFiltering_; + sWindowTitle = sWindowTitle_; + sIconFile = sIconFile_; + PAL = PAL_; + fDisplayAspectRatio = fDisplayAspectRatio_; + } + VideoModeParams() {} + + bool windowed; + int width; + int height; + int bpp; + int rate; + bool vsync; + bool bSmoothLines; + bool bTrilinearFiltering; + bool bAnisotropicFiltering; + bool interlaced; + bool PAL; + float fDisplayAspectRatio; + CString sWindowTitle; + CString sIconFile; +}; + class RageDisplay { friend class RageTexture; @@ -76,60 +130,6 @@ public: virtual const PixelFormatDesc *GetPixelFormatDesc( PixelFormat pf ) const = 0; - struct VideoModeParams - { - // Initialize with a constructor so to guarantee all paramters - // are filled (in case new params are added). - VideoModeParams( - bool windowed_, - int width_, - int height_, - int bpp_, - int rate_, - bool vsync_, - bool interlaced_, - bool bSmoothLines_, - bool bTrilinearFiltering_, - bool bAnisotropicFiltering_, - CString sWindowTitle_, - CString sIconFile_, - bool PAL_, - float fDisplayAspectRatio_ - ) - { - windowed = windowed_; - width = width_; - height = height_; - bpp = bpp_; - rate = rate_; - vsync = vsync_; - interlaced = interlaced_; - bSmoothLines = bSmoothLines_; - bTrilinearFiltering = bTrilinearFiltering_; - bAnisotropicFiltering = bAnisotropicFiltering_; - sWindowTitle = sWindowTitle_; - sIconFile = sIconFile_; - PAL = PAL_; - fDisplayAspectRatio = fDisplayAspectRatio_; - } - VideoModeParams() {} - - bool windowed; - int width; - int height; - int bpp; - int rate; - bool vsync; - bool bSmoothLines; - bool bTrilinearFiltering; - bool bAnisotropicFiltering; - bool interlaced; - bool PAL; - float fDisplayAspectRatio; - CString sWindowTitle; - CString sIconFile; - }; - /* This is needed or the overridden classes' dtors will not be called. */ virtual ~RageDisplay() { } diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 52bfc9954c..c7ccfef709 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -642,7 +642,8 @@ void RageDisplay_D3D::SetViewport(int shift_left, int shift_down) { /* left and down are on a 0..SCREEN_WIDTH, 0..SCREEN_HEIGHT scale. * Scale them to the actual viewport range. */ - RageDisplay::VideoModeParams p = GraphicsWindow::GetParams(); + VideoModeParams p; + GraphicsWindow::GetParams( p ); shift_left = int( shift_left * float(p.width) / SCREEN_WIDTH ); shift_down = int( shift_down * float(p.height) / SCREEN_HEIGHT ); @@ -670,7 +671,10 @@ bool RageDisplay_D3D::BeginFrame() case D3DERR_DEVICENOTRESET: { bool bIgnore = false; - CString sError = SetVideoMode( GraphicsWindow::GetParams(), bIgnore ); + VideoModeParams params; + GraphicsWindow::GetParams( params ); + + CString sError = SetVideoMode( params, bIgnore ); if( sError != "" ) RageException::Throw( sError ); break; @@ -787,7 +791,12 @@ RageSurface* RageDisplay_D3D::CreateScreenshot() #endif } -RageDisplay::VideoModeParams RageDisplay_D3D::GetVideoModeParams() const { return GraphicsWindow::GetParams(); } +VideoModeParams RageDisplay_D3D::GetVideoModeParams() const +{ + VideoModeParams p; + GraphicsWindow::GetParams( p ); + return p; +} void RageDisplay_D3D::SendCurrentMatrices() { diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 16deb112dd..8ca385e17e 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -798,7 +798,7 @@ RageSurface* RageDisplay_OGL::CreateScreenshot() return image; } -RageDisplay::VideoModeParams RageDisplay_OGL::GetVideoModeParams() const { return wind->GetVideoModeParams(); } +VideoModeParams RageDisplay_OGL::GetVideoModeParams() const { return wind->GetVideoModeParams(); } static void SetupVertices( const RageSpriteVertex v[], int iNumVerts ) { diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index a501816fff..59d30b3287 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -87,9 +87,10 @@ static bool g_bHasFocus = true; void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame ); -static RageDisplay::VideoModeParams GetCurVideoModeParams() + +void GetCurVideoModeParams( VideoModeParams ¶msOut ) { - return RageDisplay::VideoModeParams( + paramsOut = VideoModeParams( PREFSMAN->m_bWindowed, PREFSMAN->m_iDisplayWidth, PREFSMAN->m_iDisplayHeight, @@ -172,7 +173,9 @@ void ApplyGraphicOptions() { bool bNeedReload = false; - CString sError = DISPLAY->SetVideoMode( GetCurVideoModeParams(), bNeedReload ); + VideoModeParams params; + GetCurVideoModeParams( params ); + CString sError = DISPLAY->SetVideoMode( params, bNeedReload ); if( sError != "" ) RageException::Throw( sError ); @@ -689,7 +692,8 @@ RageDisplay *CreateDisplay() CheckVideoDefaultSettings(); - RageDisplay::VideoModeParams params(GetCurVideoModeParams()); + VideoModeParams params; + GetCurVideoModeParams( params ); CString error = "There was an error while initializing your video card.\n\n" "Please do not file this error as a bug! Use the web page below to troubleshoot this problem.\n\n" diff --git a/stepmania/src/StepMania.h b/stepmania/src/StepMania.h index 9830765289..fff2b551a6 100644 --- a/stepmania/src/StepMania.h +++ b/stepmania/src/StepMania.h @@ -26,6 +26,9 @@ extern int g_argc; extern char **g_argv; bool GetCommandlineArgument( const CString &option, CString *argument=NULL, int iIndex=0 ); +struct VideoModeParams; +void GetCurVideoModeParams( VideoModeParams ¶msOut ); + #endif /* diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h index dab9f20556..c9f71fcdfa 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h @@ -3,7 +3,7 @@ /* This handles low-level operations that OGL 1.x doesn't give us. */ -#include "RageDisplay.h" // for RageDisplay::VideoModeParams +#include "RageDisplay.h" // for VideoModeParams class LowLevelWindow { @@ -15,12 +15,12 @@ public: // Return "" if mode change was successful, otherwise an error message. // bNewDeviceOut is set true if a new device was created and textures // need to be reloaded. - virtual CString TryVideoMode( RageDisplay::VideoModeParams p, bool &bNewDeviceOut ) = 0; + virtual CString TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) = 0; virtual void SwapBuffers() = 0; virtual void Update() { } - virtual RageDisplay::VideoModeParams GetVideoModeParams() const = 0; + virtual VideoModeParams GetVideoModeParams() const = 0; }; #endif diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp index a094643d9d..60049c72ad 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp @@ -45,7 +45,7 @@ LowLevelWindow_Win32::~LowLevelWindow_Win32() } -int ChooseWindowPixelFormat( RageDisplay::VideoModeParams p, PIXELFORMATDESCRIPTOR *PixelFormat ) +int ChooseWindowPixelFormat( VideoModeParams p, PIXELFORMATDESCRIPTOR *PixelFormat ) { ASSERT( GraphicsWindow::GetHwnd() != NULL ); ASSERT( GraphicsWindow::GetHDC() != NULL ); @@ -94,7 +94,7 @@ void DumpPixelFormat( const PIXELFORMATDESCRIPTOR &pfd ) /* This function does not reset the video mode if it fails, because we might be trying * yet another video mode, so we'd just thrash the display. On fatal error, * LowLevelWindow_Win32::~LowLevelWindow_Win32 will call Shutdown(). */ -CString LowLevelWindow_Win32::TryVideoMode( RageDisplay::VideoModeParams p, bool &bNewDeviceOut ) +CString LowLevelWindow_Win32::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) { ASSERT_M( p.bpp == 16 || p.bpp == 32, ssprintf("%i", p.bpp) ); @@ -221,9 +221,11 @@ void LowLevelWindow_Win32::Update() GraphicsWindow::Update(); } -RageDisplay::VideoModeParams LowLevelWindow_Win32::GetVideoModeParams() const +VideoModeParams LowLevelWindow_Win32::GetVideoModeParams() const { - return GraphicsWindow::GetParams(); + VideoModeParams p; + GraphicsWindow::GetParams( p ); + return p; } /* diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h index c22191d944..e3e280bcb5 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h @@ -9,11 +9,11 @@ public: LowLevelWindow_Win32(); ~LowLevelWindow_Win32(); void *GetProcAddress( CString s ); - CString TryVideoMode( RageDisplay::VideoModeParams p, bool &bNewDeviceOut ); + CString TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ); void SwapBuffers(); void Update(); - RageDisplay::VideoModeParams GetVideoModeParams() const; + VideoModeParams GetVideoModeParams() const; }; #ifdef ARCH_LOW_LEVEL_WINDOW diff --git a/stepmania/src/archutils/Win32/GraphicsWindow.cpp b/stepmania/src/archutils/Win32/GraphicsWindow.cpp index 36522c7c58..b9252ba5b5 100644 --- a/stepmania/src/archutils/Win32/GraphicsWindow.cpp +++ b/stepmania/src/archutils/Win32/GraphicsWindow.cpp @@ -5,7 +5,7 @@ #include "ProductInfo.h" #include "RageLog.h" #include "RageUtil.h" - +#include "RageDisplay.h" #include "archutils/Win32/AppInstance.h" #include "archutils/Win32/WindowIcon.h" #include "archutils/Win32/GetFileInformation.h" @@ -16,7 +16,7 @@ static const CString g_sClassName = CString(PRODUCT_NAME) + " LowLevelWindow_Win static HWND g_hWndMain; static HDC g_HDC; -static RageDisplay::VideoModeParams g_CurrentParams; +static VideoModeParams g_CurrentParams; static bool g_bResolutionChanged = false; static bool g_bHasFocus = true; static bool g_bLastHasFocus = true; @@ -128,12 +128,12 @@ LRESULT CALLBACK GraphicsWindow::GraphicsWindow_WndProc( HWND hWnd, UINT msg, WP return DefWindowProcA( hWnd, msg, wParam, lParam ); } -void GraphicsWindow::SetVideoModeParams( const RageDisplay::VideoModeParams &p ) +void GraphicsWindow::SetVideoModeParams( const VideoModeParams &p ) { g_CurrentParams = p; } -CString GraphicsWindow::SetScreenMode( const RageDisplay::VideoModeParams &p ) +CString GraphicsWindow::SetScreenMode( const VideoModeParams &p ) { if( p.windowed ) { @@ -173,7 +173,7 @@ CString GraphicsWindow::SetScreenMode( const RageDisplay::VideoModeParams &p ) return CString(); } -static int GetWindowStyle( const RageDisplay::VideoModeParams &p ) +static int GetWindowStyle( const VideoModeParams &p ) { if( p.windowed ) return WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; @@ -181,7 +181,7 @@ static int GetWindowStyle( const RageDisplay::VideoModeParams &p ) return WS_POPUP; } -void GraphicsWindow::CreateGraphicsWindow( const RageDisplay::VideoModeParams &p ) +void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p ) { ASSERT( g_hWndMain == NULL ); @@ -198,7 +198,7 @@ void GraphicsWindow::CreateGraphicsWindow( const RageDisplay::VideoModeParams &p g_HDC = GetDC( g_hWndMain ); } -void GraphicsWindow::RecreateGraphicsWindow( const RageDisplay::VideoModeParams &p ) +void GraphicsWindow::RecreateGraphicsWindow( const VideoModeParams &p ) { ASSERT( g_hWndMain != NULL ); @@ -220,7 +220,7 @@ void GraphicsWindow::RecreateGraphicsWindow( const RageDisplay::VideoModeParams /* Set the final window size, set the window text and icon, and then unhide the * window. */ -void GraphicsWindow::ConfigureGraphicsWindow( const RageDisplay::VideoModeParams &p ) +void GraphicsWindow::ConfigureGraphicsWindow( const VideoModeParams &p ) { ASSERT( g_hWndMain ); @@ -385,9 +385,9 @@ HDC GraphicsWindow::GetHDC() return g_HDC; } -RageDisplay::VideoModeParams GraphicsWindow::GetParams() +void GraphicsWindow::GetParams( VideoModeParams ¶msOut ) { - return g_CurrentParams; + paramsOut = g_CurrentParams; } void GraphicsWindow::Update() diff --git a/stepmania/src/archutils/Win32/GraphicsWindow.h b/stepmania/src/archutils/Win32/GraphicsWindow.h index 6650454e6a..f69ad4d44e 100644 --- a/stepmania/src/archutils/Win32/GraphicsWindow.h +++ b/stepmania/src/archutils/Win32/GraphicsWindow.h @@ -3,7 +3,7 @@ #define GRAPHICS_WINDOW_H #include -#include "RageDisplay.h" // for RageDisplay::VideoModeParams +struct VideoModeParams; // for VideoModeParams namespace GraphicsWindow { @@ -13,16 +13,16 @@ namespace GraphicsWindow /* Shut down completely. */ void Shutdown(); - void SetVideoModeParams( const RageDisplay::VideoModeParams &p ); - CString SetScreenMode( const RageDisplay::VideoModeParams &p ); - void CreateGraphicsWindow( const RageDisplay::VideoModeParams &p ); - void RecreateGraphicsWindow( const RageDisplay::VideoModeParams &p ); + void SetVideoModeParams( const VideoModeParams &p ); + CString SetScreenMode( const VideoModeParams &p ); + void CreateGraphicsWindow( const VideoModeParams &p ); + void RecreateGraphicsWindow( const VideoModeParams &p ); void DestroyGraphicsWindow(); - void ConfigureGraphicsWindow( const RageDisplay::VideoModeParams &p ); + void ConfigureGraphicsWindow( const VideoModeParams &p ); LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); - RageDisplay::VideoModeParams GetParams(); + void GetParams( VideoModeParams ¶msOut ); HDC GetHDC(); void Update();