#include <simgear/scene/util/StateAttributeFactory.hxx>
#include <simgear/structure/OSGUtils.hxx>
#include <simgear/structure/SGExpression.hxx>
-
+#include <simgear/props/vectorPropTemplates.hxx>
namespace simgear
InstallAttributeBuilder<TextureUnitBuilder> textureUnitBuilder("texture-unit");
// Shader key, used both for shaders with relative and absolute names
-typedef pair<string, Shader::Type> ShaderKey;
+typedef pair<string, int> ShaderKey;
-inline ShaderKey makeShaderKey(SGPropertyNode_ptr& ptr, Shader::Type shaderType)
+inline ShaderKey makeShaderKey(SGPropertyNode_ptr& ptr, int shaderType)
{
return ShaderKey(ptr->getStringValue(), shaderType);
}
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 ") +
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> shader = new Shader(stype);
+ shader->setName(fileName);
if (shader->loadShaderSourceFromFile(fileName)) {
program->addShader(shader.get());
shaderMap.insert(ShaderMap::value_type(skey, shader));
uniform->setName(name);
uniform->setType(uniformType);
switch (uniformType) {
+ case Uniform::BOOL:
+ initFromParameters(effect, valProp, uniform.get(),
+ static_cast<bool (Uniform::*)(bool)>(&Uniform::set),
+ options);
+ break;
case Uniform::FLOAT:
initFromParameters(effect, valProp, uniform.get(),
static_cast<bool (Uniform::*)(float)>(&Uniform::set),
// 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;
void valueChanged(SGPropertyNode* node)
{
- _tniq->refreshValidity();
+ if (_tniq.valid())
+ _tniq->refreshValidity();
}
protected:
- osg::ref_ptr<Technique> _tniq;
+ osg::observer_ptr<Technique> _tniq;
};
template<typename T>