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  void releaseGLObjects(osg::State* state);
36 
37  private:
38  std::string mPath;
39 
40  // <name, code>
41  typedef std::map<std::string, std::string> TemplateMap;
43 
44  typedef std::pair<std::string, DefineMap> MapKey;
45  typedef std::map<MapKey, osg::ref_ptr<osg::Shader> > ShaderMap;
47 
48  typedef std::map<std::pair<osg::ref_ptr<osg::Shader>, osg::ref_ptr<osg::Shader> >, osg::ref_ptr<osg::Program> > ProgramMap;
50 
51  OpenThreads::Mutex mMutex;
52  };
53 
54 }
55 
56 #endif
OpenThreads::Mutex mMutex
Definition: shadermanager.hpp:51
std::map< std::string, std::string > DefineMap
Definition: shadermanager.hpp:23
std::string mPath
Definition: shadermanager.hpp:38
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:41
std::map< MapKey, osg::ref_ptr< osg::Shader > > ShaderMap
Definition: shadermanager.hpp:45
std::pair< std::string, DefineMap > MapKey
Definition: shadermanager.hpp:44
ShaderMap mShaders
Definition: shadermanager.hpp:46
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:48
osg::ref_ptr< osg::Program > getProgram(osg::ref_ptr< osg::Shader > vertexShader, osg::ref_ptr< osg::Shader > fragmentShader)
Definition: shadermanager.cpp:153
State
Definition: state.hpp:6
ProgramMap mPrograms
Definition: shadermanager.hpp:49
void setShaderPath(const std::string &path)
Definition: shadermanager.cpp:19
TemplateMap mShaderTemplates
Definition: shadermanager.hpp:42
void releaseGLObjects(osg::State *state)
Definition: shadermanager.cpp:167
Type
Definition: soundmanager.hpp:39