2014-07-19 18:35:47 +00:00
|
|
|
#include "d3d8Wrapper.h"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
namespace D3D8Wrapper
|
|
|
|
{
|
|
|
|
ThreadSafePointerSet IDirect3D8::m_List;
|
|
|
|
|
2014-07-20 02:38:57 +00:00
|
|
|
D3D8Wrapper::IDirect3D8::IDirect3D8(D3D8Base::IDirect3D8* real) : D3D8Wrapper::IDirect3DUnknown((IUnknown*) real)
|
|
|
|
{
|
|
|
|
m_pD3D = real;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tries to find the real object in the pointer set, or creates a new wrapped object
|
2014-07-19 18:35:47 +00:00
|
|
|
D3D8Wrapper::IDirect3D8* D3D8Wrapper::IDirect3D8::GetDirect3D(D3D8Base::IDirect3D8* pD3D)
|
|
|
|
{
|
|
|
|
D3D8Wrapper::IDirect3D8* p = (D3D8Wrapper::IDirect3D8*) m_List.GetDataPtr(pD3D);
|
|
|
|
if( p == NULL )
|
|
|
|
{
|
|
|
|
p = new D3D8Wrapper::IDirect3D8(pD3D);
|
|
|
|
m_List.AddMember(pD3D,p);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->m_ulRef++;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3D8::Release(THIS)
|
|
|
|
{
|
|
|
|
m_pUnk->Release();
|
|
|
|
|
|
|
|
ULONG ulRef = --m_ulRef;
|
|
|
|
|
|
|
|
if(ulRef == 0)
|
|
|
|
{
|
|
|
|
m_List.DeleteMember(GetDirect3D8());
|
|
|
|
delete this;
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
return ulRef;
|
|
|
|
}
|
|
|
|
|
2014-07-20 02:38:57 +00:00
|
|
|
|
2014-07-19 18:35:47 +00:00
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterDisplayMode(THIS_ UINT Adapter,D3D8Base::D3DDISPLAYMODE* pMode)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::GetAdapterDisplayMode");
|
|
|
|
return m_pD3D->GetAdapterDisplayMode(Adapter, pMode);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*** IDirect3D8 methods ***/
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::RegisterSoftwareDevice(void* pInitializeFunction)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::RegisterSoftwareDevice");
|
|
|
|
return m_pD3D->RegisterSoftwareDevice(pInitializeFunction);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterCount(THIS)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::GetAdapterCount");
|
2014-07-19 18:35:47 +00:00
|
|
|
return m_pD3D->GetAdapterCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3D8Base::D3DADAPTER_IDENTIFIER8* pIdentifier)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::GetAdapterIdentifier");
|
|
|
|
return m_pD3D->GetAdapterIdentifier(Adapter,Flags,pIdentifier);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterModeCount(UINT Adapter)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::GetAdapterModeCount");
|
2014-07-19 18:35:47 +00:00
|
|
|
return m_pD3D->GetAdapterModeCount(Adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::EnumAdapterModes(UINT Adapter,UINT Mode,D3D8Base::D3DDISPLAYMODE* pMode)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::EnumAdapterModes");
|
|
|
|
return m_pD3D->EnumAdapterModes(Adapter,Mode,pMode);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceType(UINT Adapter,D3D8Base::D3DDEVTYPE CheckType,D3D8Base::D3DFORMAT DisplayFormat,D3D8Base::D3DFORMAT BackBufferFormat,BOOL Windowed)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::CheckDeviceType");
|
|
|
|
return m_pD3D->CheckDeviceType(Adapter,CheckType,DisplayFormat,BackBufferFormat,Windowed);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceFormat(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,DWORD Usage,D3D8Base::D3DRESOURCETYPE RType,D3D8Base::D3DFORMAT CheckFormat)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::CheckDeviceFormat");
|
|
|
|
return m_pD3D->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceMultiSampleType(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT SurfaceFormat,BOOL Windowed,D3D8Base::D3DMULTISAMPLE_TYPE MultiSampleType)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::CheckDeviceMultiSampleType");
|
|
|
|
return m_pD3D->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDepthStencilMatch(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,D3D8Base::D3DFORMAT RenderTargetFormat,D3D8Base::D3DFORMAT DepthStencilFormat)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::CheckDepthStencilMatch");
|
|
|
|
return m_pD3D->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetDeviceCaps(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DCAPS8* pCaps)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::GetDeviceCaps");
|
|
|
|
return m_pD3D->GetDeviceCaps(Adapter,DeviceType,pCaps);
|
2014-07-19 18:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(HMONITOR) D3D8Wrapper::IDirect3D8::GetAdapterMonitor(UINT Adapter)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::GetAdapterMonitor");
|
2014-07-19 18:35:47 +00:00
|
|
|
return m_pD3D->GetAdapterMonitor(Adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CreateDevice(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface)
|
|
|
|
{
|
2014-07-20 02:38:57 +00:00
|
|
|
LOG("IDirect3D8::CreateDevice");
|
|
|
|
D3D8Base::IDirect3DDevice8* base_device = NULL;
|
2014-07-19 18:35:47 +00:00
|
|
|
|
2014-07-20 02:38:57 +00:00
|
|
|
HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,&base_device);
|
2014-07-19 18:35:47 +00:00
|
|
|
|
2014-07-20 02:38:57 +00:00
|
|
|
// Wrap the real object
|
|
|
|
D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(base_device);
|
2014-07-19 18:35:47 +00:00
|
|
|
|
2014-07-20 02:38:57 +00:00
|
|
|
last_device = f;
|
2014-07-19 18:35:47 +00:00
|
|
|
|
2014-07-20 02:38:57 +00:00
|
|
|
// Return our wrapped object
|
|
|
|
*ppReturnedDeviceInterface = f;
|
2014-07-19 18:35:47 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|