From c326423dce27c3755a7af41fe9cf56bf2ff5b801 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 23 Oct 2004 02:16:59 +0000 Subject: [PATCH] move win32 pixel format dumping code into LowLevelWindow_Win32 --- stepmania/src/RageDisplay_OGL.cpp | 67 ------------------- .../LowLevelWindow/LowLevelWindow_Win32.cpp | 34 ++++++++-- 2 files changed, 30 insertions(+), 71 deletions(-) diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index b3ea739945..520efdc926 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -689,72 +689,6 @@ void SetupExtensions() } } -void DumpOpenGLDebugInfo() -{ -#if defined(WIN32) - /* Dump Windows pixel format data. */ - int Actual = GetPixelFormat(wglGetCurrentDC()); - - PIXELFORMATDESCRIPTOR pfd; - memset(&pfd, 0, sizeof(pfd)); - pfd.nSize=sizeof(pfd); - pfd.nVersion=1; - - int pfcnt = DescribePixelFormat(GetDC(g_hWndMain),1,sizeof(pfd),&pfd); - for (int i=1; i <= pfcnt; i++) - { - memset(&pfd, 0, sizeof(pfd)); - pfd.nSize=sizeof(pfd); - pfd.nVersion=1; - DescribePixelFormat(GetDC(g_hWndMain),i,sizeof(pfd),&pfd); - - bool skip = false; - - bool rgba = (pfd.iPixelType==PFD_TYPE_RGBA); - - bool mcd = ((pfd.dwFlags & PFD_GENERIC_FORMAT) && (pfd.dwFlags & PFD_GENERIC_ACCELERATED)); - bool soft = ((pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED)); - bool icd = !(pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED); - bool opengl = !!(pfd.dwFlags & PFD_SUPPORT_OPENGL); - bool window = !!(pfd.dwFlags & PFD_DRAW_TO_WINDOW); - bool dbuff = !!(pfd.dwFlags & PFD_DOUBLEBUFFER); - - if(!rgba || soft || !opengl || !window || !dbuff) - skip = true; - - /* Skip the above, unless it happens to be the one we chose. */ - if(skip && i != Actual) - continue; - - CString str = ssprintf("Mode %i: ", i); - if( i != Actual ) - continue; -// if(i == Actual) str += "*** "; - if(skip) str += "(BOGUS) "; - if(soft) str += "software "; - if(icd) str += "ICD "; - if(mcd) str += "MCD "; - if(!rgba) str += "indexed "; - if(!opengl) str += "!OPENGL "; - if(!window) str += "!window "; - if(!dbuff) str += "!dbuff "; - - str += ssprintf("%i (%i%i%i) ", pfd.cColorBits, pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits); - if(pfd.cAlphaBits) str += ssprintf("%i alpha ", pfd.cAlphaBits); - if(pfd.cDepthBits) str += ssprintf("%i depth ", pfd.cDepthBits); - if(pfd.cStencilBits) str += ssprintf("%i stencil ", pfd.cStencilBits); - if(pfd.cAccumBits) str += ssprintf("%i accum ", pfd.cAccumBits); - - if(i == Actual && skip) - { - /* We chose a bogus format. */ - LOG->Warn("%s", str.c_str()); - } else - LOG->Info("%s", str.c_str()); - } -#endif -} - void RageDisplay_OGL::ResolutionChanged() { SetViewport(0,0); @@ -787,7 +721,6 @@ CString RageDisplay_OGL::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut ) } this->SetDefaultRenderStates(); - DumpOpenGLDebugInfo(); /* Now that we've initialized, we can search for extensions (some of which * we may need to set up the video mode). */ diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp index ff5e17d362..729a38aa37 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp @@ -71,6 +71,35 @@ void pump(const char *p) } } +void DumpPixelFormat( const PIXELFORMATDESCRIPTOR &pfd ) +{ + CString str = ssprintf( "Mode: " ); + bool bInvalidFormat = false; + + if( pfd.dwFlags & PFD_GENERIC_FORMAT ) + { + if( pfd.dwFlags & PFD_GENERIC_ACCELERATED ) str += "MCD "; + else { str += "software "; bInvalidFormat = true; } + } + else + str += "ICD "; + + if( pfd.iPixelType != PFD_TYPE_RGBA ) { str += "indexed "; bInvalidFormat = true; } + if( !(pfd.dwFlags & PFD_SUPPORT_OPENGL) ) { str += "!OPENGL "; bInvalidFormat = true; } + if( !(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ) { str += "!window "; bInvalidFormat = true; } + if( !(pfd.dwFlags & PFD_DOUBLEBUFFER) ) { str += "!dbuff "; bInvalidFormat = true; } + + str += ssprintf( "%i (%i%i%i) ", pfd.cColorBits, pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits ); + if( pfd.cAlphaBits ) str += ssprintf( "%i alpha ", pfd.cAlphaBits ); + if( pfd.cDepthBits ) str += ssprintf( "%i depth ", pfd.cDepthBits ); + if( pfd.cStencilBits ) str += ssprintf( "%i stencil ", pfd.cStencilBits ); + if( pfd.cAccumBits ) str += ssprintf( "%i accum ", pfd.cAccumBits ); + + if( bInvalidFormat ) + LOG->Warn( "Invalid format: %s", str.c_str() ); + else + LOG->Info( "%s", str.c_str() ); +} /* 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, @@ -171,10 +200,7 @@ CString LowLevelWindow_Win32::TryVideoMode( RageDisplay::VideoModeParams p, bool DescribePixelFormat( GraphicsWindow::GetHDC(), iPixelFormat, sizeof(g_CurrentPixelFormat), &g_CurrentPixelFormat ); - LOG->Info( "Got %i bpp (%i%i%i%i), %i depth", - g_CurrentPixelFormat.cColorBits, g_CurrentPixelFormat.cRedBits, - g_CurrentPixelFormat.cBlueBits, g_CurrentPixelFormat.cGreenBits, - g_CurrentPixelFormat.cAlphaBits, g_CurrentPixelFormat.cDepthBits ); + DumpPixelFormat( g_CurrentPixelFormat ); } if( g_HGLRC == NULL )