void OgreTexture::loadFromFile(const std::string& _filename) { setUsage(TextureUsage::Default); Ogre::TextureManager* manager = Ogre::TextureManager::getSingletonPtr(); if ( !manager->resourceExists(_filename) ) { DataManager& resourcer = DataManager::getInstance(); if (!resourcer.isDataExist(_filename)) { MYGUI_PLATFORM_LOG(Error, "Texture '" + _filename + "' not found, set default texture"); } else { mTexture = manager->load(_filename, mGroup, Ogre::TEX_TYPE_2D, 0); } } else { #if (OGRE_VERSION < MYGUI_DEFINE_VERSION(1, 9, 0)) mTexture = manager->getByName(_filename); #else mTexture = manager->getByName(_filename).staticCast<Ogre::Texture>(); #endif } setFormatByOgreTexture(); }
void GUIManager::runCommand(const std::string &command, const std::string &args) { if (command == ToggleInputMode.getCommand()) { getInput().toggleInputMode(); } else if (command == ToggleGui.getCommand()) { S_LOG_VERBOSE("Toggle Gui Initiated -- " << getInput().getInputMode()); if (mEnabled) { S_LOG_INFO("Disabling GUI"); mEnabled = false; getInput().removeAdapter(mCEGUIAdapter); } else { S_LOG_INFO("Enabling GUI"); mEnabled = true; getInput().addAdapter(mCEGUIAdapter); } } else if (command == ReloadGui.getCommand()) { Ogre::TextureManager* texMgr = Ogre::TextureManager::getSingletonPtr(); Ogre::ResourcePtr resource = texMgr->getByName("cegui/" + getDefaultScheme() + ".png"); if (!resource.isNull()) { resource->reload(); } } }
bool RocketInterface::LoadTexture(Rocket::Core::TextureHandle& textureHandle, Rocket::Core::Vector2i& textureDimensions, const Rocket::Core::String& source) { Ogre::TextureManager* tm = Ogre::TextureManager::getSingletonPtr(); Ogre::TexturePtr texture = tm->getByName(Ogre::String(source.CString())); if (texture.isNull()) { texture = tm->load( Ogre::String(source.CString()), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 0, 1.0f, false, Ogre::PF_UNKNOWN, true); } if (texture.isNull()) return false; textureDimensions.x = texture->getWidth(); textureDimensions.y = texture->getHeight(); textureHandle = reinterpret_cast<Rocket::Core::TextureHandle>(new RocketOgreTexture(texture)); return true; }