diff --git a/DDrawCompat/DDraw/DirectDrawClipper.cpp b/DDrawCompat/DDraw/DirectDrawClipper.cpp new file mode 100644 index 0000000..d0c7daf --- /dev/null +++ b/DDrawCompat/DDraw/DirectDrawClipper.cpp @@ -0,0 +1,8 @@ +#include "DDraw/DirectDrawClipper.h" + +namespace DDraw +{ + void DirectDrawClipper::setCompatVtable(IDirectDrawClipperVtbl& /*vtable*/) + { + } +} diff --git a/DDrawCompat/DDraw/DirectDrawClipper.h b/DDrawCompat/DDraw/DirectDrawClipper.h new file mode 100644 index 0000000..63ac12e --- /dev/null +++ b/DDrawCompat/DDraw/DirectDrawClipper.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Common/CompatVtable.h" +#include "DDraw/Visitors/DirectDrawClipperVtblVisitor.h" + +namespace DDraw +{ + class DirectDrawClipper : public CompatVtable + { + public: + static void setCompatVtable(IDirectDrawClipperVtbl& vtable); + }; +} + +SET_COMPAT_VTABLE(IDirectDrawClipperVtbl, DDraw::DirectDrawClipper); diff --git a/DDrawCompat/DDraw/Hooks.cpp b/DDrawCompat/DDraw/Hooks.cpp index 1a77c60..a9a4515 100644 --- a/DDrawCompat/DDraw/Hooks.cpp +++ b/DDrawCompat/DDraw/Hooks.cpp @@ -7,8 +7,9 @@ #include "Common/Log.h" #include "DDraw/ActivateAppHandler.h" #include "DDraw/DirectDraw.h" -#include "DDraw/DirectDrawSurface.h" +#include "DDraw/DirectDrawClipper.h" #include "DDraw/DirectDrawPalette.h" +#include "DDraw/DirectDrawSurface.h" #include "DDraw/Hooks.h" #include "DDraw/RealPrimarySurface.h" #include "DDraw/Repository.h" @@ -31,6 +32,20 @@ namespace dd7.detach(); } + void hookDirectDrawClipper(CompatRef dd) + { + CompatPtr clipper; + HRESULT result = dd->CreateClipper(&dd, 0, &clipper.getRef(), nullptr); + if (SUCCEEDED(result)) + { + DDraw::DirectDrawClipper::hookVtable(clipper.get()->lpVtbl); + } + else + { + Compat::Log() << "Failed to create a DirectDraw clipper for hooking: " << result; + } + } + void hookDirectDrawPalette(CompatRef dd) { PALETTEENTRY paletteEntries[2] = {}; @@ -112,8 +127,9 @@ namespace DDraw } hookDirectDraw(*dd7); - hookDirectDrawSurface(*dd7); + hookDirectDrawClipper(*dd7); hookDirectDrawPalette(*dd7); + hookDirectDrawSurface(*dd7); } void uninstallHooks() diff --git a/DDrawCompat/DDraw/Visitors/DirectDrawClipperVtblVisitor.h b/DDrawCompat/DDraw/Visitors/DirectDrawClipperVtblVisitor.h new file mode 100644 index 0000000..a4a8646 --- /dev/null +++ b/DDrawCompat/DDraw/Visitors/DirectDrawClipperVtblVisitor.h @@ -0,0 +1,20 @@ +#pragma once + +#include "Common/VtableVisitor.h" + +template <> +struct VtableForEach +{ + template + static void forEach(Visitor& visitor) + { + VtableForEach::forEach(visitor); + + DD_VISIT(GetClipList); + DD_VISIT(GetHWnd); + DD_VISIT(Initialize); + DD_VISIT(IsClipListChanged); + DD_VISIT(SetClipList); + DD_VISIT(SetHWnd); + } +}; diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index a0bedc2..ba16c3c 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -182,6 +182,7 @@ + @@ -196,6 +197,7 @@ + @@ -245,6 +247,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 64b7765..0923468 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -300,6 +300,12 @@ Header Files\D3dDdi + + Header Files\DDraw\Visitors + + + Header Files\DDraw + @@ -458,6 +464,9 @@ Source Files\D3dDdi + + Source Files\DDraw +