Re: [AD] patch for detecting DX8,9 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Tuesday 22 February 2005 06:54, AJ wrote:
> attached is a patch for detecting directX versions 8 and 9.
> made for 4.1.18
The attached patch is a slightly reworked version of the original (which
didn't apply for me for some reason). I have mainly replaced the blocks of
ifs with select/case blocks, which I think are easier to read (and
intended for the purpose).
I have a few questions though:
+ case 0x0001032A:
+ case 0x00010371:
+ dx_version = 0x801; /* 8.1 */
Is this really correct? Are there two possible return values for DX 8.1? If
so, why? Also, why 0x801 rather than 0x810, as you did for the other ones?
+ case 0x00010385:
+ dx_version = 0x81a; /* 8.1a */
+ break;
+ case 0x00010385:
+ dx_version = 0x81b; /* 8.1b */
+ break;
+ case 0x00020386:
+ dx_version = 0x820; /* 8.2 */
+ break;
There's a duplicate value here. What would be the correct values?
Evert
Index: src/win/wdxver.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wdxver.c,v
retrieving revision 1.9
diff -u -r1.9 wdxver.c
--- src/win/wdxver.c 22 Mar 2004 13:25:23 -0000 1.9
+++ src/win/wdxver.c 6 Mar 2005 17:20:17 -0000
@@ -44,6 +44,7 @@
typedef HRESULT(WINAPI *DIRECTDRAWCREATE) (GUID *, LPDIRECTDRAW *, IUnknown *);
typedef HRESULT(WINAPI *DIRECTINPUTCREATE) (HINSTANCE, DWORD, LPDIRECTINPUT *, IUnknown *);
+typedef HRESULT(WINAPI *DSETUPCREATE)(DWORD*,DWORD*);
@@ -63,13 +64,18 @@
HRESULT hr;
HINSTANCE ddraw_hinst = NULL;
HINSTANCE dinput_hinst = NULL;
+ HINSTANCE dsetup_hinst = NULL;
LPDIRECTDRAW directdraw = NULL;
LPDIRECTDRAW2 directdraw2 = NULL;
DIRECTDRAWCREATE DirectDrawCreate = NULL;
DIRECTINPUTCREATE DirectInputCreate = NULL;
+ DSETUPCREATE DSetupCreate = NULL;
OSVERSIONINFO os_version;
LPDIRECTDRAWSURFACE ddraw_surf = NULL;
LPDIRECTDRAWSURFACE3 ddraw_surf3 = NULL;
+ DWORD dsetup_revision;
+ DWORD dsetup_version;
+ INT dsetup_result;
#if DIRECTX_SDK_VERSION >= 0x600
LPDIRECTDRAWSURFACE4 ddraw_surf4 = NULL;
@@ -98,6 +104,73 @@
return dx_version;
}
+ /* First check for DX 8 and 9 */
+ dsetup_hinst = LoadLibrary( "DSETUP.DLL" );
+ if ( dsetup_hinst ) {
+ DSetupCreate = (DSETUPCREATE)GetProcAddress(dsetup_hinst, "DirectXSetupGetVersion");
+ if ( DSetupCreate ) {
+ dsetup_result = DSetupCreate( &dsetup_version, &dsetup_revision ); // returns 0 on failure
+ if ( dsetup_result ) {
+ switch (dsetup_version) {
+ case 0x00040005:
+ dx_version = 0x500;
+ break;
+ case 0x00040006:
+ dx_version = 0x600;
+ break;
+ case 0x00040007:
+ dx_version = 0x700;
+ break;
+ case 0x00040008: /* v8.x */
+ dx_version = 0x800;
+ switch (dsetup_revision) {
+ case 0x0001032A:
+ case 0x00010371:
+ dx_version = 0x801; /* 8.1 */
+ dx_version = 0x801; /* 8.1 */
+ break;
+ case 0x00010385:
+ dx_version = 0x81a; /* 8.1a */
+ break;
+ case 0x00010385:
+ dx_version = 0x81b; /* 8.1b */
+ break;
+ case 0x00020386:
+ dx_version = 0x820; /* 8.2 */
+ break;
+ default:
+ dx_version = 0x800; /* 8.0 */
+ } /* switch (dsetup_revision) */
+ }
+ case 0x00040009 == dsetup_version ) {
+ switch (dsetup_revision) {
+ case 0x00000384:
+ dx_version = 0x900; /* 9.0 */
+ break;
+ case 0x00000385:
+ dx_version = 0x90a; /* 9.0a */
+ break;
+ case 0x00000386:
+ dx_version = 0x90b; /* 9.0b */
+ break;
+ case 0x00000387:
+ dx_version = 0x90b; /* 9.0(b|c) */
+ break;
+ case 0x00000388:
+ dx_version = 0x90c; /* 9.0c */
+ break;
+ default:
+ dx_version = 0x900;
+ } /* switch (dsetup_revision) */
+ }
+ } /* switch (dsetup_version) */
+ }
+ }
+ FreeLibrary( dsetup_hinst );
+ if ( dx_version )
+ return dx_version;
+ }
+
if (os_version.dwMajorVersion == 4) {
/* NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 */
dx_version = 0x200;