2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS ReactX
4 * FILE: dll/directx/d3d9/d3d9.c
5 * PURPOSE: d3d9.dll implementation
6 * PROGRAMERS: Magnus Olsen <greatlrd (at) reactos (dot) org>
7 * Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
11 #include "d3d9_helpers.h"
12 #include "d3d9_create.h"
15 #define DEBUG_MESSAGE_BUFFER_SIZE 512
17 typedef IDirect3D9
* (WINAPI
*LPDIRECT3DCREATE9
)(UINT
);
19 static LPCSTR D3dError_WrongSdkVersion
=
20 "D3D ERROR: D3D header version mismatch.\n"
21 "The application was compiled against and will only work with "
22 "D3D_SDK_VERSION (%d), but the currently installed runtime is "
24 "Recompile the application against the appropriate SDK for the installed runtime.\n"
27 HRESULT WINAPI
Direct3DShaderValidatorCreate9(void)
33 HRESULT WINAPI
PSGPError(void)
39 HRESULT WINAPI
PSGPSampleTexture(void)
45 HRESULT WINAPI
DebugSetLevel(void)
51 HRESULT WINAPI
DebugSetMute(DWORD dw1
)
57 IDirect3D9
* WINAPI
Direct3DCreate9(UINT SDKVersion
)
61 DWORD LoadDebugDllSize
;
62 LPDIRECT3D9 D3D9Obj
= 0;
63 LPDIRECT3DCREATE9 DebugDirect3DCreate9
= 0;
64 CHAR DebugMessageBuffer
[DEBUG_MESSAGE_BUFFER_SIZE
];
65 UINT NoDebugSDKVersion
= SDKVersion
& ~DX_D3D9_DEBUG
;
67 LoadDebugDllSize
= sizeof(LoadDebugDll
);
68 if (ReadRegistryValue(REG_DWORD
, "LoadDebugRuntime", (LPBYTE
)&LoadDebugDll
, &LoadDebugDllSize
))
70 if (0 != LoadDebugDll
)
72 hDebugDll
= LoadLibraryA("d3d9d.dll");
76 DebugDirect3DCreate9
= (LPDIRECT3DCREATE9
)GetProcAddress(hDebugDll
, "Direct3DCreate9");
78 return DebugDirect3DCreate9(SDKVersion
);
83 if (NoDebugSDKVersion
!= D3D_SDK_VERSION
&& NoDebugSDKVersion
!= D3D9b_SDK_VERSION
)
85 if (SDKVersion
& DX_D3D9_DEBUG
)
88 hResult
= SafeFormatString(DebugMessageBuffer
, DEBUG_MESSAGE_BUFFER_SIZE
, D3dError_WrongSdkVersion
, NoDebugSDKVersion
, D3D_SDK_VERSION
);
89 if (SUCCEEDED(hResult
))
90 OutputDebugStringA(DebugMessageBuffer
);
96 CreateD3D9(&D3D9Obj
, SDKVersion
);
101 BOOL APIENTRY
DllMain(HANDLE hModule
, DWORD ul_reason_for_call
, LPVOID lpReserved
)
103 switch (ul_reason_for_call
)
105 case DLL_PROCESS_ATTACH
:
106 case DLL_THREAD_ATTACH
:
107 case DLL_THREAD_DETACH
:
108 case DLL_PROCESS_DETACH
: