2018/12/3의 최신 ImGui가 내부 DLL 삽입식 UI를 만들 때 CSGO가 게임에 들어가면 그림을 그리지 않습니다

3658 단어 UI 인터페이스
2018/12/3의 최신 ImGui가 내부 DLL 삽입식 UI를 만들 때 CSGO가 게임에 들어가면 그림을 그리지 않습니다. 해결 방법:
드로잉 프레임:
      	static HRESULT __stdcall hookedPresent(IDirect3DDevice9* device, 
   const RECT* src, const RECT* dest, HWND windowOverride, const   
   RGNDATA* dirtyRegion) noexcept { 	static bool isInitialised{
   false };
   if (!isInitialised) { 		ImGui::CreateContext();
      		ImGui_ImplWin32_Init(FindWindowA("Valve001", NULL));
      		ImGui_ImplDX9_Init(device);
      
      		ImGui::StyleColorsDark(); 		ImGuiStyle& style = ImGui::GetStyle();
      		style.WindowRounding = 0.0f; 		style.WindowBorderSize = 0.0f;
      		style.ChildBorderSize = 0.0f; 		ImGuiIO& io = ImGui::GetIO();
      		io.IniFilename = nullptr; 		io.LogFilename = nullptr; 		char    buffer[MAX_PATH]; 		GetWindowsDirectoryA(buffer, MAX_PATH);
      		io.Fonts->AddFontFromFileTTF(std::string{ buffer + std::string{    "\\Fonts\\Tahoma.ttf" } }.c_str(), 16.0f);
      
      		HookMessage(); 		isInitialised = true; 	} 	else if (open) { 		DWORD    d3rsColorWrite;
   		device->GetRenderState(D3DRS_COLORWRITEENABLE,   
   &d3rsColorWrite); 		IDirect3DVertexDeclaration9*
   vertexDeclaration;
      		device->GetVertexDeclaration(&vertexDeclaration);
      		IDirect3DVertexShader9* vertexShader;
      		device->GetVertexShader(&vertexShader);
      		device->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff);
      		device->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
      		device->SetSamplerState(NULL, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
      		device->SetSamplerState(NULL, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
      		device->SetSamplerState(NULL, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
      		device->SetSamplerState(NULL, D3DSAMP_SRGBTEXTURE, NULL);
      
      		ImGui_ImplDX9_NewFrame(); 		ImGui_ImplWin32_NewFrame();
      		ImGui::NewFrame();
      
      		ImGui::GetIO().MouseDrawCursor = false; 		{ 			static float f =
      0.0f; 			static int counter = 0;
      
      			ImGui::Begin("Hello, world!");                          // Create    a window called "Hello, world!" and append into it.
      
      			ImGui::Text("This is some useful text.");               // Display    some text (you can use a format strings too)
      
      			ImGui::SliderFloat("float", &f, 0.0f, 1.0f);            // Edit 1    float using a slider from 0.0f to 1.0f    
      
      			if (ImGui::Button("Button"))                            // Buttons    return true when clicked (most widgets return true
   when   edited/activated)
      				counter++; 			ImGui::SameLine(); 			ImGui::Text("counter = %d", counter);
      
      			ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",
      1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); 			ImGui::End(); 		}
      
      		ImGui::EndFrame(); 		ImGui::Render();
      		ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
      
      		device->SetRenderState(D3DRS_COLORWRITEENABLE, d3rsColorWrite);
      		device->SetRenderState(D3DRS_SRGBWRITEENABLE, true);
      		device->SetVertexDeclaration(vertexDeclaration);
      		device->SetVertexShader(vertexShader); 	} 	return    originalPresent(device, src, dest, windowOverride, dirtyRegion);
   }

마우스 메시지를 받지 않음:
VS2017 직접 소스 파일 검색, 형식:
if (::GetActiveWindow() == g_hWnd && ::GetCursorPos(&pos))

... 로 바꾸다
if (/*::GetActiveWindow() == g_hWnd &&*/ ::GetCursorPos(&pos))

오케이.내부적으로 ImGui UI를 사용할 수 있습니다.

좋은 웹페이지 즐겨찾기