_bufferList.clear();
}
-void EffectCullVisitor::addBuffer(int i, osg::Texture2D* tex)
+void EffectCullVisitor::addBuffer(std::string b, osg::Texture2D* tex)
{
- _bufferList.insert(std::make_pair(i,tex));
+ _bufferList.insert(std::make_pair(b,tex));
}
-osg::Texture2D* EffectCullVisitor::getBuffer(int i)
+osg::Texture2D* EffectCullVisitor::getBuffer(std::string b)
{
- return _bufferList[i];
+ return _bufferList[b];
}
}
virtual void reset();
void clearBufferList();
- void addBuffer(int i, osg::Texture2D* tex);
- osg::Texture2D* getBuffer(int i);
+ void addBuffer(std::string b, osg::Texture2D* tex);
+ osg::Texture2D* getBuffer(std::string b);
private:
- std::map<int,osg::ref_ptr<osg::Texture2D> > _bufferList;
+ std::map<std::string,osg::ref_ptr<osg::Texture2D> > _bufferList;
std::vector<osg::ref_ptr<EffectGeode> > _lightList;
bool _collectLights;
};
class Pass : public osg::StateSet
{
public:
- typedef std::list<std::pair<int,int> > BufferUnitList;
+ typedef std::list<std::pair<int,std::string> > BufferUnitList;
typedef std::map<std::string,osg::Vec4> PositionedUniformMap;
META_Object(simgear,Pass);
Pass(const Pass& rhs,
const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
- void setBufferUnit( int unit, int buffer ) { _bufferUnitList.push_back( std::make_pair(unit,buffer) ); }
+ void setBufferUnit( int unit, std::string buffer ) { _bufferUnitList.push_back( std::make_pair(unit,buffer) ); }
const BufferUnitList& getBufferUnitList() const { return _bufferUnitList; }
void addPositionedUniform( const std::string& name, const osg::Vec4& offset ) { _positionedUniforms[name] = offset; }
class GBufferBuilder : public TextureBuilder
{
public:
- GBufferBuilder(int b) : buffer(b) {}
+ GBufferBuilder() {}
Texture* build(Effect* effect, Pass* pass, const SGPropertyNode*,
const SGReaderWriterOptions* options);
private:
- int buffer;
+ string buffer;
};
Texture* GBufferBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode* prop,
if (pUnit) {
unit = pUnit->getValue<int>();
} else {
- const SGPropertyNode* pName = prop->getChild("name");
- if (pName)
- try {
- unit = boost::lexical_cast<int>(pName->getStringValue());
- } catch (boost::bad_lexical_cast& lex) {
- SG_LOG(SG_INPUT, SG_ALERT, "can't decode name as texture unit "
- << lex.what());
- }
+ SG_LOG(SG_INPUT, SG_ALERT, "no texture unit");
}
+ buffer = prop->getStringValue("name");
+
pass->setBufferUnit( unit, buffer );
// Return white for now. Would be overridden in Technique::ProcessDrawable
namespace
{
- TextureBuilder::Registrar installDepthBuffer("depth-buffer", new GBufferBuilder(Effect::DEPTH_BUFFER));
- TextureBuilder::Registrar installNormalBuffer("normal-buffer", new GBufferBuilder(Effect::NORMAL_BUFFER));
- TextureBuilder::Registrar installDiffuseBuffer("diffuse-buffer", new GBufferBuilder(Effect::DIFFUSE_BUFFER));
- TextureBuilder::Registrar installSpecularBuffer("spec-emis-buffer", new GBufferBuilder(Effect::SPEC_EMIS_BUFFER));
- TextureBuilder::Registrar installLightingBuffer("lighting-buffer", new GBufferBuilder(Effect::LIGHTING_BUFFER));
- TextureBuilder::Registrar installMiddleBloomBuffer("middle-bloom-buffer", new GBufferBuilder(Effect::MIDDLE_BLOOM_BUFFER));
- TextureBuilder::Registrar installBloomBuffer("bloom-buffer", new GBufferBuilder(Effect::BLOOM_BUFFER));
- TextureBuilder::Registrar installAoBuffer("ao-buffer", new GBufferBuilder(Effect::AO_BUFFER));
- TextureBuilder::Registrar installShadowBuffer("shadow-buffer", new GBufferBuilder(Effect::SHADOW_BUFFER));
+ TextureBuilder::Registrar installBuffer("buffer", new GBufferBuilder);
}
}