Author: gbrunmar
Date: Tue Dec 18 00:22:40 2007
New Revision: 31295
URL:
http://svn.reactos.org/svn/reactos?rev=31295&view=rev
Log:
* Check SDKVersion and print error message if debug flag is specified.
* New CreateD3D9 internal function to create a valid IDirect3D9 object.
Modified:
trunk/reactos/dll/directx/d3d9/d3d9.c
trunk/reactos/dll/directx/d3d9/d3d9_helpers.c
trunk/reactos/dll/directx/d3d9/d3d9_helpers.h
trunk/reactos/dll/directx/d3d9/d3d9_private.h
Modified: trunk/reactos/dll/directx/d3d9/d3d9.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9.c?re…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9.c Tue Dec 18 00:22:40 2007
@@ -13,42 +13,46 @@
#include <debug.h>
-DLLAPI
+#define DEBUG_MESSAGE_BUFFER_SIZE 512
+
+static LPCSTR D3dError_WrongSdkVersion =
+ "D3D ERROR: D3D header version mismatch.\n"
+ "The application was compiled against and will only work with "
+ "D3D_SDK_VERSION (%d), but the currently installed runtime is "
+ "version (%d).\n"
+ "Recompile the application against the appropriate SDK for the installed
runtime.\n"
+ "\n";
+
HRESULT Direct3DShaderValidatorCreate9(void)
{
UNIMPLEMENTED
return 0;
}
-DLLAPI
HRESULT PSGPError(void)
{
UNIMPLEMENTED
return 0;
}
-DLLAPI
HRESULT PSGPSampleTexture(void)
{
UNIMPLEMENTED
return 0;
}
-DLLAPI
-HRESULT DebugSetLevel(void)
+HRESULT DebugSetLevel(void)
{
UNIMPLEMENTED
return 0;
}
-DLLAPI
HRESULT DebugSetMute(DWORD dw1)
{
UNIMPLEMENTED
return 0;
}
-DLLAPI
IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
{
HINSTANCE hDebugDll;
@@ -56,6 +60,7 @@
DWORD LoadDebugDllSize;
LPDIRECT3D9 D3D9Obj = 0;
LPDIRECT3DCREATE9 DebugDirect3DCreate9 = 0;
+ CHAR DebugMessageBuffer[DEBUG_MESSAGE_BUFFER_SIZE];
UNIMPLEMENTED
@@ -70,10 +75,23 @@
{
DebugDirect3DCreate9 = (LPDIRECT3DCREATE9)GetProcAddress(hDebugDll,
"Direct3DCreate9");
- D3D9Obj = DebugDirect3DCreate9(SDKVersion);
+ return DebugDirect3DCreate9(SDKVersion);
}
}
}
+
+ if ((SDKVersion & 0x7FFFFFFF) != D3D_SDK_VERSION || (SDKVersion & 0x7FFFFFFF)
!= D3D9b_SDK_VERSION)
+ {
+ if (SDKVersion & 0x80000000)
+ {
+ FormatDebugString(DebugMessageBuffer, DEBUG_MESSAGE_BUFFER_SIZE,
D3dError_WrongSdkVersion, SDKVersion, D3D_SDK_VERSION);
+ OutputDebugStringA(DebugMessageBuffer);
+ }
+
+ return NULL;
+ }
+
+ CreateD3D9(&D3D9Obj);
return D3D9Obj;
}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_helpers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_help…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_helpers.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_helpers.c Tue Dec 18 00:22:40 2007
@@ -7,9 +7,13 @@
*/
#include "d3d9_helpers.h"
+#include <stdio.h>
+#include <ddraw.h>
+#include "d3d9_private.h"
static LPCSTR D3dDebugRegPath = "Software\\Microsoft\\Direct3D";
+
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN
OUT LPDWORD DataBufferSize)
{
@@ -32,3 +36,46 @@
return TRUE;
}
+
+HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR
FormatString, ... )
+{
+ int BytesWritten;
+ va_list vargs;
+
+ if (BufferSize == 0)
+ return DDERR_INVALIDPARAMS;
+
+ va_start(vargs, FormatString);
+ BytesWritten = _vsnprintf(Buffer, BufferSize-1, FormatString, vargs);
+
+ if (BytesWritten < BufferSize)
+ return DDERR_GENERIC;
+
+ Buffer[BufferSize-1] = '\0';
+
+ return 0;
+}
+
+HRESULT CreateD3D9(IDirect3D9** ppDirect3D9)
+{
+ LPDIRECTD3D9_INT pDirect3D9;
+
+ if (ppDirect3D9 == 0)
+ return DDERR_INVALIDPARAMS;
+
+ pDirect3D9 = HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTD3D9_INT));
+
+ if (0 == pDirect3D9)
+ return DDERR_OUTOFMEMORY;
+
+ pDirect3D9->unknown000007 = 0;
+ pDirect3D9->lpInt = 0;
+
+ //pDirect3D9->lpVtbl = &IDirect3D3_Vtbl;
+ pDirect3D9->dwProcessId = GetCurrentThreadId();
+ pDirect3D9->dwIntRefCnt = 1;
+
+ *ppDirect3D9 = (IDirect3D9*)pDirect3D9;
+
+ return ERROR_SUCCESS;
+}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_helpers.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_help…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_helpers.h (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_helpers.h Tue Dec 18 00:22:40 2007
@@ -6,6 +6,14 @@
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
+#include <d3d9.h>
#include <windows.h>
+/* Reads a registry value if it's of the correct value type */
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN
OUT LPDWORD DataBufferSize);
+
+/* Formats debug strings */
+HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR
FormatString, ... );
+
+/* Creates a Direct3D9 object */
+HRESULT CreateD3D9(IDirect3D9** ppDirect3D9);
Modified: trunk/reactos/dll/directx/d3d9/d3d9_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_priv…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_private.h (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_private.h Tue Dec 18 00:22:40 2007
@@ -11,9 +11,9 @@
#define DLLAPI __declspec(dllexport)
-typedef IDirect3D9* WINAPI (*LPDIRECT3DCREATE9)(UINT);
+typedef IDirect3D9* (WINAPI *LPDIRECT3DCREATE9)(UINT);
-struct _tagDIRECTD3D9_INT_
+typedef struct _tagDIRECTD3D9_INT_
{
/* 0x0000 */ LPVOID lpVtbl; /* LPDIRECTD3D9 functoions table */
/* 0x0004 */ CRITICAL_SECTION d3d9_cs;
@@ -4594,4 +4594,4 @@
/* 0x47ac */ DWORD unknown004587;
/* 0x47b0 */ DWORD unknown004588;
/* 0x47b4 */ DWORD unknown004589; /*? 0x00000020 */
-} *DIRECTD3D9_INT;
+} DIRECTD3D9_INT, *LPDIRECTD3D9_INT;