From: James Turner Date: Thu, 16 Jan 2014 20:09:21 +0000 (+0000) Subject: Technique selection: fix shader-language X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=481f7e3bfac5bbdc7f1e2a894347860867b1ff9a;p=simgear.git Technique selection: fix shader-language (Also add a glsl-supported test to simplify Effect logic) --- diff --git a/simgear/scene/material/Technique.cxx b/simgear/scene/material/Technique.cxx index dc714bc2..d5d9b069 100644 --- a/simgear/scene/material/Technique.cxx +++ b/simgear/scene/material/Technique.cxx @@ -250,11 +250,7 @@ class GLVersionExpression : public SGExpression public: void eval(float& value, const expression::Binding*) const { -#ifdef TECHNIQUE_TEST_EXTENSIONS - value = 1.1; -#else value = getGLVersionNumber(); -#endif } }; @@ -335,9 +331,37 @@ Expression* shaderLanguageParser(const SGPropertyNode* exp, } expression::ExpParserRegistrar shaderLanguageRegistrar("shader-language", - glVersionParser); + shaderLanguageParser); + +class GLSLSupportedExpression : public GeneralNaryExpression +{ +public: + void eval(bool& value, const expression::Binding* b) const + { + value = false; + int contextId = getOperand(0)->getValue(b); + GL2Extensions* extensions + = GL2Extensions::Get(static_cast(contextId), true); + if (!extensions) + return; + value = extensions->isGlslSupported(); + } +}; + +Expression* glslSupportedParser(const SGPropertyNode* exp, + expression::Parser* parser) +{ + GLSLSupportedExpression* sexp = new GLSLSupportedExpression; + int location = parser->getBindingLayout().addBinding("__contextId", + expression::INT); + VariableExpression* contextExp = new VariableExpression(location); + sexp->addOperand(contextExp); + return sexp; +} - +expression::ExpParserRegistrar glslSupportedRegistrar("glsl-supported", + glslSupportedParser); + void Technique::setGLExtensionsPred(float glVersion, const std::vector& extensions) {