diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 230d07e11d..01ed4cefb8 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -22,6 +22,7 @@ #include "RageMath.h" #include "RageTypes.h" #include "GameConstantsAndTypes.h" +#include "StepMania.h" RageDisplay* DISPLAY = NULL; @@ -70,6 +71,10 @@ void GetGLExtensions(set &ext) RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync ) { LOG->Trace( "RageDisplay::RageDisplay()" ); + + /* Give hooks a chance to do some debug init before we try to fire up OpenGL. */ + HOOKS->PreDisplayInit(); + m_oglspecs = new oglspecs_t; SDL_InitSubSystem(SDL_INIT_VIDEO); diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 71495373af..0b0da666a1 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -60,7 +60,7 @@ IntDir=.\../Release6 TargetDir=\temp\stepmania TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -95,7 +95,7 @@ IntDir=.\../Debug6 TargetDir=\temp\stepmania TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -726,6 +726,14 @@ SOURCE=.\archutils\Win32\AppInstance.h # End Source File # Begin Source File +SOURCE=.\archutils\Win32\DebugInfoHunt.cpp +# End Source File +# Begin Source File + +SOURCE=.\archutils\Win32\DebugInfoHunt.h +# End Source File +# Begin Source File + SOURCE=.\archutils\Win32\GotoURL.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index fa4e067498..4a4df10352 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -767,6 +767,12 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ + + + + diff --git a/stepmania/src/arch/ArchHooks/ArchHooks.h b/stepmania/src/arch/ArchHooks/ArchHooks.h index b0b06766ad..cefaa21cbe 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks.h @@ -20,6 +20,10 @@ class ArchHooks public: /* This receives all logs. 'important' is set for Warn and Info. */ virtual void Log(CString str, bool important) { } + + /* This is called when DISPLAY is constructed. */ + virtual void PreDisplayInit() { } + virtual ~ArchHooks() { } }; diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index c6cfde4e20..f68a8ed577 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -3,6 +3,7 @@ #include "archutils/win32/tls.h" #include "archutils/win32/crash.h" +#include "archutils/win32/DebugInfoHunt.h" ArchHooks_Win32::ArchHooks_Win32() { @@ -21,6 +22,13 @@ void ArchHooks_Win32::Log(CString str, bool important) CrashLog(str); } +void ArchHooks_Win32::PreDisplayInit() +{ + /* This is a good time to do the debug search: before we actually + * start OpenGL (in case something goes wrong). */ + SearchForDebugInfo(); +} + /* * Copyright (c) 2002-2003 by the person(s) listed below. All rights reserved. * diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h index 6a8d80503f..7a5a1a41cb 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h @@ -7,6 +7,7 @@ class ArchHooks_Win32: public ArchHooks public: ArchHooks_Win32(); void Log(CString str, bool important); + void PreDisplayInit(); }; #undef ARCH_HOOKS diff --git a/stepmania/src/archutils/Win32/DebugInfoHunt.cpp b/stepmania/src/archutils/Win32/DebugInfoHunt.cpp new file mode 100644 index 0000000000..0ad0b04e74 --- /dev/null +++ b/stepmania/src/archutils/Win32/DebugInfoHunt.cpp @@ -0,0 +1,63 @@ +#include "stdafx.h" +#include "DebugInfoHunt.h" +#include "RageLog.h" + +#include +#pragma comment(lib, "d3d8.lib") + +/* + * The only way I've found to get the display driver version is through + * D3D. (There's an interface in DirectDraw, but it always returned 0.) + * Make sure this doesn't break if D3D isn't available! + */ +static void GetDisplayDriverDebugInfo() +{ + if (FAILED(CoInitialize(NULL))) + return; + + IDirect3D8 *m_pd3d = NULL; + try + { + // Construct a Direct3D object + m_pd3d = Direct3DCreate8( D3D_SDK_VERSION ); + } + catch (...) + { + } + + if( m_pd3d == NULL ) + { + LOG->Info("Couldn't get video driver info (no d3d)"); + return; + } + + HRESULT hr; + + D3DADAPTER_IDENTIFIER8 id; + hr = m_pd3d->GetAdapterIdentifier(D3DADAPTER_DEFAULT, D3DENUM_NO_WHQL_LEVEL, &id); + if(FAILED(hr)) + { + LOG->Info(hr_ssprintf(hr, "Couldn't get video driver info")); + return; + } + + LOG->Info("Video description: %s", id.Description); + LOG->Info("Chipset rev: %i Vendor ID: %i Device ID: %i", id.Revision, id.VendorId, id.DeviceId); + LOG->Info("Video driver: %s %i.%i.%i", id.Driver, + LOWORD(id.DriverVersion.HighPart), + HIWORD(id.DriverVersion.LowPart), + LOWORD(id.DriverVersion.LowPart)); + + CoUninitialize(); +} + +void SearchForDebugInfo() +{ + GetDisplayDriverDebugInfo(); +} + +/* + * Copyright (c) 2003 by the person(s) listed below. All rights reserved. + * + * Glenn Maynard + */ diff --git a/stepmania/src/archutils/Win32/DebugInfoHunt.h b/stepmania/src/archutils/Win32/DebugInfoHunt.h new file mode 100644 index 0000000000..01c7ccd368 --- /dev/null +++ b/stepmania/src/archutils/Win32/DebugInfoHunt.h @@ -0,0 +1,13 @@ +#ifndef DEBUG_INFO_HUNT_H +#define DEBUG_INFO_HUNT_H + +/* We want debug information; Windows makes us hunt for it. */ +void SearchForDebugInfo(); + +#endif + +/* + * Copyright (c) 2003 by the person(s) listed below. All rights reserved. + * + * Glenn Maynard + */