ReactOS 0.4.16-dev-106-g10b08aa
d3d9.c
Go to the documentation of this file.
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 <d3d9.h>
11#include "d3d9_helpers.h"
12#include "d3d9_create.h"
13#include <debug.h>
14
15#define DEBUG_MESSAGE_BUFFER_SIZE 512
16
17typedef IDirect3D9* (WINAPI *LPDIRECT3DCREATE9)(UINT);
18
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 "
23 "version (%d).\n"
24 "Recompile the application against the appropriate SDK for the installed runtime.\n"
25 "\n";
26
28{
30 return 0;
31}
32
34{
36 return 0;
37}
38
40{
42 return 0;
43}
44
46{
48 return 0;
49}
50
52{
54 return 0;
55}
56
57IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
58{
59 HINSTANCE hDebugDll;
60 DWORD LoadDebugDll;
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;
66
67 LoadDebugDllSize = sizeof(LoadDebugDll);
68 if (ReadRegistryValue(REG_DWORD, "LoadDebugRuntime", (LPBYTE)&LoadDebugDll, &LoadDebugDllSize))
69 {
70 if (0 != LoadDebugDll)
71 {
72 hDebugDll = LoadLibraryA("d3d9d.dll");
73
74 if (0 != hDebugDll)
75 {
76 DebugDirect3DCreate9 = (LPDIRECT3DCREATE9)GetProcAddress(hDebugDll, "Direct3DCreate9");
77
78 return DebugDirect3DCreate9(SDKVersion);
79 }
80 }
81 }
82
83 if (NoDebugSDKVersion != D3D_SDK_VERSION && NoDebugSDKVersion != D3D9b_SDK_VERSION)
84 {
85 if (SDKVersion & DX_D3D9_DEBUG)
86 {
87 HRESULT hResult;
88 hResult = SafeFormatString(DebugMessageBuffer, DEBUG_MESSAGE_BUFFER_SIZE, D3dError_WrongSdkVersion, NoDebugSDKVersion, D3D_SDK_VERSION);
89 if (SUCCEEDED(hResult))
90 OutputDebugStringA(DebugMessageBuffer);
91 }
92
93 return NULL;
94 }
95
96 CreateD3D9(&D3D9Obj, SDKVersion);
97
98 return D3D9Obj;
99}
100
101BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
102{
103 switch (ul_reason_for_call)
104 {
109 break;
110 }
111
112 return TRUE;
113}
#define UNIMPLEMENTED
Definition: debug.h:118
HRESULT WINAPI DebugSetMute(void)
Definition: d3d8.c:24
HRESULT WINAPI PSGPError(void)
Definition: d3d9.c:33
IDirect3D9 *(WINAPI * LPDIRECT3DCREATE9)(UINT)
Definition: d3d9.c:17
HRESULT WINAPI Direct3DShaderValidatorCreate9(void)
Definition: d3d9.c:27
#define DEBUG_MESSAGE_BUFFER_SIZE
Definition: d3d9.c:15
HRESULT WINAPI DebugSetLevel(void)
Definition: d3d9.c:45
static LPCSTR D3dError_WrongSdkVersion
Definition: d3d9.c:19
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
HRESULT WINAPI PSGPSampleTexture(void)
Definition: d3d9.c:39
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
Definition: d3d9.c:101
struct IDirect3D9 * LPDIRECT3D9
Definition: d3d9.h:124
#define DX_D3D9_DEBUG
Definition: d3d9_common.h:15
HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9, UINT SDKVersion)
Definition: d3d9_create.c:237
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize)
Definition: d3d9_helpers.c:19
HRESULT SafeFormatString(OUT LPSTR Buffer, IN DWORD BufferSize, IN LPCSTR FormatString,...)
Definition: d3d9_helpers.c:41
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define APIENTRY
Definition: api.h:79
HMODULE hModule
Definition: animate.c:44
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define GetProcAddress(x, y)
Definition: compat.h:753
#define DLL_THREAD_ATTACH
Definition: compat.h:132
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned int UINT
Definition: ndis.h:50
#define REG_DWORD
Definition: sdbapi.c:596
#define D3D_SDK_VERSION
Definition: d3d8.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
#define WINAPI
Definition: msvc.h:6
const char * LPCSTR
Definition: xmlstorage.h:183
char CHAR
Definition: xmlstorage.h:175