OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shadermanager.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_SHADERMANAGER_H
2 #define OPENMW_COMPONENTS_SHADERMANAGER_H
3 
4 #include <string>
5 #include <map>
6 
7 #include <osg/ref_ptr>
8 
9 #include <osg/Shader>
10 
11 #include <OpenThreads/Mutex>
12 
13 namespace Shader
14 {
15 
19  {
20  public:
21  void setShaderPath(const std::string& path);
22 
23  typedef std::map<std::string, std::string> DefineMap;
24 
31  osg::ref_ptr<osg::Shader> getShader(const std::string& shaderTemplate, const DefineMap& defines, osg::Shader::Type shaderType);
32 
33  osg::ref_ptr<osg::Program> getProgram(osg::ref_ptr<osg::Shader> vertexShader, osg::ref_ptr<osg::Shader> fragmentShader);
34 
35 
36  private:
37  std::string mPath;
38 
39  // <name, code>
40  typedef std::map<std::string, std::string> TemplateMap;
42 
43  typedef std::pair<std::string, DefineMap> MapKey;
44  typedef std::map<MapKey, osg::ref_ptr<osg::Shader> > ShaderMap;
46 
47  typedef std::map<std::pair<osg::ref_ptr<osg::Shader>, osg::ref_ptr<osg::Shader> >, osg::ref_ptr<osg::Program> > ProgramMap;
49 
50  OpenThreads::Mutex mMutex;
51  };
52 
53 }
54 
55 #endif
OpenThreads::Mutex mMutex
Definition: shadermanager.hpp:50
std::map< std::string, std::string > DefineMap
Definition: shadermanager.hpp:23
std::string mPath
Definition: shadermanager.hpp:37
osg::ref_ptr< osg::Shader > getShader(const std::string &shaderTemplate, const DefineMap &defines, osg::Shader::Type shaderType)
Definition: shadermanager.cpp:104
std::map< std::string, std::string > TemplateMap
Definition: shadermanager.hpp:40
std::map< MapKey, osg::ref_ptr< osg::Shader > > ShaderMap
Definition: shadermanager.hpp:44
std::pair< std::string, DefineMap > MapKey
Definition: shadermanager.hpp:43
ShaderMap mShaders
Definition: shadermanager.hpp:45
Reads shader template files and turns them into a concrete shader, based on a list of define's...
Definition: shadermanager.hpp:18
std::map< std::pair< osg::ref_ptr< osg::Shader >, osg::ref_ptr< osg::Shader > >, osg::ref_ptr< osg::Program > > ProgramMap
Definition: shadermanager.hpp:47
osg::ref_ptr< osg::Program > getProgram(osg::ref_ptr< osg::Shader > vertexShader, osg::ref_ptr< osg::Shader > fragmentShader)
Definition: shadermanager.cpp:149
ProgramMap mPrograms
Definition: shadermanager.hpp:48
void setShaderPath(const std::string &path)
Definition: shadermanager.cpp:19
TemplateMap mShaderTemplates
Definition: shadermanager.hpp:41