Implemented IDirect3D9->QueryInterface()
[reactos.git] / reactos / dll / directx / d3d9 / d3d9.c
1 /*
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>
8 */
9
10 #include <windows.h>
11 #include "d3d9_private.h"
12 #include "d3d9_helpers.h"
13
14 #include <debug.h>
15
16 #define DEBUG_MESSAGE_BUFFER_SIZE 512
17
18 static LPCSTR D3dError_WrongSdkVersion =
19 "D3D ERROR: D3D header version mismatch.\n"
20 "The application was compiled against and will only work with "
21 "D3D_SDK_VERSION (%d), but the currently installed runtime is "
22 "version (%d).\n"
23 "Recompile the application against the appropriate SDK for the installed runtime.\n"
24 "\n";
25
26 HRESULT Direct3DShaderValidatorCreate9(void)
27 {
28 UNIMPLEMENTED
29 return 0;
30 }
31
32 HRESULT PSGPError(void)
33 {
34 UNIMPLEMENTED
35 return 0;
36 }
37
38 HRESULT PSGPSampleTexture(void)
39 {
40 UNIMPLEMENTED
41 return 0;
42 }
43
44 HRESULT DebugSetLevel(void)
45 {
46 UNIMPLEMENTED
47 return 0;
48 }
49
50 HRESULT DebugSetMute(DWORD dw1)
51 {
52 UNIMPLEMENTED
53 return 0;
54 }
55
56 IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
57 {
58 HINSTANCE hDebugDll;
59 DWORD LoadDebugDll;
60 DWORD LoadDebugDllSize;
61 LPDIRECT3D9 D3D9Obj = 0;
62 LPDIRECT3DCREATE9 DebugDirect3DCreate9 = 0;
63 CHAR DebugMessageBuffer[DEBUG_MESSAGE_BUFFER_SIZE];
64 UINT NoDebugSDKVersion = SDKVersion & 0x7FFFFFFF;
65
66 UNIMPLEMENTED
67
68 LoadDebugDllSize = sizeof(LoadDebugDll);
69 if (ReadRegistryValue(REG_DWORD, "LoadDebugRuntime", (LPBYTE)&LoadDebugDll, &LoadDebugDllSize))
70 {
71 if (0 != LoadDebugDll)
72 {
73 hDebugDll = LoadLibrary("d3d9d.dll");
74
75 if (0 != hDebugDll)
76 {
77 DebugDirect3DCreate9 = (LPDIRECT3DCREATE9)GetProcAddress(hDebugDll, "Direct3DCreate9");
78
79 return DebugDirect3DCreate9(SDKVersion);
80 }
81 }
82 }
83
84 if (NoDebugSDKVersion != D3D_SDK_VERSION && NoDebugSDKVersion != D3D9b_SDK_VERSION)
85 {
86 if (SDKVersion & 0x80000000)
87 {
88 FormatDebugString(DebugMessageBuffer, DEBUG_MESSAGE_BUFFER_SIZE, D3dError_WrongSdkVersion, NoDebugSDKVersion, D3D_SDK_VERSION);
89 OutputDebugStringA(DebugMessageBuffer);
90 }
91
92 return NULL;
93 }
94
95 CreateD3D9(&D3D9Obj);
96
97 return D3D9Obj;
98 }
99
100 BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
101 {
102 switch (ul_reason_for_call)
103 {
104 case DLL_PROCESS_ATTACH:
105 case DLL_THREAD_ATTACH:
106 case DLL_THREAD_DETACH:
107 case DLL_PROCESS_DETACH:
108 break;
109 }
110
111 return TRUE;
112 }