Пример #1
0
    DiTexturePtr DiShaderParameter::WriteTexture2D( const DiString& name, 
        const DiString& textureName )
    {
        DiString texfile = textureName;
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        if(texfile.CheckFileExtension("dds"))
            texfile = texfile.ExtractBaseName() + ".pvr";
#endif
        
        //DI_LOG("Writing 2d texture name: %s, %s [%x]", name.c_str(), textureName.c_str(),this);
        
        DiAssetManager& assetMgr = DiAssetManager::GetInstance();
        DiTexturePtr textureAsset = assetMgr.GetAsset<DiTexture>(texfile);

        if (!textureAsset)
        {
            textureAsset = DiTexture::GetDefaultTexture();
            DI_WARNING("Cannot write the texture(%s), using default texture", texfile.c_str());
        }

        auto it = mShaderParams[VARIABLE_SAMPLER2D].find(name);
        if (it != mShaderParams[VARIABLE_SAMPLER2D].end())
        {
            DiTexture* tex = textureAsset.get();
            DiAny an(tex);
            it->second = an;
        }
        return textureAsset;
    }
Пример #2
0
    DiTexturePtr DiShaderParameter::WriteTextureCUBE( const DiString& name, 
        const DiString& textureName )
    {
        DiString texfile = textureName;
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        if(texfile.CheckFileExtension("dds"))
            texfile = texfile.ExtractBaseName() + ".pvr";
#endif
        
        DiAssetManager& assetMgr = DiAssetManager::GetInstance();
        DiTexturePtr textureAsset = assetMgr.GetAsset<DiTexture>(texfile);

        if (!textureAsset)
        {
            DI_WARNING("Failed to load the textureCUBE resource : %s",texfile.c_str());
            return DiTexturePtr();
        }

        auto it = mShaderParams[VARIABLE_SAMPLERCUBE].find(name);
        if (it != mShaderParams[VARIABLE_SAMPLERCUBE].end())
        {
            DiTexture* tex = textureAsset.get();
            DiAny an(tex);
            it->second = an;
        }
        return textureAsset;
    }