X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2FTechnique.cxx;h=aeab9cf365b9b3057c70701b82e6d9165fd02397;hb=9f9c4cf32c2cf774c7febd7fe2b4e65a7d205294;hp=4c1dbe169c3a6f0eef2f5009fe168ccdcc086f87;hpb=57ccb6fd6b935a0bd41bc95df57ec037443da65d;p=simgear.git diff --git a/simgear/scene/material/Technique.cxx b/simgear/scene/material/Technique.cxx index 4c1dbe16..aeab9cf3 100644 --- a/simgear/scene/material/Technique.cxx +++ b/simgear/scene/material/Technique.cxx @@ -6,7 +6,6 @@ #include "Technique.hxx" #include "Pass.hxx" -#include #include #include @@ -14,6 +13,7 @@ #include #include +#include #include #include @@ -59,16 +59,15 @@ Technique::Technique(bool alwaysValid) Technique::Technique(const Technique& rhs, const osg::CopyOp& copyop) : _contextMap(rhs._contextMap), _alwaysValid(rhs._alwaysValid), - _shadowingStateSet(rhs._shadowingStateSet), + _shadowingStateSet(copyop(rhs._shadowingStateSet.get())), _validExpression(rhs._validExpression), _contextIdLocation(rhs._contextIdLocation) { - using namespace std; - using namespace boost; - transform(rhs.passes.begin(), rhs.passes.end(), - back_inserter(passes), - bind(simgear::clone_ref, _1, copyop)); - + for (std::vector >::const_iterator itr = rhs.passes.begin(), + end = rhs.passes.end(); + itr != end; + ++itr) + passes.push_back(static_cast(copyop(itr->get()))); } Technique::~Technique() @@ -276,6 +275,38 @@ Expression* extensionSupportedParser(const SGPropertyNode* exp, expression::ExpParserRegistrar extensionSupportedRegistrar("extension-supported", extensionSupportedParser); +class GLShaderLanguageExpression : public GeneralNaryExpression +{ +public: + void eval(float& value, const expression::Binding* b) const + { + value = 0.0f; + int contextId = getOperand(0)->getValue(b); + GL2Extensions* extensions + = GL2Extensions::Get(static_cast(contextId), true); + if (!extensions) + return; + if (!extensions->isGlslSupported()) + return; + value = extensions->getLanguageVersion(); + } +}; + +Expression* shaderLanguageParser(const SGPropertyNode* exp, + expression::Parser* parser) +{ + GLShaderLanguageExpression* slexp = new GLShaderLanguageExpression; + int location = parser->getBindingLayout().addBinding("__contextId", + expression::INT); + VariableExpression* contextExp = new VariableExpression(location); + slexp->addOperand(contextExp); + return slexp; +} + +expression::ExpParserRegistrar shaderLanguageRegistrar("shader-language", + glVersionParser); + + void Technique::setGLExtensionsPred(float glVersion, const std::vector& extensions) {