RussellJerome / UnrealModLoader

GNU Lesser General Public License v2.1
209 stars 66 forks source link

Allow mods to use existing DX11-Present hook #14

Closed TheNewJavaman closed 2 years ago

TheNewJavaman commented 2 years ago

TLDR: Adds a mod event that is called whenever a frame will be presented via DX11

I'm in the process of writing a VR mod for Ghostrunner using UnrealModLoader, and I needed to hook into DX11. I was implementing my own DX11 hooks, but then I found yours in LoaderUI. This PR allows any mod to use the existing DX11 resources, which removes any mod DX11 initialization like creating a Device/SwapChain/Context and hooking into Present.

This change works by adding an event dispatcher at the existing DX11 Present detour, which then calls any mods that have registered with that event, passing the Device/Context/RenderTargetView.

I'm currently using these changes in a custom build of UML and have tested them by doing basic operations on the resources (creating more RenderTargetViews for VR, for example).

RussellJerome commented 2 years ago

Epic Gamer Moment, thanks lad