mirror of
https://github.com/reactos/reactos.git
synced 2025-06-05 17:30:32 +00:00
* Renamed internal IDirect3D9 structure
* Made Direct3D9Impl's IUnknown interface more robust thanks to hpoussin * Inited more values in internal struct svn path=/trunk/; revision=31335
This commit is contained in:
parent
a69fd32e4b
commit
141a3b554b
4 changed files with 36 additions and 14 deletions
|
@ -14,6 +14,10 @@
|
||||||
|
|
||||||
static LPCSTR D3dDebugRegPath = "Software\\Microsoft\\Direct3D";
|
static LPCSTR D3dDebugRegPath = "Software\\Microsoft\\Direct3D";
|
||||||
|
|
||||||
|
LPDIRECT3D9_INT impl_from_IDirect3D9(LPDIRECT3D9 iface)
|
||||||
|
{
|
||||||
|
return (LPDIRECT3D9_INT)((ULONG_PTR)iface - FIELD_OFFSET(DIRECT3D9_INT, lpVtbl));
|
||||||
|
}
|
||||||
|
|
||||||
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize)
|
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize)
|
||||||
{
|
{
|
||||||
|
@ -58,12 +62,12 @@ HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR For
|
||||||
|
|
||||||
HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9)
|
HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9)
|
||||||
{
|
{
|
||||||
LPDIRECTD3D9_INT pDirect3D9;
|
LPDIRECT3D9_INT pDirect3D9;
|
||||||
|
|
||||||
if (ppDirect3D9 == 0)
|
if (ppDirect3D9 == 0)
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
|
|
||||||
pDirect3D9 = HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTD3D9_INT));
|
pDirect3D9 = HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECT3D9_INT));
|
||||||
|
|
||||||
if (0 == pDirect3D9)
|
if (0 == pDirect3D9)
|
||||||
return DDERR_OUTOFMEMORY;
|
return DDERR_OUTOFMEMORY;
|
||||||
|
@ -75,7 +79,16 @@ HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9)
|
||||||
pDirect3D9->dwProcessId = GetCurrentThreadId();
|
pDirect3D9->dwProcessId = GetCurrentThreadId();
|
||||||
pDirect3D9->dwRefCnt = 1;
|
pDirect3D9->dwRefCnt = 1;
|
||||||
|
|
||||||
*ppDirect3D9 = (IDirect3D9*)pDirect3D9;
|
pDirect3D9->unknown004576 = 0;
|
||||||
|
pDirect3D9->unknown004578 = 0;
|
||||||
|
pDirect3D9->unknown004579 = 0;
|
||||||
|
pDirect3D9->unknown004580 = 0;
|
||||||
|
pDirect3D9->unknown004581 = 0;
|
||||||
|
pDirect3D9->unknown004582 = 0;
|
||||||
|
pDirect3D9->unknown004583 = 0;
|
||||||
|
pDirect3D9->unknown004589 = 0;
|
||||||
|
|
||||||
|
*ppDirect3D9 = (LPDIRECT3D9)&pDirect3D9->lpVtbl;
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,13 @@
|
||||||
* PURPOSE: d3d9.dll helper functions
|
* PURPOSE: d3d9.dll helper functions
|
||||||
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
|
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
|
||||||
*/
|
*/
|
||||||
|
#ifndef _D3D9_HELPERS_H_
|
||||||
|
#define _D3D9_HELPERS_H_
|
||||||
|
|
||||||
#include <d3d9.h>
|
#include "d3d9_private.h"
|
||||||
#include <windows.h>
|
|
||||||
|
/* Convert a IDirect3D9 pointer safely to the internal implementation struct */
|
||||||
|
LPDIRECT3D9_INT impl_from_IDirect3D9(LPDIRECT3D9 iface);
|
||||||
|
|
||||||
/* Reads a registry value if it's of the correct value type */
|
/* 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);
|
BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataBuffer, IN OUT LPDWORD DataBufferSize);
|
||||||
|
@ -17,3 +21,5 @@ HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR For
|
||||||
|
|
||||||
/* Creates a Direct3D9 object */
|
/* Creates a Direct3D9 object */
|
||||||
HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9);
|
HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9);
|
||||||
|
|
||||||
|
#endif // _D3D9_HELPERS_H_
|
||||||
|
|
|
@ -5,20 +5,18 @@
|
||||||
* PURPOSE: IDirect3D9 implementation
|
* PURPOSE: IDirect3D9 implementation
|
||||||
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
|
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
|
||||||
*/
|
*/
|
||||||
#include "d3d9_private.h"
|
#include "d3d9_helpers.h"
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface);
|
|
||||||
|
|
||||||
/* IDirect3D9: IUnknown implementation */
|
/* IDirect3D9: IUnknown implementation */
|
||||||
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppvObject)
|
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppvObject)
|
||||||
{
|
{
|
||||||
LPDIRECTD3D9_INT This = (LPDIRECTD3D9_INT)iface;
|
LPDIRECT3D9_INT This = impl_from_IDirect3D9(iface);
|
||||||
|
|
||||||
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3D9))
|
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3D9))
|
||||||
{
|
{
|
||||||
IDirect3D9Impl_AddRef(iface);
|
IUnknown_AddRef(iface);
|
||||||
*ppvObject = &This->lpVtbl;
|
*ppvObject = &This->lpVtbl;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +27,7 @@ static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID ri
|
||||||
|
|
||||||
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface)
|
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface)
|
||||||
{
|
{
|
||||||
LPDIRECTD3D9_INT This = (LPDIRECTD3D9_INT)iface;
|
LPDIRECT3D9_INT This = impl_from_IDirect3D9(iface);
|
||||||
ULONG ref = InterlockedIncrement(&This->dwRefCnt);
|
ULONG ref = InterlockedIncrement(&This->dwRefCnt);
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
|
@ -37,7 +35,7 @@ static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface)
|
||||||
|
|
||||||
static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface)
|
static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface)
|
||||||
{
|
{
|
||||||
LPDIRECTD3D9_INT This = (LPDIRECTD3D9_INT)iface;
|
LPDIRECT3D9_INT This = impl_from_IDirect3D9(iface);
|
||||||
ULONG ref = InterlockedDecrement(&This->dwRefCnt);
|
ULONG ref = InterlockedDecrement(&This->dwRefCnt);
|
||||||
|
|
||||||
if (ref == 0)
|
if (ref == 0)
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
* PURPOSE: d3d9.dll helper functions
|
* PURPOSE: d3d9.dll helper functions
|
||||||
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
|
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
|
||||||
*/
|
*/
|
||||||
|
#ifndef _D3D9_PRIVATE_H_
|
||||||
|
#define _D3D9_PRIVATE_H_
|
||||||
|
|
||||||
|
#define COBJMACROS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
|
|
||||||
|
@ -15,7 +18,7 @@ typedef IDirect3D9* (WINAPI *LPDIRECT3DCREATE9)(UINT);
|
||||||
|
|
||||||
extern const IDirect3D9Vtbl Direct3D9_Vtbl;
|
extern const IDirect3D9Vtbl Direct3D9_Vtbl;
|
||||||
|
|
||||||
typedef struct _tagDIRECTD3D9_INT_
|
typedef struct _tagDIRECT3D9_INT_
|
||||||
{
|
{
|
||||||
/* 0x0000 */ const IDirect3D9Vtbl *lpVtbl; /* LPDIRECTD3D9 functoions table */
|
/* 0x0000 */ const IDirect3D9Vtbl *lpVtbl; /* LPDIRECTD3D9 functoions table */
|
||||||
/* 0x0004 */ CRITICAL_SECTION d3d9_cs;
|
/* 0x0004 */ CRITICAL_SECTION d3d9_cs;
|
||||||
|
@ -4596,4 +4599,6 @@ typedef struct _tagDIRECTD3D9_INT_
|
||||||
/* 0x47ac */ DWORD unknown004587;
|
/* 0x47ac */ DWORD unknown004587;
|
||||||
/* 0x47b0 */ DWORD unknown004588;
|
/* 0x47b0 */ DWORD unknown004588;
|
||||||
/* 0x47b4 */ DWORD unknown004589; /*? 0x00000020 */
|
/* 0x47b4 */ DWORD unknown004589; /*? 0x00000020 */
|
||||||
} DIRECTD3D9_INT, *LPDIRECTD3D9_INT;
|
} DIRECT3D9_INT, *LPDIRECT3D9_INT;
|
||||||
|
|
||||||
|
#endif // _D3D9_PRIVATE_H_
|
||||||
|
|
Loading…
Reference in a new issue