Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.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  std::string datablock_name = "datablock name: " + std::string(datablock->getName().mDebugString);
73  ImGui::Text(datablock_name.c_str());
74 
75  BlamVector4 color = BlamVector4(datablock->getColour().r, datablock->getColour().g,
76  datablock->getColour().b, datablock->getColour().a);
77 
78  if (ImGui::ColorEdit4("color", (float*)&color))
79  {
80  datablock->setColour(Ogre::ColourValue(color.x, color.y, color.z, color.w));
81  }
82  }
83  else if (hlms->getType() == Ogre::HlmsTypes::HLMS_PBS)
84  {
85  Ogre::HlmsPbsDatablock* datablock = (Ogre::HlmsPbsDatablock*)entry.datablock;
86  }
87  }
88  }
89  }
90  else
91  {
92  ImGui::Text("hlms was nullptr");
93  }
94 
95  ImGui::Unindent(10.0f);
96  }
97  }
98 
99 public:
100  void Draw()
101  {
102  if (!show)
103  {
104  return;
105  }
106 
107  if (ImGui::Begin("Ogre HLMS Debug", &show))
108  {
110 
112  {
113  if (ignored_datablocks.size() > 0)
114  {
115  std::string total_datablocks = "ignored datablocks: " + std::to_string(ignored_datablocks.size());
116  ImGui::Text(total_datablocks.c_str());
117 
118  if (ImGui::Button("clear ignore list"))
119  {
120  ignored_datablocks.clear();
121  }
122  }
123 
124  DrawHlmsGroup("pbs", ogre_graphics_system->getRoot()->getHlmsManager()->getHlms(Ogre::HlmsTypes::HLMS_PBS));
125  DrawHlmsGroup("unlit", ogre_graphics_system->getRoot()->getHlmsManager()->getHlms(Ogre::HlmsTypes::HLMS_UNLIT));
126  }
127  else
128  {
129  ImGui::Text("ogre graphics system was nullptr");
130  }
131  }
132  ImGui::End();
133  }
134 };
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:428
BlamImGuiWindow::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: imgui.h:34
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ogre_graphics_system
Demo::GraphicsSystem * ogre_graphics_system
Definition: ogre.cpp:52
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:492
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:100
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:145
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644