1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 23:53:52 +00:00

Set default state sensibly

This commit is contained in:
AnyOldName3 2020-12-18 00:02:51 +00:00
parent ce2bcba5d4
commit a080071588
3 changed files with 6 additions and 8 deletions

View file

@ -32,6 +32,8 @@
#include <components/resource/imagemanager.hpp> #include <components/resource/imagemanager.hpp>
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
#include <components/resource/keyframemanager.hpp> #include <components/resource/keyframemanager.hpp>
#include <components/shader/removedalphafunc.hpp>
#include <components/shader/shadermanager.hpp> #include <components/shader/shadermanager.hpp>
#include <components/settings/settings.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("far", mViewDistance));
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("simpleWater", false)); 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"); mUniformNear = mRootNode->getOrCreateStateSet()->getUniform("near");
mUniformFar = mRootNode->getOrCreateStateSet()->getUniform("far"); mUniformFar = mRootNode->getOrCreateStateSet()->getUniform("far");
updateProjectionMatrix(); updateProjectionMatrix();

View file

@ -17,11 +17,4 @@ namespace Shader
sInstances[func - GL_NEVER] = new RemovedAlphaFunc(static_cast<osg::AlphaFunc::ComparisonFunction>(func), 1.0); sInstances[func - GL_NEVER] = new RemovedAlphaFunc(static_cast<osg::AlphaFunc::ComparisonFunction>(func), 1.0);
return sInstances[func - GL_NEVER]; 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()));
}
} }

View file

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