当前位置: 首页>>代码示例>>C++>>正文


C++ TexturePtr::getFormat方法代码示例

本文整理汇总了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;
 }
开发者ID:Chiru,项目名称:naali,代码行数:50,代码来源:OgreMaterialUtils.cpp

示例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);
        }
    }
开发者ID:Chiru,项目名称:naali,代码行数:34,代码来源:OgreMaterialUtils.cpp

示例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);
        }
    }
开发者ID:Belsepubi,项目名称:naali,代码行数:46,代码来源:OgreMaterialUtils.cpp


注:本文中的ogre::TexturePtr::getFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。