40 ImGui::SetNextWindowPosCenter(ImGuiCond_FirstUseEver);
41 ImGui::SetNextWindowSize(ImVec2(
WINDOW_WIDTH, 550.f), ImGuiCond_FirstUseEver);
42 if (!ImGui::Begin(
_LC(
"TextureToolWindow",
"Texture Tool"), &
m_is_visible))
54 auto itor = Ogre::TextureManager::getSingleton().getResourceIterator();
55 while (itor.hasMoreElements())
57 Ogre::TexturePtr tex = Ogre::static_pointer_cast<Ogre::Texture>(itor.getNext());
64 if (ImGui::Selectable(tex->getName().c_str(), &selected))
82 float max_width = ImGui::GetWindowSize().x -
83 (
LEFT_PANE_WIDTH + ImGui::GetStyle().ItemSpacing.x + 2*ImGui::GetStyle().WindowPadding.x);
84 float max_height = ImGui::GetWindowSize().y * 0.5;
86 size *= max_width / size.x;
87 if (size.y > max_height)
89 size *= max_height / size.y;
91 ImGui::Image(
reinterpret_cast<ImTextureID
>(
m_display_tex->getHandle()), size);
94 ImGui::BeginChild(
"tex info", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()));
98 ImGui::Text(
"Format: %s", Ogre::PixelUtil::getFormatName(
m_display_tex->getFormat()).c_str());
100 ImGui::Text(
"Num. faces: %d",
static_cast<int>(
m_display_tex->getNumFaces()));
104 ImGui::Text(
"Num. mipmaps: %u",
m_display_tex->getNumMipmaps());
106 static const char* tex_type_names[] =
107 {
"~invalid~",
"1D",
"2D",
"3D",
"Cubemap",
"2D array",
"2D rect",
"External OES" };
108 ImGui::Text(
"Type: %s", tex_type_names[
m_display_tex->getTextureType()]);
110 std::string usageStr =
"";
112 usageStr +=
"static,\n";
114 usageStr +=
"dynamic,\n";
116 usageStr +=
"write only,\n";
118 usageStr +=
"static write only,\n";
120 usageStr +=
"dynamic write only,\n";
121 if (
m_display_tex->getUsage() & Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE)
122 usageStr +=
"dynamic write only discardable,\n";
124 usageStr +=
"automipmap,\n";
126 usageStr +=
"rendertarget,\n";
128 usageStr +=
"default\n";
129 ImGui::TextWrapped(
"Usage: %s", usageStr.c_str());
134 ImGui::BeginChild(
"buttons");
135 if (ImGui::Button(
_LC(
"TextureToolWindow",
"Save as PNG")))
140 if (ImGui::Button(
_LC(
"TextureToolWindow",
"Save Raw")))
149 m_is_hovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows);
157 using namespace Ogre;
160 TexturePtr tex = TextureManager::getSingleton().getByName(texName);
165 tex->convertToImage(img);
174 std::string msg =
_LC(
"TextureToolWindow",
"saved texture as ") + outname;
179 std::string str =
"Exception while saving image: " + e.getFullDescription();