Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImGui_ImplDX9_Init crashes #1683

Closed
ghost opened this issue Mar 18, 2018 · 3 comments
Closed

ImGui_ImplDX9_Init crashes #1683

ghost opened this issue Mar 18, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 18, 2018

https://imgur.com/LMcAOPL.png
https://imgur.com/TZ8NFlF.png
Codes:

HRESULT __stdcall Hooks::EndScene(IDirect3DDevice9* pDevice)
{
 
	if (!g_Hooks.bInitializedDrawManager)
	{
		Utils::Log("Initializing Draw manager");
		g_Render.InitDeviceObjects(pDevice);
		ImGui_ImplDX9_Init(g_Hooks.hCSGOWindow, pDevice);
		g_Hooks.bInitializedDrawManager = true;
		Utils::Log("Draw manager initialized");
	}
	else
	{
		g_Hooks.MouseEnableExecute(); // Handles in-game cursor
		ImGui::GetIO().MouseDrawCursor = g_Settings.bMenuOpened;
 
		DWORD dwOld_D3DRS_COLORWRITEENABLE;
		pDevice->GetRenderState(D3DRS_COLORWRITEENABLE, &dwOld_D3DRS_COLORWRITEENABLE);
		pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff);
		ImGui_ImplDX9_NewFrame();
 
		//std::string szWatermark = "Antario";
		//g_Render.String(8, 8, CD3DFONT_DROPSHADOW, Color(250, 150, 200, 180), g_Fonts.pFontTahoma8.get(),
		  //              szWatermark.c_str());
 
		if (g_Settings.bMenuOpened)
		{
			ImGui::Begin("hello");
			{
				ImGui::Text("Hello ImGAY");
			}
			ImGui::End();
			//g_Hooks.nMenu.Render();             // Render our menu
			//g_Hooks.nMenu.mouseCursor->Render();// Render mouse cursor in the end so its not overlapped
		}
 
		// Put your draw calls here
		g_ESP.Render();
		ImGui::Render();
		pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, dwOld_D3DRS_COLORWRITEENABLE);
	}
 
 
	static auto oEndScene = g_Hooks.pD3DDevice9Hook->GetOriginal<Endscene_t>(vtable_indexes::endscene);
	return oEndScene(pDevice);
}
HRESULT __stdcall Hooks::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
    static auto oReset = g_Hooks.pD3DDevice9Hook->GetOriginal<Reset_t>(vtable_indexes::reset);
 
    if (g_Hooks.bInitializedDrawManager)
    {
        Utils::Log("Reseting draw manager.");
 
        g_Render.InvalidateDeviceObjects();
		ImGui_ImplDX9_InvalidateDeviceObjects();
 
        HRESULT hr = oReset(pDevice, pPresentationParameters);
 
        g_Render.RestoreDeviceObjects(pDevice);
		ImGui_ImplDX9_CreateDeviceObjects();
 
        Utils::Log("DrawManager reset succeded.");
        return hr;
    }
 
 
    return oReset(pDevice, pPresentationParameters);
}

Any ideas?

@SlidyBat
Copy link

Like the error tells you, you haven't called ImGui::CreateContext() or ImGui::SetCurrentContext()
You need to create a new context when initializing and destroy that context when finishing up.

@ghost
Copy link
Author

ghost commented Mar 18, 2018

Yeah It's not crashing now.
Thanks

@ghost ghost closed this as completed Mar 18, 2018
@ocornut
Copy link
Owner

ocornut commented Mar 18, 2018

Sorry but #1586

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants