#include "precompiled.h" #include #include #include "TextureManager.h" #include "TextureEntry.h" #include "res/res.h" #include "res/ogl_tex.h" #include "ogl.h" #include "timer.h" #include "CLogger.h" #include "Xeromyces.h" #include "XeroXMB.h" #define LOG_CATEGORY "graphics" using namespace std; CTextureManager::CTextureManager(): m_LastGroupIndex(0) {} CTextureManager::~CTextureManager() { for (size_t i=0;isecond; ++it; } } CTextureEntry* CTextureManager::FindTexture(CStr tag) { for (uint i=0;iGetTag() == tag) return m_TextureEntries[i]; } return 0; } CTextureEntry* CTextureManager::FindTexture(Handle handle) { for (uint i=0;iIsLoaded() && handle==m_TextureEntries[i]->GetHandle()) { return m_TextureEntries[i]; } } return 0; } void CTextureManager::LoadTerrainsFromXML(const char *filename) { CXeromyces XeroFile; if (XeroFile.Load(filename) != PSRETURN_OK) return; XMBElement root = XeroFile.getRoot(); CStr rootName = XeroFile.getElementString(root.getNodeName()); // Check that we've got the right kind of xml document if (rootName != "terrains") { LOG(ERROR, LOG_CATEGORY, "TextureManager: Loading %s: Root node is not terrains (found \"%s\")", filename, rootName.c_str()); return; } #define ELMT(x) int el_##x = XeroFile.getElementID(#x) #define ATTR(x) int at_##x = XeroFile.getAttributeID(#x) ELMT(terrain); #undef ELMT #undef ATTR // Load terrains // Iterate main children // they should all be or