mercator  0.4.0
A terrain generation library for the Worldforge system.
ShaderFactory.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2005 Alistair Riddoch
4 
5 #ifndef MERCATOR_SHADER_FACTORY_H
6 #define MERCATOR_SHADER_FACTORY_H
7 
8 #include "Shader.h"
9 #include <memory>
10 
11 namespace Mercator {
12 
14 class ShaderKit {
15  protected:
16  explicit ShaderKit();
17  public:
18  virtual ~ShaderKit();
19 
23  virtual std::unique_ptr<Shader> newShader(const Shader::Parameters &) const = 0;
24 };
25 
27 template <class T>
28 class ShaderFactory : public ShaderKit {
29  public:
30  ShaderFactory();
31  ~ShaderFactory() override;
32 
33  std::unique_ptr<Shader> newShader(const Shader::Parameters &) const override;
34 };
35 
41  private:
42 
44  std::map<std::string, std::unique_ptr<ShaderKit>> m_factories;
45 
46  public:
48  ~ShaderFactories();
49 
50  std::unique_ptr<Shader> newShader(const std::string & type,
51  const Shader::Parameters &) const;
52 };
53 
54 } // namespace Mercator
55 
56 #endif // MERCATOR_SHADER_FACTORY_H
Mercator::ShaderFactory::newShader
std::unique_ptr< Shader > newShader(const Shader::Parameters &) const override
Create a new Shader instance.
Definition: ShaderFactory_impl.h:19
Mercator::ShaderKit
Interface for shader factory objects.
Definition: ShaderFactory.h:14
Mercator::ShaderKit::newShader
virtual std::unique_ptr< Shader > newShader(const Shader::Parameters &) const =0
Create a new Shader instance.
Mercator::ShaderFactories::newShader
std::unique_ptr< Shader > newShader(const std::string &type, const Shader::Parameters &) const
Create a shader of the specified type.
Definition: ShaderFactory.cpp:38
Mercator::ShaderFactory
Factory template used to create ordinary shader objects.
Definition: ShaderFactory.h:28
Mercator::ShaderFactories
Class which manages all the shader factories available.
Definition: ShaderFactory.h:40
Mercator::Shader::Parameters
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
Definition: Shader.h:59