Set default state sensibly

pull/3053/head
AnyOldName3 4 years ago
parent ce2bcba5d4
commit a080071588

@ -32,6 +32,8 @@
#include <components/resource/imagemanager.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/resource/keyframemanager.hpp>
#include <components/shader/removedalphafunc.hpp>
#include <components/shader/shadermanager.hpp>
#include <components/settings/settings.hpp>
@ -376,6 +378,9 @@ namespace MWRender
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("far", mViewDistance));
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("simpleWater", false));
// Hopefully, anything genuinely requiring the default alpha func of GL_ALWAYS explicitly sets it
mRootNode->getOrCreateStateSet()->setAttribute(Shader::RemovedAlphaFunc::getInstance(GL_GREATER));
mUniformNear = mRootNode->getOrCreateStateSet()->getUniform("near");
mUniformFar = mRootNode->getOrCreateStateSet()->getUniform("far");
updateProjectionMatrix();

@ -17,11 +17,4 @@ namespace Shader
sInstances[func - GL_NEVER] = new RemovedAlphaFunc(static_cast<osg::AlphaFunc::ComparisonFunction>(func), 1.0);
return sInstances[func - GL_NEVER];
}
void RemovedAlphaFunc::apply(osg::State & state) const
{
// Hopefully, anything genuinely requiring the default alpha func of GL_ALWAYS explicitly sets it
if (!state.getGlobalDefaultAttribute(ALPHAFUNC)->getType() != getType())
state.setGlobalDefaultAttribute(static_cast<const osg::StateAttribute*>(cloneType()));
}
}

@ -29,7 +29,7 @@ namespace Shader
META_StateAttribute(Shader, RemovedAlphaFunc, ALPHAFUNC);
void apply(osg::State& state) const override;
void apply(osg::State& state) const override {}
protected:
virtual ~RemovedAlphaFunc() = default;

Loading…
Cancel
Save