+
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
+
#include "Technique.hxx"
#include "Pass.hxx"
-#include <boost/bind.hpp>
#include <boost/foreach.hpp>
+#include <iterator>
#include <vector>
#include <string>
#include <osg/GLExtensions>
+#include <osg/GL2Extensions>
#include <osg/Math>
#include <osgUtil/CullVisitor>
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(),
- backRefInsertIterator(passes),
- bind(simgear::clone_ref<Pass>, _1, copyop));
-
+ for (std::vector<ref_ptr<Pass> >::const_iterator itr = rhs.passes.begin(),
+ end = rhs.passes.end();
+ itr != end;
+ ++itr)
+ passes.push_back(static_cast<Pass*>(copyop(itr->get())));
}
Technique::~Technique()
pass->releaseGLObjects(state);
}
if (state == 0) {
- for (int i = 0; i < _contextMap.size(); ++i) {
+ for (int i = 0; i < (int)_contextMap.size(); ++i) {
ContextInfo& info = _contextMap[i];
Status oldVal = info.valid();
info.valid.compareAndSwap(oldVal, UNKNOWN);
expression::ExpParserRegistrar
extensionSupportedRegistrar("extension-supported", extensionSupportedParser);
+class GLShaderLanguageExpression : public GeneralNaryExpression<float, int>
+{
+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<unsigned>(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<int>* contextExp = new VariableExpression<int>(location);
+ slexp->addOperand(contextExp);
+ return slexp;
+}
+
+expression::ExpParserRegistrar shaderLanguageRegistrar("shader-language",
+ glVersionParser);
+
+
void Technique::setGLExtensionsPred(float glVersion,
const std::vector<std::string>& extensions)
{
void Technique::refreshValidity()
{
- for (int i = 0; i < _contextMap.size(); ++i) {
+ for (int i = 0; i < (int)_contextMap.size(); ++i) {
ContextInfo& info = _contextMap[i];
Status oldVal = info.valid();
// What happens if we lose the race here?