mercator 0.4.0
A terrain generation library for the Worldforge system.
ShaderFactory.cpp
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#include "ShaderFactory_impl.h"
6
7#include "DepthShader.h"
8#include "FillShader.h"
9#include "GrassShader.h"
10#include "ThresholdShader.h"
11
12#include <cassert>
13
14namespace Mercator {
15
16ShaderKit::ShaderKit() = default;
17
18ShaderKit::~ShaderKit() = default;
19
20ShaderFactories::ShaderFactories()
21{
22 m_factories.emplace("grass", std::make_unique<ShaderFactory<GrassShader>>());
23 m_factories.emplace("depth", std::make_unique<ShaderFactory<DepthShader>>());
24 m_factories.emplace("fill", std::make_unique<ShaderFactory<FillShader>>());
25 m_factories.emplace("high", std::make_unique<ShaderFactory<HighShader>>());
26 m_factories.emplace("low", std::make_unique<ShaderFactory<LowShader>>());
27 m_factories.emplace("band", std::make_unique<ShaderFactory<BandShader>>());
28}
29
30ShaderFactories::~ShaderFactories() = default;
31
32
38std::unique_ptr<Shader> ShaderFactories::newShader(const std::string & type,
39 const Shader::Parameters & params) const
40{
41 auto I = m_factories.find(type);
42 if (I == m_factories.end()) {
43 return nullptr;
44 }
45 assert(I->second);
46 return I->second->newShader(params);
47}
48
49} // namespace Mercator
std::unique_ptr< Shader > newShader(const std::string &type, const Shader::Parameters &) const
Create a shader of the specified type.
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
Definition: Shader.h:59