diff --git a/DDrawCompat/CompatDepthBuffer.h b/DDrawCompat/CompatDepthBuffer.h deleted file mode 100644 index bc596f1..0000000 --- a/DDrawCompat/CompatDepthBuffer.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -#include "CompatPtr.h" - -namespace CompatDepthBuffer -{ - template - void fixSupportedZBufferBitDepths(CompatPtr d3d, TD3dDeviceDesc& desc); -} diff --git a/DDrawCompat/CompatDirect3d.h b/DDrawCompat/CompatDirect3d.h deleted file mode 100644 index 6cc80f2..0000000 --- a/DDrawCompat/CompatDirect3d.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "CompatVtable.h" -#include "Direct3dVtblVisitor.h" - -template -class CompatDirect3d : public CompatVtable, TDirect3d> -{ -public: - static void setCompatVtable(Vtable& vtable); -}; diff --git a/DDrawCompat/CompatDirect3dDevice.h b/DDrawCompat/CompatDirect3dDevice.h deleted file mode 100644 index 4126697..0000000 --- a/DDrawCompat/CompatDirect3dDevice.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "CompatVtable.h" -#include "Direct3dDeviceVtblVisitor.h" - -template -class CompatDirect3dDevice : public CompatVtable, TDirect3dDevice> -{ -public: - static void setCompatVtable(Vtable& vtable); -}; diff --git a/DDrawCompat/DDraw/Hooks.cpp b/DDrawCompat/DDraw/Hooks.cpp index 274ff42..25b7542 100644 --- a/DDrawCompat/DDraw/Hooks.cpp +++ b/DDrawCompat/DDraw/Hooks.cpp @@ -2,8 +2,6 @@ #include -#include "CompatDirect3d.h" -#include "CompatDirect3dDevice.h" #include "CompatPtr.h" #include "CompatRef.h" #include "DDraw/ActivateAppHandler.h" @@ -14,108 +12,12 @@ #include "DDraw/RealPrimarySurface.h" #include "DDraw/Repository.h" #include "DDrawLog.h" -#include "DDrawProcs.h" namespace { - void hookDirect3dDevice(CompatRef d3d, CompatRef renderTarget); - void hookDirect3dDevice7(CompatRef d3d, CompatRef renderTarget); - template void hookVtable(const CompatPtr& intf); - template - CompatPtr createDirect3d(CompatRef dd) - { - CompatPtr d3d; - HRESULT result = dd->QueryInterface(&dd, Compat::getIntfId(), - reinterpret_cast(&d3d.getRef())); - if (FAILED(result)) - { - Compat::Log() << "Failed to create a Direct3D object for hooking: " << result; - } - return d3d; - } - - template - CompatPtr createDirect3dDevice( - CompatRef d3d, CompatRef renderTarget, Params... params) - { - CompatPtr d3dDevice; - HRESULT result = d3d->CreateDevice( - &d3d, IID_IDirect3DRGBDevice, &renderTarget, &d3dDevice.getRef(), params...); - if (FAILED(result)) - { - Compat::Log() << "Failed to create a Direct3D device for hooking: " << result; - } - return d3dDevice; - } - - CompatPtr createRenderTarget(CompatRef dd) - { - DDSURFACEDESC2 desc = {}; - desc.dwSize = sizeof(desc); - desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; - desc.dwWidth = 1; - desc.dwHeight = 1; - desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat); - desc.ddpfPixelFormat.dwFlags = DDPF_RGB; - desc.ddpfPixelFormat.dwRGBBitCount = 32; - desc.ddpfPixelFormat.dwRBitMask = 0x00FF0000; - desc.ddpfPixelFormat.dwGBitMask = 0x0000FF00; - desc.ddpfPixelFormat.dwBBitMask = 0x000000FF; - desc.ddsCaps.dwCaps = DDSCAPS_3DDEVICE; - - CompatPtr renderTarget; - HRESULT result = dd->CreateSurface(&dd, &desc, &renderTarget.getRef(), nullptr); - if (FAILED(result)) - { - Compat::Log() << "Failed to create a render target for hooking: " << result; - } - return renderTarget; - } - - void hookDirect3d(CompatRef dd, CompatRef renderTarget) - { - CompatPtr d3d(createDirect3d(dd)); - if (d3d) - { - hookVtable>(d3d); - hookVtable>(d3d); - hookVtable>(d3d); - hookDirect3dDevice(*d3d, renderTarget); - } - } - - void hookDirect3d7(CompatRef dd, CompatRef renderTarget) - { - CompatPtr d3d(createDirect3d(dd)); - if (d3d) - { - hookVtable>(d3d); - hookDirect3dDevice7(*d3d, renderTarget); - } - } - - void hookDirect3dDevice(CompatRef d3d, CompatRef renderTarget) - { - CompatPtr d3dDevice( - createDirect3dDevice(d3d, renderTarget, nullptr)); - - hookVtable>(d3dDevice); - hookVtable>(d3dDevice); - hookVtable>(d3dDevice); - } - - void hookDirect3dDevice7(CompatRef d3d, CompatRef renderTarget) - { - CompatPtr d3dDevice( - createDirect3dDevice(d3d, renderTarget)); - - hookVtable>(d3dDevice); - } - void hookDirectDraw(CompatRef dd) { DDraw::DirectDraw::s_origVtable = *(&dd)->lpVtbl; @@ -206,14 +108,6 @@ namespace DDraw hookDirectDrawSurface(*dd7); hookDirectDrawPalette(*dd7); - CompatPtr renderTarget7(createRenderTarget(*dd7)); - if (renderTarget7) - { - CompatPtr renderTarget4(renderTarget7); - hookDirect3d(*dd, *renderTarget4); - hookDirect3d7(*dd7, *renderTarget7); - } - ActivateAppHandler::installHooks(); } diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index f8cccbc..3539404 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -93,6 +93,7 @@ MultiThreadedDebug true false + $(IntDir)%(RelativeDir) DDrawCompat.def @@ -121,6 +122,7 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions) MultiThreaded true + $(IntDir)%(RelativeDir) DDrawCompat.def @@ -151,9 +153,6 @@ - - - @@ -184,8 +183,12 @@ - + + + + + @@ -209,9 +212,6 @@ - - - @@ -228,6 +228,10 @@ + + + + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index e1a3d99..b72434c 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -25,6 +25,12 @@ {bcc85014-8548-43ff-902f-16bcb6a0e96b} + + {1e5628f5-39bf-4080-ae94-938081671cf8} + + + {08a23b36-cd96-4214-985b-0473ecf6ecab} + @@ -81,21 +87,9 @@ Header Files - - Header Files - Header Files - - Header Files - - - Header Files - - - Header Files - Header Files @@ -195,6 +189,21 @@ Header Files\DDraw + + Header Files\Direct3d + + + Header Files\Direct3d + + + Header Files\Direct3d + + + Header Files\Direct3d + + + Header Files\Direct3d + @@ -224,15 +233,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - Source Files @@ -311,6 +311,18 @@ Source Files\DDraw + + Source Files\Direct3d + + + Source Files\Direct3d + + + Source Files\Direct3d + + + Source Files\Direct3d + diff --git a/DDrawCompat/CompatDepthBuffer.cpp b/DDrawCompat/Direct3d/DepthBuffer.cpp similarity index 79% rename from DDrawCompat/CompatDepthBuffer.cpp rename to DDrawCompat/Direct3d/DepthBuffer.cpp index a008cad..fabf745 100644 --- a/DDrawCompat/CompatDepthBuffer.cpp +++ b/DDrawCompat/Direct3d/DepthBuffer.cpp @@ -1,7 +1,7 @@ #include #include -#include "CompatDepthBuffer.h" +#include "Direct3d/DepthBuffer.h" namespace { @@ -101,24 +101,27 @@ namespace } } -namespace CompatDepthBuffer +namespace Direct3d { - template - void fixSupportedZBufferBitDepths( - CompatPtr d3d, TD3dDeviceDesc& desc) + namespace DepthBuffer { - if (isHardwareZBufferSupported(desc)) + template + void fixSupportedZBufferBitDepths( + CompatPtr d3d, TD3dDeviceDesc& desc) { - const DWORD supportedBitDepths = getSupportedZBufferBitDepths(d3d, getDeviceGuid(desc)); - if (0 != supportedBitDepths && supportedBitDepths != desc.dwDeviceZBufferBitDepth) + if (isHardwareZBufferSupported(desc)) { - logSupportedZBufferBitDepthsChanged( - d3d, getDeviceGuid(desc), desc.dwDeviceZBufferBitDepth, supportedBitDepths); - desc.dwDeviceZBufferBitDepth = supportedBitDepths; + const DWORD supportedBitDepths = getSupportedZBufferBitDepths(d3d, getDeviceGuid(desc)); + if (0 != supportedBitDepths && supportedBitDepths != desc.dwDeviceZBufferBitDepth) + { + logSupportedZBufferBitDepthsChanged( + d3d, getDeviceGuid(desc), desc.dwDeviceZBufferBitDepth, supportedBitDepths); + desc.dwDeviceZBufferBitDepth = supportedBitDepths; + } } } - } - template void fixSupportedZBufferBitDepths(CompatPtr, D3DDEVICEDESC&); - template void fixSupportedZBufferBitDepths(CompatPtr, D3DDEVICEDESC7&); + template void fixSupportedZBufferBitDepths(CompatPtr, D3DDEVICEDESC&); + template void fixSupportedZBufferBitDepths(CompatPtr, D3DDEVICEDESC7&); + } } diff --git a/DDrawCompat/Direct3d/DepthBuffer.h b/DDrawCompat/Direct3d/DepthBuffer.h new file mode 100644 index 0000000..aea64b5 --- /dev/null +++ b/DDrawCompat/Direct3d/DepthBuffer.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "CompatPtr.h" + +namespace Direct3d +{ + namespace DepthBuffer + { + template + void fixSupportedZBufferBitDepths(CompatPtr d3d, TD3dDeviceDesc& desc); + } +} diff --git a/DDrawCompat/CompatDirect3d.cpp b/DDrawCompat/Direct3d/Direct3d.cpp similarity index 65% rename from DDrawCompat/CompatDirect3d.cpp rename to DDrawCompat/Direct3d/Direct3d.cpp index d728c54..4ee9825 100644 --- a/DDrawCompat/CompatDirect3d.cpp +++ b/DDrawCompat/Direct3d/Direct3d.cpp @@ -1,7 +1,7 @@ -#include "CompatDepthBuffer.h" -#include "CompatDirect3d.h" #include "CompatPtr.h" -#include "Direct3dTypes.h" +#include "Direct3d/DepthBuffer.h" +#include "Direct3d/Direct3d.h" +#include "Direct3d/Types.h" namespace { @@ -9,7 +9,7 @@ namespace struct EnumDevicesParams { CompatPtr d3d; - typename Types::TD3dEnumDevicesCallback enumDevicesCallback; + typename Direct3d::Types::TD3dEnumDevicesCallback enumDevicesCallback; void* userArg; }; @@ -22,7 +22,7 @@ namespace LPVOID lpContext) { auto& params = *reinterpret_cast*>(lpContext); - CompatDepthBuffer::fixSupportedZBufferBitDepths(params.d3d, *lpD3DHWDeviceDesc); + Direct3d::DepthBuffer::fixSupportedZBufferBitDepths(params.d3d, *lpD3DHWDeviceDesc); return params.enumDevicesCallback(lpGuid, lpDeviceDescription, lpDeviceName, lpD3DHWDeviceDesc, lpD3DHELDeviceDesc, params.userArg); } @@ -34,7 +34,7 @@ namespace LPVOID lpContext) { auto& params = *reinterpret_cast*>(lpContext); - CompatDepthBuffer::fixSupportedZBufferBitDepths(params.d3d, *lpD3DDeviceDesc); + Direct3d::DepthBuffer::fixSupportedZBufferBitDepths(params.d3d, *lpD3DDeviceDesc); return params.enumDevicesCallback(lpDeviceDescription, lpDeviceName, lpD3DDeviceDesc, params.userArg); } @@ -49,7 +49,7 @@ namespace This, lpEnumDevicesCallback, lpUserArg); } - typedef typename Types::TDirect3dHighest TDirect3dHighest; + typedef typename Direct3d::Types::TDirect3dHighest TDirect3dHighest; CompatPtr d3d(Compat::queryInterface(This)); EnumDevicesParams params = { d3d, lpEnumDevicesCallback, lpUserArg }; @@ -58,14 +58,17 @@ namespace } } -template -void CompatDirect3d::setCompatVtable(Vtable& vtable) +namespace Direct3d { - vtable.EnumDevices = &enumDevices; - // No need to fix FindDevice since it uses EnumDevices -} + template + void Direct3d::setCompatVtable(Vtable& vtable) + { + vtable.EnumDevices = &enumDevices; + // No need to fix FindDevice since it uses EnumDevices + } -template CompatDirect3d; -template CompatDirect3d; -template CompatDirect3d; -template CompatDirect3d; + template Direct3d; + template Direct3d; + template Direct3d; + template Direct3d; +} diff --git a/DDrawCompat/Direct3d/Direct3d.h b/DDrawCompat/Direct3d/Direct3d.h new file mode 100644 index 0000000..e365ea6 --- /dev/null +++ b/DDrawCompat/Direct3d/Direct3d.h @@ -0,0 +1,14 @@ +#pragma once + +#include "CompatVtable.h" +#include "Direct3dVtblVisitor.h" + +namespace Direct3d +{ + template + class Direct3d : public CompatVtable, TDirect3d> + { + public: + static void setCompatVtable(Vtable& vtable); + }; +} diff --git a/DDrawCompat/CompatDirect3dDevice.cpp b/DDrawCompat/Direct3d/Direct3dDevice.cpp similarity index 53% rename from DDrawCompat/CompatDirect3dDevice.cpp rename to DDrawCompat/Direct3d/Direct3dDevice.cpp index bc39d24..ba3318b 100644 --- a/DDrawCompat/CompatDirect3dDevice.cpp +++ b/DDrawCompat/Direct3d/Direct3dDevice.cpp @@ -1,21 +1,21 @@ -#include "CompatDepthBuffer.h" -#include "CompatDirect3dDevice.h" #include "CompatPtr.h" #include "CompatRef.h" -#include "Direct3dTypes.h" +#include "Direct3d/DepthBuffer.h" +#include "Direct3d/Direct3dDevice.h" +#include "Direct3d/Types.h" namespace { template void fixSupportedZBufferBitDepths(CompatRef d3dDevice, TD3dDeviceDesc& desc) { - typedef typename Types::TDirect3d TDirect3d; + typedef typename Direct3d::Types::TDirect3d TDirect3d; CompatPtr d3d; if (SUCCEEDED(CompatVtableBase::s_origVtable.GetDirect3D( &d3dDevice, &d3d.getRef()))) { - typedef typename Types::TDirect3dHighest TDirect3dHighest; - CompatDepthBuffer::fixSupportedZBufferBitDepths(d3d, desc); + typedef typename Direct3d::Types::TDirect3dHighest TDirect3dHighest; + Direct3d::DepthBuffer::fixSupportedZBufferBitDepths(d3d, desc); } } @@ -35,13 +35,16 @@ namespace } } -template -void CompatDirect3dDevice::setCompatVtable(Vtable& vtable) +namespace Direct3d { - vtable.GetCaps = &getCaps; -} + template + void Direct3dDevice::setCompatVtable(Vtable& vtable) + { + vtable.GetCaps = &getCaps; + } -template CompatDirect3dDevice; -template CompatDirect3dDevice; -template CompatDirect3dDevice; -template CompatDirect3dDevice; + template Direct3dDevice; + template Direct3dDevice; + template Direct3dDevice; + template Direct3dDevice; +} diff --git a/DDrawCompat/Direct3d/Direct3dDevice.h b/DDrawCompat/Direct3d/Direct3dDevice.h new file mode 100644 index 0000000..3446609 --- /dev/null +++ b/DDrawCompat/Direct3d/Direct3dDevice.h @@ -0,0 +1,14 @@ +#pragma once + +#include "CompatVtable.h" +#include "Direct3dDeviceVtblVisitor.h" + +namespace Direct3d +{ + template + class Direct3dDevice : public CompatVtable, TDirect3dDevice> + { + public: + static void setCompatVtable(Vtable& vtable); + }; +} diff --git a/DDrawCompat/Direct3d/Hooks.cpp b/DDrawCompat/Direct3d/Hooks.cpp new file mode 100644 index 0000000..71fa0c6 --- /dev/null +++ b/DDrawCompat/Direct3d/Hooks.cpp @@ -0,0 +1,141 @@ +#define CINTERFACE + +#include + +#include "CompatPtr.h" +#include "CompatRef.h" +#include "DDraw/Repository.h" +#include "DDrawLog.h" +#include "Direct3d/Direct3d.h" +#include "Direct3d/Direct3dDevice.h" +#include "Direct3d/Hooks.h" + +namespace +{ + void hookDirect3dDevice(CompatRef d3d, CompatRef renderTarget); + void hookDirect3dDevice7(CompatRef d3d, CompatRef renderTarget); + + template + void hookVtable(const CompatPtr& intf); + + template + CompatPtr createDirect3d(CompatRef dd) + { + CompatPtr d3d; + HRESULT result = dd->QueryInterface(&dd, Compat::getIntfId(), + reinterpret_cast(&d3d.getRef())); + if (FAILED(result)) + { + Compat::Log() << "Failed to create a Direct3D object for hooking: " << result; + } + return d3d; + } + + template + CompatPtr createDirect3dDevice( + CompatRef d3d, CompatRef renderTarget, Params... params) + { + CompatPtr d3dDevice; + HRESULT result = d3d->CreateDevice( + &d3d, IID_IDirect3DRGBDevice, &renderTarget, &d3dDevice.getRef(), params...); + if (FAILED(result)) + { + Compat::Log() << "Failed to create a Direct3D device for hooking: " << result; + } + return d3dDevice; + } + + CompatPtr createRenderTarget(CompatRef dd) + { + DDSURFACEDESC2 desc = {}; + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; + desc.dwWidth = 1; + desc.dwHeight = 1; + desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat); + desc.ddpfPixelFormat.dwFlags = DDPF_RGB; + desc.ddpfPixelFormat.dwRGBBitCount = 32; + desc.ddpfPixelFormat.dwRBitMask = 0x00FF0000; + desc.ddpfPixelFormat.dwGBitMask = 0x0000FF00; + desc.ddpfPixelFormat.dwBBitMask = 0x000000FF; + desc.ddsCaps.dwCaps = DDSCAPS_3DDEVICE; + + CompatPtr renderTarget; + HRESULT result = dd->CreateSurface(&dd, &desc, &renderTarget.getRef(), nullptr); + if (FAILED(result)) + { + Compat::Log() << "Failed to create a render target for hooking: " << result; + } + return renderTarget; + } + + void hookDirect3d(CompatRef dd, CompatRef renderTarget) + { + CompatPtr d3d(createDirect3d(dd)); + if (d3d) + { + hookVtable>(d3d); + hookVtable>(d3d); + hookVtable>(d3d); + hookDirect3dDevice(*d3d, renderTarget); + } + } + + void hookDirect3d7(CompatRef dd, CompatRef renderTarget) + { + CompatPtr d3d(createDirect3d(dd)); + if (d3d) + { + hookVtable>(d3d); + hookDirect3dDevice7(*d3d, renderTarget); + } + } + + void hookDirect3dDevice(CompatRef d3d, CompatRef renderTarget) + { + CompatPtr d3dDevice( + createDirect3dDevice(d3d, renderTarget, nullptr)); + + hookVtable>(d3dDevice); + hookVtable>(d3dDevice); + hookVtable>(d3dDevice); + } + + void hookDirect3dDevice7(CompatRef d3d, CompatRef renderTarget) + { + CompatPtr d3dDevice( + createDirect3dDevice(d3d, renderTarget)); + + hookVtable>(d3dDevice); + } + + template + void hookVtable(const CompatPtr& intf) + { + CompatInterface::hookVtable(intf.get()->lpVtbl); + } +} + +namespace Direct3d +{ + void installHooks() + { + auto dd7(DDraw::Repository::getDirectDraw()); + CompatPtr dd; + CALL_ORIG_DDRAW(DirectDrawCreate, nullptr, &dd.getRef(), nullptr); + if (!dd || !dd7 || FAILED(dd->SetCooperativeLevel(dd, nullptr, DDSCL_NORMAL))) + { + Compat::Log() << "Failed to hook Direct3d interfaces"; + return; + } + + CompatPtr renderTarget7(createRenderTarget(*dd7)); + if (renderTarget7) + { + CompatPtr renderTarget4(renderTarget7); + hookDirect3d(*dd, *renderTarget4); + hookDirect3d7(*dd7, *renderTarget7); + } + } +} diff --git a/DDrawCompat/Direct3d/Hooks.h b/DDrawCompat/Direct3d/Hooks.h new file mode 100644 index 0000000..d9b6278 --- /dev/null +++ b/DDrawCompat/Direct3d/Hooks.h @@ -0,0 +1,6 @@ +#pragma once + +namespace Direct3d +{ + void installHooks(); +} diff --git a/DDrawCompat/Direct3d/Types.h b/DDrawCompat/Direct3d/Types.h new file mode 100644 index 0000000..988517a --- /dev/null +++ b/DDrawCompat/Direct3d/Types.h @@ -0,0 +1,57 @@ +#pragma once + +#define CINTERFACE + +#include + +namespace Direct3d +{ + struct Types1 + { + typedef IDirect3D TDirect3d; + typedef IDirect3D3 TDirect3dHighest; + typedef IDirect3DDevice TDirect3dDevice; + typedef D3DDEVICEDESC TD3dDeviceDesc; + typedef LPD3DENUMDEVICESCALLBACK TD3dEnumDevicesCallback; + }; + + struct Types2 + { + typedef IDirect3D2 TDirect3d; + typedef IDirect3D3 TDirect3dHighest; + typedef IDirect3DDevice2 TDirect3dDevice; + typedef D3DDEVICEDESC TD3dDeviceDesc; + typedef LPD3DENUMDEVICESCALLBACK TD3dEnumDevicesCallback; + }; + + struct Types3 + { + typedef IDirect3D3 TDirect3d; + typedef IDirect3D3 TDirect3dHighest; + typedef IDirect3DDevice3 TDirect3dDevice; + typedef D3DDEVICEDESC TD3dDeviceDesc; + typedef LPD3DENUMDEVICESCALLBACK TD3dEnumDevicesCallback; + }; + + struct Types7 + { + typedef IDirect3D7 TDirect3d; + typedef IDirect3D7 TDirect3dHighest; + typedef IDirect3DDevice7 TDirect3dDevice; + typedef D3DDEVICEDESC7 TD3dDeviceDesc; + typedef LPD3DENUMDEVICESCALLBACK7 TD3dEnumDevicesCallback; + }; + + template + struct Types; + + template <> struct Types : Types1 {}; + template <> struct Types : Types2 {}; + template <> struct Types : Types3 {}; + template <> struct Types : Types7 {}; + + template <> struct Types : Types1 {}; + template <> struct Types : Types2 {}; + template <> struct Types : Types3 {}; + template <> struct Types : Types7 {}; +} diff --git a/DDrawCompat/Direct3dTypes.h b/DDrawCompat/Direct3dTypes.h deleted file mode 100644 index a9be937..0000000 --- a/DDrawCompat/Direct3dTypes.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#define CINTERFACE - -#include - -struct Direct3dTypes -{ - typedef IDirect3D TDirect3d; - typedef IDirect3D3 TDirect3dHighest; - typedef IDirect3DDevice TDirect3dDevice; - typedef D3DDEVICEDESC TD3dDeviceDesc; - typedef LPD3DENUMDEVICESCALLBACK TD3dEnumDevicesCallback; -}; - -struct Direct3dTypes2 -{ - typedef IDirect3D2 TDirect3d; - typedef IDirect3D3 TDirect3dHighest; - typedef IDirect3DDevice2 TDirect3dDevice; - typedef D3DDEVICEDESC TD3dDeviceDesc; - typedef LPD3DENUMDEVICESCALLBACK TD3dEnumDevicesCallback; -}; - -struct Direct3dTypes3 -{ - typedef IDirect3D3 TDirect3d; - typedef IDirect3D3 TDirect3dHighest; - typedef IDirect3DDevice3 TDirect3dDevice; - typedef D3DDEVICEDESC TD3dDeviceDesc; - typedef LPD3DENUMDEVICESCALLBACK TD3dEnumDevicesCallback; -}; - -struct Direct3dTypes7 -{ - typedef IDirect3D7 TDirect3d; - typedef IDirect3D7 TDirect3dHighest; - typedef IDirect3DDevice7 TDirect3dDevice; - typedef D3DDEVICEDESC7 TD3dDeviceDesc; - typedef LPD3DENUMDEVICESCALLBACK7 TD3dEnumDevicesCallback; -}; - -template -struct Types; - -#define D3D_CONCAT(x, y, ...) x##y - -#define D3D_TYPES(Interface, ...) \ - template <> \ - struct Types : D3D_CONCAT(Direct3dTypes, __VA_ARGS__) \ - {} - -D3D_TYPES(IDirect3D); -D3D_TYPES(IDirect3D, 2); -D3D_TYPES(IDirect3D, 3); -D3D_TYPES(IDirect3D, 7); - -D3D_TYPES(IDirect3DDevice); -D3D_TYPES(IDirect3DDevice, 2); -D3D_TYPES(IDirect3DDevice, 3); -D3D_TYPES(IDirect3DDevice, 7); - -#undef D3D_TYPES -#undef D3D_CONCAT diff --git a/DDrawCompat/DllMain.cpp b/DDrawCompat/DllMain.cpp index 7213374..93f122d 100644 --- a/DDrawCompat/DllMain.cpp +++ b/DDrawCompat/DllMain.cpp @@ -12,6 +12,7 @@ #include "DDraw/DisplayMode.h" #include "DDraw/Hooks.h" #include "DDrawProcs.h" +#include "Direct3d/Hooks.h" #include "Gdi/Gdi.h" #include "Time.h" @@ -31,6 +32,8 @@ namespace D3dDdiHooks::installHooks(); Compat::Log() << "Installing DirectDraw hooks"; DDraw::installHooks(); + Compat::Log() << "Installing Direct3D hooks"; + Direct3d::installHooks(); Compat::Log() << "Installing GDI hooks"; Gdi::installHooks(); Compat::Log() << "Installing registry hooks";