Esempio n. 1
0
	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
		{
			mTexture = manager->getByName(_filename);
		}

		setFormatByOgreTexture();
	}
Esempio n. 2
0
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;
}