本文整理汇总了C++中ogre::TexturePtr::getFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::getFormat方法的具体用法?C++ TexturePtr::getFormat怎么用?C++ TexturePtr::getFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::getFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOrCreateLegacyMaterial
Ogre::MaterialPtr GetOrCreateLegacyMaterial(const std::string& texture_name, uint variation)
{
if (variation >= MAX_MATERIAL_VARIATIONS)
{
OgreRenderingModule::LogWarning("Requested suffix for non-existing material variation " + ToString<uint>(variation));
variation = 0;
}
const std::string& suffix = MaterialSuffix[variation];
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
std::string material_name = texture_name + suffix;
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
{
material = mm.create(material_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(material.get());
}
else
return material;
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
{
// As far as the legacy materials are concerned, DXT1 is not alpha
if (tex->getFormat() == Ogre::PF_DXT1)
has_alpha = false;
else if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
}
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(BaseMaterials[variation]);
else
base_material = mm.getByName(AlphaBaseMaterials[variation]);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[variation] + " base material for " + texture_name);
return Ogre::MaterialPtr();
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
return material;
}
示例2: UpdateLegacyMaterials
void UpdateLegacyMaterials(const std::string& texture_name)
{
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
for (uint i = 0; i < MAX_MATERIAL_VARIATIONS; ++i)
{
std::string material_name = texture_name + MaterialSuffix[i];
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
continue;
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(BaseMaterials[i]);
else
base_material = mm.getByName(AlphaBaseMaterials[i]);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[i] + " base material for " + texture_name);
continue;
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
}
}
示例3: CreateLegacyMaterials
void CreateLegacyMaterials(const std::string& texture_name, bool update)
{
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
{
if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
}
// Early out: if texture does not yet exist and materials have already been created once
if (((tex.isNull()) || (!update)) && (!mm.getByName(texture_name).isNull()))
return;
for (uint i = 0; i < MAX_MATERIAL_VARIATIONS; ++i)
{
const std::string& base_material_name = BaseMaterials[i];
const std::string& alpha_base_material_name = AlphaBaseMaterials[i];
std::string material_name = texture_name + MaterialSuffix[i];
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
{
material = mm.create(material_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(material.get());
}
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(base_material_name);
else
base_material = mm.getByName(alpha_base_material_name);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[i] + " base material for " + texture_name);
return;
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
}
}