X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2FEffect.cxx;h=c934815760ced8359c0c3678fde2e9b865544deb;hb=430e72b42404cd07685de13c767a9ca443ad1f49;hp=3cd6a93b7a6166701c442edb2852d21e1ab3fd02;hpb=d393e4a0193269d0a22198538e16d7d1cb750ec0;p=simgear.git diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 3cd6a93b..c9348157 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -74,7 +74,7 @@ #include #include #include - +#include namespace simgear @@ -671,9 +671,9 @@ InstallAttributeBuilder installAlphaTest("alpha-test"); InstallAttributeBuilder textureUnitBuilder("texture-unit"); // Shader key, used both for shaders with relative and absolute names -typedef pair ShaderKey; +typedef pair ShaderKey; -inline ShaderKey makeShaderKey(SGPropertyNode_ptr& ptr, Shader::Type shaderType) +inline ShaderKey makeShaderKey(SGPropertyNode_ptr& ptr, int shaderType) { return ShaderKey(ptr->getStringValue(), shaderType); } @@ -815,7 +815,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass, BOOST_FOREACH(const ShaderKey& shaderKey, prgKey.shaders) { const string& shaderName = shaderKey.first; - Shader::Type stype = shaderKey.second; + Shader::Type stype = (Shader::Type)shaderKey.second; string fileName = SGModelLib::findDataFile(shaderName, options); if (fileName.empty()) throw BuilderException(string("couldn't find shader ") + @@ -833,12 +833,13 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass, BOOST_FOREACH(const ShaderKey& skey, resolvedKey.shaders) { const string& fileName = skey.first; - Shader::Type stype = skey.second; + Shader::Type stype = (Shader::Type)skey.second; ShaderMap::iterator sitr = shaderMap.find(skey); if (sitr != shaderMap.end()) { program->addShader(sitr->second.get()); } else { ref_ptr shader = new Shader(stype); + shader->setName(fileName); if (shader->loadShaderSourceFromFile(fileName)) { program->addShader(shader.get()); shaderMap.insert(ShaderMap::value_type(skey, shader)); @@ -961,6 +962,11 @@ struct UniformBuilder :public PassAttributeBuilder uniform->setName(name); uniform->setType(uniformType); switch (uniformType) { + case Uniform::BOOL: + initFromParameters(effect, valProp, uniform.get(), + static_cast(&Uniform::set), + options); + break; case Uniform::FLOAT: initFromParameters(effect, valProp, uniform.get(), static_cast(&Uniform::set), @@ -993,8 +999,8 @@ struct UniformBuilder :public PassAttributeBuilder // optimize common uniforms if (uniformType == Uniform::SAMPLER_2D || uniformType == Uniform::INT) { - int val; - uniform->get(val); + int val = 0; + uniform->get(val); // 'val' remains unchanged in case of error (Uniform is a non-scalar) if (uniformType == Uniform::SAMPLER_2D && val == 0 && name == "texture") { uniform = texture0; @@ -1387,10 +1393,11 @@ public: void valueChanged(SGPropertyNode* node) { - _tniq->refreshValidity(); + if (_tniq.valid()) + _tniq->refreshValidity(); } protected: - osg::ref_ptr _tniq; + osg::observer_ptr _tniq; }; template