Elaztek Developer Hub
Blamite Game Engine - blam!  00453.06.08.26.0624.blamite
The core library for the Blamite Game Engine.
ogre_hlms_debug.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <limits.h>
6 #include <OGRE/OgreSceneManager.h>
7 #include <OGRE/OgreRoot.h>
8 #include <OGRE/OgreHlms.h>
9 #include <OGRE/OgreHlmsManager.h>
10 #include <Strings/components/utils/list/list.h>
11 
14 
19 {
20 private:
21  std::vector<std::string> ignored_datablocks = std::vector<std::string>();
22 
29  void DrawHlmsGroup(std::string name, Ogre::Hlms* hlms)
30  {
31  if (ImGui::CollapsingHeader(name.c_str()))
32  {
33  Ogre::Hlms::HlmsDatablockMap datablocks = hlms->getDatablockMap();
34  Ogre::Hlms::HlmsDatablockMap::iterator it;
35 
36  ImGui::Indent(10.0f);
37 
38  if (hlms)
39  {
40  if (ImGui::Button("ignore all current datablocks"))
41  {
42  for (it = datablocks.begin(); it != datablocks.end(); it++)
43  {
44  Ogre::Hlms::DatablockEntry entry = it->second;
45  ignored_datablocks.push_back(entry.name);
46  }
47  }
48 
49  std::string total_datablocks = "total datablocks: " + std::to_string(hlms->getDatablockMap().size());
50  ImGui::Text(total_datablocks.c_str());
51 
52  for (it = datablocks.begin(); it != datablocks.end(); it++)
53  {
54  Ogre::Hlms::DatablockEntry entry = it->second;
55 
56  if (BlamStrings::Utils::List::Contains(ignored_datablocks, entry.name))
57  {
58  continue;
59  }
60 
61  if (ImGui::CollapsingHeader(entry.name.c_str()))
62  {
63  std::string name = "name: " + entry.name;
64  std::string visible_to_manager = "visible to manager: " + std::to_string(entry.visibleToManager);
65 
66  ImGui::Text(name.c_str());
67  ImGui::Text(visible_to_manager.c_str());
68 
69  if (hlms->getType() == Ogre::HlmsTypes::HLMS_UNLIT)
70  {
71  Ogre::HlmsUnlitDatablock* datablock = (Ogre::HlmsUnlitDatablock*)entry.datablock;
72 
73  #if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM || OGRE_IDSTRING_ALWAYS_READABLE
74  std::string datablock_name = "datablock name: " + datablock->getName().getFriendlyText()
75  + " [" + std::string(datablock->getName().mDebugString) + "]";
76  #else
77  std::string datablock_name = "datablock name: " + datablock->getName().getFriendlyText();
78  #endif
79 
80  ImGui::Text(datablock_name.c_str());
81 
82  BlamVector4 color = BlamVector4(datablock->getColour().r, datablock->getColour().g,
83  datablock->getColour().b, datablock->getColour().a);
84 
85  if (ImGui::ColorEdit4("color", (float*)&color))
86  {
87  datablock->setColour(Ogre::ColourValue(color.x, color.y, color.z, color.w));
88  }
89  }
90  else if (hlms->getType() == Ogre::HlmsTypes::HLMS_PBS)
91  {
92  Ogre::HlmsPbsDatablock* datablock = (Ogre::HlmsPbsDatablock*)entry.datablock;
93  }
94  }
95  }
96  }
97  else
98  {
99  ImGui::Text("hlms was nullptr");
100  }
101 
102  ImGui::Unindent(10.0f);
103  }
104  }
105 
106 public:
107  void Draw()
108  {
109  if (!show)
110  {
111  return;
112  }
113 
114  if (ImGui::Begin("Ogre HLMS Debug", &show))
115  {
117 
119  {
120  if (ignored_datablocks.size() > 0)
121  {
122  std::string total_datablocks = "ignored datablocks: " + std::to_string(ignored_datablocks.size());
123  ImGui::Text(total_datablocks.c_str());
124 
125  if (ImGui::Button("clear ignore list"))
126  {
127  ignored_datablocks.clear();
128  }
129  }
130 
131  DrawHlmsGroup("pbs", ogre_graphics_system->getRoot()->getHlmsManager()->getHlms(Ogre::HlmsTypes::HLMS_PBS));
132  DrawHlmsGroup("unlit", ogre_graphics_system->getRoot()->getHlmsManager()->getHlms(Ogre::HlmsTypes::HLMS_UNLIT));
133  }
134  else
135  {
136  ImGui::Text("ogre graphics system was nullptr");
137  }
138  }
139  ImGui::End();
140  }
141 };
BlamImGuiWindow_OgreHlmsDebug
Class for the Ogre HLMS Debug utility.
Definition: ogre_hlms_debug.hpp:18
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:447
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
entry
Definition: imgui.h:36
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ogre_graphics_system
Demo::GraphicsSystem * ogre_graphics_system
Definition: ogre.cpp:75
imgui_stdlib.h
rendering.h
BlamImGuiWindow
Class representing an ImGUI window.
Definition: imgui.h:31
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
ImGui::CollapsingHeader
IMGUI_API bool CollapsingHeader(const char *label, ImGuiTreeNodeFlags flags=0)
Definition: imgui_widgets.cpp:5422
ImGui::Unindent
IMGUI_API void Unindent(float indent_w=0.0f)
Definition: imgui.cpp:7178
ImGui::Text
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui_widgets.cpp:238
Blam::Rendering::GetGraphicsSystem
BLAM Demo::GraphicsSystem * GetGraphicsSystem()
Retrieves the graphics system used by OGRE.
Definition: ogre.cpp:645
Demo::GraphicsSystem
Definition: GraphicsSystem.h:27
ImGui::ColorEdit4
IMGUI_API bool ColorEdit4(const char *label, float col[4], ImGuiColorEditFlags flags=0)
Definition: imgui_widgets.cpp:4154
imgui.h
BlamImGuiWindow_OgreHlmsDebug::Draw
void Draw()
Draws the contents of the group.
Definition: ogre_hlms_debug.hpp:107
ImGui::Indent
IMGUI_API void Indent(float indent_w=0.0f)
Definition: imgui.cpp:7170
Demo::GraphicsSystem::getRoot
Ogre::Root * getRoot(void) const
Definition: GraphicsSystem.h:147
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644