---------------------------------------------------------------------
| 72 | } |
| 73 | //--------------------------------------------------------------------- |
| 74 | void ShadowTextureManager::getShadowTextures(ShadowTextureConfigList& configList, |
| 75 | ShadowTextureList& listToPopulate) |
| 76 | { |
| 77 | listToPopulate.clear(); |
| 78 | |
| 79 | std::set<Texture*> usedTextures; |
| 80 | |
| 81 | for (ShadowTextureConfig& config : configList) |
| 82 | { |
| 83 | bool found = false; |
| 84 | for (auto & tex : mTextureList) |
| 85 | { |
| 86 | // Skip if already used this one |
| 87 | if (usedTextures.find(tex.get()) != usedTextures.end()) |
| 88 | continue; |
| 89 | |
| 90 | if (config.width == tex->getWidth() && config.height == tex->getHeight() && |
| 91 | config.depth == tex->getDepth() && config.type == tex->getTextureType() && |
| 92 | config.format == tex->getFormat() && config.fsaa == tex->getFSAA()) |
| 93 | { |
| 94 | // Ok, a match |
| 95 | listToPopulate.push_back(tex); |
| 96 | usedTextures.insert(tex.get()); |
| 97 | found = true; |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | if (!found) |
| 102 | { |
| 103 | // Create a new texture |
| 104 | String targName = StringUtil::format("Ogre/ShadowTexture%zu", mCount++); |
| 105 | TexturePtr shadowTex = TextureManager::getSingleton().createManual( |
| 106 | targName, RGN_INTERNAL, config.type, config.width, config.height, config.depth, 0, config.format, |
| 107 | TU_RENDERTARGET | config.extraFlags, NULL, false, config.fsaa); |
| 108 | OgreAssert(shadowTex, "Unsupported shadow texture configuration"); |
| 109 | // Ensure texture loaded |
| 110 | shadowTex->load(); |
| 111 | |
| 112 | // update with actual format, if the requested format is not supported |
| 113 | config.format = shadowTex->getFormat(); |
| 114 | listToPopulate.push_back(shadowTex); |
| 115 | usedTextures.insert(shadowTex.get()); |
| 116 | mTextureList.push_back(shadowTex); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | } |
| 121 | //--------------------------------------------------------------------- |
| 122 | TexturePtr ShadowTextureManager::getNoShadowTexture(PixelFormat format) |
| 123 | { |
no test coverage detected