diff --git a/DDrawCompat/DDraw/DirectDrawSurface.cpp b/DDrawCompat/DDraw/DirectDrawSurface.cpp index 51cc642..b05b47f 100644 --- a/DDrawCompat/DDraw/DirectDrawSurface.cpp +++ b/DDrawCompat/DDraw/DirectDrawSurface.cpp @@ -66,6 +66,7 @@ namespace DDraw SET_COMPAT_METHOD(GetSurfaceDesc); SET_COMPAT_METHOD(IsLost); SET_COMPAT_METHOD(Lock); + SET_COMPAT_METHOD(QueryInterface); SET_COMPAT_METHOD(ReleaseDC); SET_COMPAT_METHOD(Restore); SET_COMPAT_METHOD(SetPalette); diff --git a/DDrawCompat/DDraw/Log.cpp b/DDrawCompat/DDraw/Log.cpp index 45bd3b9..07d3045 100644 --- a/DDrawCompat/DDraw/Log.cpp +++ b/DDrawCompat/DDraw/Log.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -51,3 +53,56 @@ std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC2& sd) << sd.ddsCaps << sd.dwTextureStage; } + +std::ostream& operator<<(std::ostream& os, const GUID& guid) +{ +#define LOG_GUID(g) if (g == guid) return os << #g + LOG_GUID(CLSID_DirectDraw); + LOG_GUID(CLSID_DirectDraw7); + LOG_GUID(CLSID_DirectDrawClipper); + LOG_GUID(IID_IDirectDraw); + LOG_GUID(IID_IDirectDraw2); + LOG_GUID(IID_IDirectDraw4); + LOG_GUID(IID_IDirectDraw7); + LOG_GUID(IID_IDirectDrawSurface); + LOG_GUID(IID_IDirectDrawSurface2); + LOG_GUID(IID_IDirectDrawSurface3); + LOG_GUID(IID_IDirectDrawSurface4); + LOG_GUID(IID_IDirectDrawSurface7); + LOG_GUID(IID_IDirectDrawPalette); + LOG_GUID(IID_IDirectDrawClipper); + LOG_GUID(IID_IDirectDrawColorControl); + LOG_GUID(IID_IDirectDrawGammaControl); + LOG_GUID(IID_IDirect3D); + LOG_GUID(IID_IDirect3D2); + LOG_GUID(IID_IDirect3D3); + LOG_GUID(IID_IDirect3D7); + LOG_GUID(IID_IDirect3DRampDevice); + LOG_GUID(IID_IDirect3DRGBDevice); + LOG_GUID(IID_IDirect3DHALDevice); + LOG_GUID(IID_IDirect3DMMXDevice); + LOG_GUID(IID_IDirect3DRefDevice); + LOG_GUID(IID_IDirect3DNullDevice); + LOG_GUID(IID_IDirect3DTnLHalDevice); + LOG_GUID(IID_IDirect3DDevice); + LOG_GUID(IID_IDirect3DDevice2); + LOG_GUID(IID_IDirect3DDevice3); + LOG_GUID(IID_IDirect3DDevice7); + LOG_GUID(IID_IDirect3DTexture); + LOG_GUID(IID_IDirect3DTexture2); + LOG_GUID(IID_IDirect3DLight); + LOG_GUID(IID_IDirect3DMaterial); + LOG_GUID(IID_IDirect3DMaterial2); + LOG_GUID(IID_IDirect3DMaterial3); + LOG_GUID(IID_IDirect3DExecuteBuffer); + LOG_GUID(IID_IDirect3DViewport); + LOG_GUID(IID_IDirect3DViewport2); + LOG_GUID(IID_IDirect3DViewport3); + LOG_GUID(IID_IDirect3DVertexBuffer); + LOG_GUID(IID_IDirect3DVertexBuffer7); +#undef LOG_GUID + + OLECHAR str[256] = {}; + StringFromGUID2(guid, str, sizeof(str)); + return os << str; +} diff --git a/DDrawCompat/DDraw/Log.h b/DDrawCompat/DDraw/Log.h index 6288609..434177b 100644 --- a/DDrawCompat/DDraw/Log.h +++ b/DDrawCompat/DDraw/Log.h @@ -9,3 +9,4 @@ std::ostream& operator<<(std::ostream& os, const DDSCAPS2& caps); std::ostream& operator<<(std::ostream& os, const DDPIXELFORMAT& pf); std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC& sd); std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC2& sd); +std::ostream& operator<<(std::ostream& os, const GUID& guid); diff --git a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp index 6abb61a..d14daf3 100644 --- a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp +++ b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp @@ -129,6 +129,12 @@ namespace DDraw return result; } + template + HRESULT SurfaceImpl::QueryInterface(TSurface* This, REFIID riid, LPVOID* obp) + { + return s_origVtable.QueryInterface(This, (IID_IDirect3DRampDevice == riid ? IID_IDirect3DRGBDevice : riid), obp); + } + template HRESULT SurfaceImpl::ReleaseDC(TSurface* This, HDC hDC) { diff --git a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h index 97b332c..2c49e36 100644 --- a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h +++ b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h @@ -35,6 +35,7 @@ namespace DDraw virtual HRESULT IsLost(TSurface* This); virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent); + virtual HRESULT QueryInterface(TSurface* This, REFIID riid, LPVOID* obp); virtual HRESULT ReleaseDC(TSurface* This, HDC hDC); virtual HRESULT Restore(TSurface* This); virtual HRESULT SetPalette(TSurface* This, LPDIRECTDRAWPALETTE lpDDPalette); diff --git a/DDrawCompat/Direct3d/Direct3d.cpp b/DDrawCompat/Direct3d/Direct3d.cpp index e8e8641..008e821 100644 --- a/DDrawCompat/Direct3d/Direct3d.cpp +++ b/DDrawCompat/Direct3d/Direct3d.cpp @@ -14,17 +14,19 @@ namespace void* userArg; }; + template HRESULT STDMETHODCALLTYPE createDevice( - IDirect3D7* This, + TDirect3d* This, REFCLSID rclsid, - LPDIRECTDRAWSURFACE7 lpDDS, - LPDIRECT3DDEVICE7* lplpD3DDevice) + TDirectDrawSurface* lpDDS, + TDirect3dDevice** lplpD3DDevice, + Params... params) { - HRESULT result = CompatVtable::s_origVtable.CreateDevice( - This, rclsid, lpDDS, lplpD3DDevice); + HRESULT result = CompatVtable>::s_origVtable.CreateDevice( + This, (IID_IDirect3DRampDevice == rclsid) ? IID_IDirect3DRGBDevice : rclsid, lpDDS, lplpD3DDevice, params...); if (SUCCEEDED(result)) { - CompatVtable::hookVtable((*lplpD3DDevice)->lpVtbl); + CompatVtable>::hookVtable((*lplpD3DDevice)->lpVtbl); } return result; } @@ -73,12 +75,12 @@ namespace This, &d3dEnumDevicesCallback, ¶ms); } - template - void setCompatVtable7(TDirect3dVtbl& /*vtable*/) + void setCompatVtable2(IDirect3DVtbl& /*vtable*/) { } - void setCompatVtable7(IDirect3D7Vtbl& vtable) + template + void setCompatVtable2(TDirect3dVtbl& vtable) { vtable.CreateDevice = &createDevice; } @@ -91,7 +93,7 @@ namespace Direct3d { vtable.EnumDevices = &enumDevices; // No need to fix FindDevice since it uses EnumDevices - setCompatVtable7(vtable); + setCompatVtable2(vtable); } template Direct3d;