| 414 | | if (i == mTextureStates.end()) |
| 415 | | mTextureStates[texName].setTexture(texName, mOptions.get(), mModulateTexEnv.get()); |
| 416 | | return mTextureStates[texName]; |
| | 415 | if (i != mTextureStates.end()) |
| | 416 | return i->second; |
| | 417 | // Try to load that texture. |
| | 418 | TextureData textureData; |
| | 419 | textureData.setTexture(texName, mOptions.get(), mModulateTexEnv.get()); |
| | 420 | if (textureData.valid()) { |
| | 421 | mTextureStates[texName] = textureData; |
| | 422 | return textureData; |
| | 423 | } |
| | 424 | // still no joy?, try with the stripped filename if this is different |
| | 425 | // Try the pure file name if it is different |
| | 426 | std::string simpleTexName = osgDB::getSimpleFileName(texName); |
| | 427 | if (simpleTexName != texName) |
| | 428 | return toTextureData(simpleTexName); |
| | 429 | |
| | 430 | // Nothing that worked, return invalid data |
| | 431 | return TextureData(); |
| 1163 | | std::string texname = readString(stream); |
| 1164 | | |
| 1165 | | // strip absolute paths |
| 1166 | | if (texname[0] == '/' || |
| 1167 | | (isalpha(texname[0]) && texname[1] == ':')) { |
| 1168 | | std::string::size_type p = texname.rfind('\\'); |
| 1169 | | if (p != std::string::npos) |
| 1170 | | texname = texname.substr(p+1, std::string::npos); |
| 1171 | | p = texname.rfind('/'); |
| 1172 | | if (p != std::string::npos) |
| 1173 | | texname = texname.substr(p+1, std::string::npos); |
| 1174 | | } |
| 1175 | | |
| 1176 | | textureData = fileData.toTextureData(texname); |
| | 1178 | textureData = fileData.toTextureData(readString(stream)); |