From ebac0bc8ec95854fbc20b66cc60d226800db4530 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 29 Aug 2002 20:21:30 +0000 Subject: [PATCH] "max refresh" tests format (might have more available at 16bpp than 32bpp, though we're only ever 16bpp right now anyway) Merge format lists. --- stepmania/src/RageDisplay.cpp | 39 +++++++++++------------------------ stepmania/src/RageDisplay.h | 2 +- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index a97565f001..0d3ac302b2 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -96,7 +96,7 @@ RageDisplay::RageDisplay( HWND hWnd ) m_pd3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &m_DesktopMode ); } -int RageDisplay::MaxRefresh(int iWidth, int iHeight) const +int RageDisplay::MaxRefresh(int iWidth, int iHeight, D3DFORMAT fmt) const { UINT mx = D3DPRESENT_RATE_DEFAULT; for( UINT u=0; uGetAdapterModeCount(D3DADAPTER_DEFAULT); u++ ) @@ -107,7 +107,7 @@ int RageDisplay::MaxRefresh(int iWidth, int iHeight) const if(mode.Width != iWidth) continue; if(mode.Height != iHeight) continue; - /* also test mode.Format? */ + if(mode.Format != fmt) continue; if(mx == D3DPRESENT_RATE_DEFAULT || mode.RefreshRate > mx) mx = mode.RefreshRate; @@ -160,43 +160,28 @@ bool RageDisplay::SwitchDisplayMode( // If windowed, then dwBPP is ignored. Use whatever works. CArray arrayBackBufferFormats; // throw all possibilities in here - if( bWindowed ) + /* When windowed, add all formats; otherwise add only formats that match dwBPP. */ + if( iBPP == 16 || bWindowed ) { arrayBackBufferFormats.Add( D3DFMT_R5G6B5 ); arrayBackBufferFormats.Add( D3DFMT_X1R5G5B5 ); arrayBackBufferFormats.Add( D3DFMT_A1R5G5B5 ); + } + if( iBPP == 32 || bWindowed ) + { arrayBackBufferFormats.Add( D3DFMT_R8G8B8 ); arrayBackBufferFormats.Add( D3DFMT_X8R8G8B8 ); arrayBackBufferFormats.Add( D3DFMT_A8R8G8B8 ); } - else // full screen - { - // add only the formats that match dwBPP - switch( iBPP ) - { - case 16: - arrayBackBufferFormats.Add( D3DFMT_R5G6B5 ); - arrayBackBufferFormats.Add( D3DFMT_X1R5G5B5 ); - arrayBackBufferFormats.Add( D3DFMT_A1R5G5B5 ); - break; - case 32: - arrayBackBufferFormats.Add( D3DFMT_R8G8B8 ); - arrayBackBufferFormats.Add( D3DFMT_X8R8G8B8 ); - arrayBackBufferFormats.Add( D3DFMT_A8R8G8B8 ); - break; - default: - throw RageException( ssprintf("Invalid BPP '%u' specified", iBPP) ); - return false; - } - } - + if( !bWindowed && iBPP != 16 && iBPP != 32 ) + throw RageException( ssprintf("Invalid BPP '%u' specified", iBPP) ); // Test each back buffer format until we find something that works. - D3DFORMAT fmtDisplay; // fill these in below... - D3DFORMAT fmtBackBuffer; + D3DFORMAT fmtBackBuffer; // fill this in below... for( int i=0; i < arrayBackBufferFormats.GetSize(); i++ ) { + D3DFORMAT fmtDisplay; if( bWindowed ) { fmtDisplay = m_DesktopMode.Format; @@ -251,7 +236,7 @@ bool RageDisplay::SwitchDisplayMode( m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; m_d3dpp.Flags = 0; m_d3dpp.FullScreen_RefreshRateInHz = bWindowed? D3DPRESENT_RATE_DEFAULT : - iFullScreenHz == 0? MaxRefresh(iWidth, iHeight): + iFullScreenHz == 0? MaxRefresh(iWidth, iHeight, fmtBackBuffer): iFullScreenHz == 1? D3DPRESENT_RATE_DEFAULT: iFullScreenHz; m_d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index f4a80d93b0..49e097be99 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -108,10 +108,10 @@ public: int GetTPF() { return m_iTPF; }; int GetDPF() { return m_iDPF; }; - int MaxRefresh(int iWidth, int iHeight) const; void GetHzAtResolution(int width, int height, CArray &add) const; private: + int MaxRefresh(int iWidth, int iHeight, D3DFORMAT fmt) const; D3DXMATRIX& GetTopMatrix() { return m_MatrixStack.ElementAt( m_MatrixStack.GetSize()-1 ); }; HWND m_hWnd;