apply same logic to render targets, remove UB

This commit is contained in:
Cody Glassman 2023-11-10 21:22:11 -08:00
parent dec120f38c
commit 85fcfbafda
8 changed files with 76 additions and 30 deletions

View file

@ -313,6 +313,8 @@ namespace fx
rt.mTarget->setSourceFormat(parseSourceFormat());
else if (key == "mipmaps")
rt.mMipMap = parseBool();
else if (key == "clear_color")
rt.mClearColor = parseVec<osg::Vec4f, Lexer::Vec4>();
else
error(Misc::StringUtils::format("unexpected key '%s'", std::string(key)));
@ -798,9 +800,6 @@ namespace fx
if (!pass)
pass = std::make_shared<fx::Pass>();
bool clear = true;
osg::Vec4f clearColor = { 1, 1, 1, 1 };
while (!isNext<Lexer::Eof>())
{
expect<Lexer::Literal>("invalid key in block header");
@ -844,10 +843,6 @@ namespace fx
if (blendEq != osg::BlendEquation::FUNC_ADD)
pass->mBlendEq = blendEq;
}
else if (key == "clear")
clear = parseBool();
else if (key == "clear_color")
clearColor = parseVec<osg::Vec4f, Lexer::Vec4>();
else
error(Misc::StringUtils::format("unrecognized key '%s' in block header", std::string(key)));
@ -865,9 +860,6 @@ namespace fx
return;
}
if (clear)
pass->mClearColor = clearColor;
error("malformed block header");
}