Skip to content

Commit

Permalink
Main: ScriptTranslator - report if texture is re-declared with differ…
Browse files Browse the repository at this point in the history
…ent settings
  • Loading branch information
paroj committed Mar 26, 2024
1 parent 3e3c10e commit 20032a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
14 changes: 13 additions & 1 deletion OgreMain/src/OgreScriptTranslator.cpp
Expand Up @@ -2606,7 +2606,7 @@ namespace Ogre{
bool isAlpha = false;
bool sRGBRead = false;
PixelFormat format = PF_UNKNOWN;
int mipmaps = MIP_DEFAULT;
int mipmaps = TextureManager::getSingleton().getDefaultNumMipmaps(); // MIP_DEFAULT

++j;
while(j != prop->values.end())
Expand Down Expand Up @@ -2669,6 +2669,18 @@ namespace Ogre{
prop->line, "alpha. Use PF_A8 instead");
}

if(const auto& tex = TextureManager::getSingleton().getByName(evt.mName, mUnit->getParent()->getResourceGroup()))
{
// the texture is shared with another texture unit, report any discrepancies
if (tex->getDesiredFormat() != format || tex->getNumMipmaps() != uint(mipmaps) ||
tex->isHardwareGammaEnabled() != sRGBRead || tex->getTextureType() != texType)
{
compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
"overriding previous declarations of texture '" + evt.mName +
"' with different parameters");
}
}

mUnit->setTextureName(evt.mName, texType);
mUnit->setDesiredFormat(format);
OGRE_IGNORE_DEPRECATED_BEGIN
Expand Down
14 changes: 0 additions & 14 deletions Samples/Media/materials/scripts/Examples.material
Expand Up @@ -596,20 +596,6 @@ material Examples/Rocky
}
}
}
material Examples/10PointBlock
{
technique
{
pass
{

texture_unit
{
texture 10points.png
}
}
}
}
material Material__25
{
technique
Expand Down

0 comments on commit 20032a5

Please sign in to comment.