From: Tim Moore Date: Fri, 20 Nov 2009 21:58:59 +0000 (+0100) Subject: shader language predicate X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ebe5a5579cd61e759b523a38a2717eac9b562f83;p=simgear.git shader language predicate --- diff --git a/simgear/scene/material/Technique.cxx b/simgear/scene/material/Technique.cxx index 4258b464..b8093f35 100644 --- a/simgear/scene/material/Technique.cxx +++ b/simgear/scene/material/Technique.cxx @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -274,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) {