Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
dx8rendererdebugger.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "dx8rendererdebugger.h"
20#include "hashtemplate.h"
21#include "mesh.h"
22#include "meshmdl.h"
23
25
26bool DX8RendererDebugger::Enabled;
27
29{
30 Enabled=true;
31}
32
34{
35 if (!Enabled) {
36 s="";
37 return;
38 }
39 s="\n\n\n\n";
40
41 int cnt=0;
42
44 for (ite.First();!ite.Is_Done();ite.Next()) {
45 StringClass tmp(0,true);
46 MeshClass* mesh=ite.Peek_Value();
47 MeshModelClass* mmc=mesh->Peek_Model();
48 int polys=0;
49 int verts=0;
50 if (mmc) {
51 polys=mmc->Get_Polygon_Count();
52 verts=mmc->Get_Vertex_Count();
53 }
54 tmp.Format("id: %5.5d mesh: %s %d polys, %d verts",
55 ite.Peek_Key(),
56 mesh->Get_Name(),
57 polys,
58 verts);
59 s+=tmp;
60 if (mesh->Is_Disabled_By_Debugger()) {
61 s+=" (disabled)\n";
62 }
63 else {
64 s+="\n";
65 }
66 cnt++;
67 if (cnt>20) break;
68 }
69
70}
71
73{
74 // Release references to all meshes and empty the hash
76 for (ite.First();!ite.Is_Done();ite.Next()) {
77 ite.Peek_Value()->Release_Ref();
78 }
79 MeshHash.Remove_All();
80
81// if (!Enabled) return;
82}
83
84#ifdef WWDEBUG
86{
87 if (!Enabled) return;
88
89 // Don't insert the same mesh twice
90 if (MeshHash.Get(mesh->Get_Debug_Id())) return;
91
92 mesh->Add_Ref();
93 MeshHash.Insert(mesh->Get_Debug_Id(),mesh);
94}
95#endif
96
98{
99 if (!Enabled) return;
100 MeshClass* mesh=MeshHash.Get(id);
101 if (!mesh) return;
102 mesh->Set_Debugger_Disable(true);
103}
104
106{
107 if (!Enabled) return;
108 MeshClass* mesh=MeshHash.Get(id);
109 if (!mesh) return;
110 mesh->Set_Debugger_Disable(false);
111}
112
114{
115 if (!Enabled) return;
116
118 for (ite.First();!ite.Is_Done();ite.Next()) {
119 ite.Peek_Value()->Set_Debugger_Disable(true);
120 }
121}
122
124{
125 if (!Enabled) return;
126
128 for (ite.First();!ite.Is_Done();ite.Next()) {
129 ite.Peek_Value()->Set_Debugger_Disable(false);
130 }
131}
132
static void Get_String(StringClass &s)
static void Add_Mesh(MeshClass *mesh)
static void Enable_Mesh(unsigned id)
static void Disable_Mesh(unsigned id)
static void Enable(bool enable)
ValueType & Peek_Value()
const KeyType & Peek_Key()
virtual const char * Get_Name(void) const
Definition mesh.cpp:324
void Set_Debugger_Disable(bool b)
Definition mesh.h:164
MeshModelClass * Peek_Model(void)
Definition mesh.h:195
unsigned Get_Debug_Id() const
Definition mesh.h:162
bool Is_Disabled_By_Debugger() const
Definition mesh.h:165
int Get_Vertex_Count(void) const
int Get_Polygon_Count(void) const
void Add_Ref(void) const
Definition refcount.cpp:171
int _cdecl Format(const TCHAR *format,...)
Definition wwstring.cpp:273