Implement basic cache in ShadeComposer

This commit is contained in:
Robert Osfield
2010-07-02 14:18:59 +00:00
parent a55c4b7d70
commit 9f8670f50d
3 changed files with 123 additions and 4 deletions

View File

@@ -23,6 +23,8 @@ namespace osg {
// forward declare osg::State
class State;
typedef std::vector<osg::ShaderComponent*> ShaderComponents;
class OSG_EXPORT ShaderComposer : public osg::Object
{
public:
@@ -31,12 +33,22 @@ class OSG_EXPORT ShaderComposer : public osg::Object
ShaderComposer(const ShaderComposer& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Object(osg, ShaderComposer)
osg::Program* getOrCreateProgram() { return 0; }
virtual osg::Program* getOrCreateProgram(const ShaderComponents& shaderComponents);
typedef std::vector< const osg::Shader* > Shaders;
virtual osg::Shader* composeMain(const Shaders& shaders);
protected:
virtual ~ShaderComposer();
typedef std::map< ShaderComponents, ref_ptr<Program> > ProgramMap;
ProgramMap _programMap;
typedef std::map< Shaders, ref_ptr<Shader> > ShaderMainMap;
ShaderMainMap _shaderMainMap;
};
}