I tried to create my own d3d menu for game using directX9 and that’s my endscene hook
HRESULT APIENTRY hooks::hkEndScene(IDirect3DDevice9* pDevice) {
if (pDevice == NULL)
return oEndScene(pDevice);
if (!setupUI) {
D3DDEVICE_CREATION_PARAMETERS pParameters;
pDevice->GetCreationParameters(&pParameters);
Process.TargetHwnd = pParameters.hFocusWindow;
newpDevice = pDevice;
if (Process.TargetHwnd != NULL) {
Process.TargetWndProc = (WNDPROC)SetWindowLongPtr(Process.TargetHwnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
ImGui_ImplWin32_Init(Process.TargetHwnd);
ImGui_ImplDX9_Init(pDevice);
ImGui::GetIO().ImeWindowHandle = Process.TargetHwnd;
ImGui::GetIO().IniFilename = NULL;
ImGui::GetIO().LogFilename = NULL;
setupUI = true;
}
}
if (newpDevice != pDevice)
{
newpDevice = pDevice;
checknewDevice = true;
}
if (checknewDevice)
{
ImGui_ImplDX9_Init(pDevice);
checknewDevice = false;
}
if (open && !checknewDevice)
{
Render();
}
return oEndScene(pDevice);
}
After reset device when trying to initializing imgui again here
ImGui_ImplDX9_Init(pDevice);
Game crash and exit can anyone tell me why ?
also is there anything missed ?
Also that’s the reset code
HRESULT APIENTRY hooks::hkReset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters) {
if (pDevice == NULL)
return oReset(pDevice, pPresentationParameters);
ImGui_ImplDX9_InvalidateDeviceObjects();
auto ResetReturn = oReset(pDevice, pPresentationParameters);
ImGui_ImplDX9_CreateDeviceObjects();
return ResetReturn;
}
I tried to initialize the imgui resources again after reset device but game crash and exit .
New contributor
Xerin Fuscator is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.