44#include " Render.h"
55#include " util/Hooking.h"
66
7+ #include " cdc/render/PCDeviceManager.h"
8+ #include " cdc/render/PCStateManager.h"
9+
10+ #ifndef TR8
711static bool s_terrainWireframe = false ;
812
913// Code for terrain wireframe
@@ -27,21 +31,52 @@ static TerrainDrawable* __fastcall TerrainDrawable_TerrainDrawable(TerrainDrawab
2731
2832 return ret;
2933}
34+ #else
35+ static bool s_wireframe = false ;
36+
37+ static void (__thiscall* s_PCScene_Draw)(int , int , int );
38+
39+ static void __fastcall PCScene_Draw (int a1, void *, int a2, int a3)
40+ {
41+ auto device = cdc::PCDeviceManager::GetInstance ();
42+ auto state = *(cdc::PCStateManager**)((char *)device + 644 ); // TODO
43+
44+ if (s_wireframe)
45+ {
46+ state->SetRenderState (D3DRS_FILLMODE , D3DFILL_WIREFRAME );
47+ }
48+
49+ s_PCScene_Draw (a1, a2, a3);
50+
51+ // Reset
52+ if (s_wireframe)
53+ {
54+ state->SetRenderState (D3DRS_FILLMODE , D3DFILL_SOLID );
55+ }
56+ }
57+ #endif
3058
3159Render::Render ()
3260{
61+ #ifndef TR8
3362 // Insert terrain wireframe hook
3463 MH_CreateHook ((void *)GET_ADDRESS (0x40ACF0 , 0x40B9B0 , 0x000000 ), TerrainDrawable_TerrainDrawable, (void **)&s_TerrainDrawable_TerrainDrawable);
64+ #else
65+ MH_CreateHook ((void *)0x5150E0 , PCScene_Draw, (void **)&s_PCScene_Draw);
66+ #endif
3567 MH_EnableHook (MH_ALL_HOOKS );
3668}
3769
3870void Render::OnMenu ()
3971{
4072 if (ImGui::BeginMenu (" Render" ))
4173 {
42- // TODO Wireframe for Underworld
74+ # ifndef TR8
4375 ImGui::MenuItem (" Wireframe" , nullptr , (bool *)GET_ADDRESS (0x1075BD4 , 0x7C7CD4 , 0x000000 ));
4476 ImGui::MenuItem (" Terrain wireframe" , nullptr , &s_terrainWireframe);
77+ #else
78+ ImGui::MenuItem (" Wireframe" , nullptr , &s_wireframe);
79+ #endif
4580
4681 ImGui::EndMenu ();
4782 }
0 commit comments