mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-14 10:50:13 +01:00
Fix overlay not working in barotrauma.
This commit is contained in:
parent
624455705f
commit
245d379720
1 changed files with 41 additions and 5 deletions
|
@ -50,7 +50,11 @@ void DX11_Hook::resetRenderState()
|
|||
{
|
||||
if (initialized)
|
||||
{
|
||||
if (mainRenderTargetView) {
|
||||
mainRenderTargetView->Release();
|
||||
mainRenderTargetView = NULL;
|
||||
}
|
||||
|
||||
pContext->Release();
|
||||
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
|
@ -78,9 +82,34 @@ void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
|||
io.IniFilename = NULL;
|
||||
|
||||
ID3D11Texture2D* pBackBuffer;
|
||||
|
||||
pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||
|
||||
ID3D11RenderTargetView *get_targets[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = {};
|
||||
pContext->OMGetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, get_targets, NULL);
|
||||
bool bind_target = true;
|
||||
|
||||
for (unsigned i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) {
|
||||
if (get_targets[i]) {
|
||||
ID3D11Resource *res = NULL;
|
||||
get_targets[i]->GetResource(&res);
|
||||
if (res) {
|
||||
if (res == (ID3D11Resource*)pBackBuffer) {
|
||||
bind_target = false;
|
||||
}
|
||||
|
||||
res->Release();
|
||||
}
|
||||
|
||||
get_targets[i]->Release();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bind_target) {
|
||||
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
|
||||
}
|
||||
|
||||
pBackBuffer->Release();
|
||||
|
||||
ImGui_ImplDX11_Init(pDevice, pContext);
|
||||
|
@ -102,7 +131,10 @@ void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
|||
|
||||
ImGui::Render();
|
||||
|
||||
if (mainRenderTargetView) {
|
||||
pContext->OMSetRenderTargets(1, &mainRenderTargetView, NULL);
|
||||
}
|
||||
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +176,11 @@ DX11_Hook::~DX11_Hook()
|
|||
|
||||
if (initialized)
|
||||
{
|
||||
if (mainRenderTargetView) {
|
||||
mainRenderTargetView->Release();
|
||||
mainRenderTargetView = NULL;
|
||||
}
|
||||
|
||||
pContext->Release();
|
||||
|
||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
|
|
Loading…
Reference in a new issue