From 9ab0d6ebee9cba5d3b5da8945fb9a0bc49ef80c9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 28 May 2003 00:50:10 +0000 Subject: [PATCH] fix bugs that show up on Voodoo3 --- stepmania/src/RageBitmapTexture.cpp | 11 ++++++++++- stepmania/src/RageDisplay_D3D.cpp | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index 6c47989b99..0ffbdd73ee 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -245,9 +245,18 @@ void RageBitmapTexture::Create() * done *before* we set up the palette, since it might change it. */ FixHiddenAlpha(img); + /* Make we're using a supported format. + * Every card supports either RGBA8 or RGBA4. */ + if( !DISPLAY->SupportsTextureFormat(pixfmt) ) + { + pixfmt = FMT_RGBA8; + if( !DISPLAY->SupportsTextureFormat(pixfmt) ) + pixfmt = FMT_RGBA4; + } + + /* Convert the data to the destination format and dimensions * required by OpenGL if it's not in it already. */ - const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt); ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight, pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]); diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 6633805c62..30cf351696 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -253,7 +253,12 @@ RageDisplay_D3D::RageDisplay_D3D( bool windowed, int width, int height, int bpp, } - SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile ); + if( SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile ) ) + return; + if( SetVideoMode( false, width, height, bpp, rate, vsync, sWindowTitle, sIconFile ) ) + return; + if( SetVideoMode( false, width, height, 16, rate, vsync, sWindowTitle, sIconFile ) ) + return; } void RageDisplay_D3D::Update(float fDeltaTime) @@ -343,8 +348,8 @@ D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP) return fmtBackBuffer; } - SDL_QuitSubSystem(SDL_INIT_VIDEO); // exit out of full screen. The ~RageDisplay will not be called! - RageException::Throw( "Couldn't find an appropriate back buffer format." ); + LOG->Trace( "Couldn't find an appropriate back buffer format." ); + return (D3DFORMAT)-1; } #ifndef _XBOX @@ -365,6 +370,9 @@ HWND GetHwnd() /* Set the video mode. */ bool RageDisplay_D3D::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile ) { + if( FindBackBufferType( windowed, bpp ) == -1 ) // no possible back buffer formats + return false; + /* Set SDL window title and icon -before- creating the window */ SDL_WM_SetCaption(sWindowTitle, ""); mySDL_WM_SetIcon( sIconFile ); @@ -891,6 +899,9 @@ void RageDisplay_D3D::UpdateTexture( rect.bottom = height - yoffset; D3DLOCKED_RECT lr; + + + pTex->LockRect( 0, &lr, &rect, 0 ); // copy each row