Symphony Of Empires
material.cpp
Go to the documentation of this file.
1 // Eng3D - General purpouse game engine
2 // Copyright (C) 2021, Eng3D contributors
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16 //
17 // ----------------------------------------------------------------------------
18 // Name:
19 // material.cpp
20 //
21 // Abstract:
22 // Defines functions for the loading, management, creation and destruction
23 // of a material resource.
24 // ----------------------------------------------------------------------------
25 
26 #include <algorithm>
27 #include <fstream>
28 #include <string>
29 
30 #include "eng3d/material.hpp"
31 #include "eng3d/texture.hpp"
32 #include "eng3d/state.hpp"
33 #include "eng3d/log.hpp"
34 
35 //
36 // Material manager
37 //
38 const std::shared_ptr<Eng3D::Material> Eng3D::MaterialManager::load(const std::string& name) {
39  auto it = materials.find(name);
40  if(it != materials.end()) return it->second;
41 
42  Eng3D::Log::error("material", Eng3D::translate_format("%s not found", name.c_str()));
43  std::shared_ptr<Eng3D::Material> material = std::make_shared<Eng3D::Material>();
44  materials[name] = material;
45  return materials[name];
46 }
const std::shared_ptr< Eng3D::Material > load(const std::string &name)
Definition: material.cpp:38
void error(const std::string_view category, const std::string_view msg)
Definition: log.cpp:68
std::string translate_format(const std::string_view format, Args &&... args)
String formatter, with translation.
Definition: string.hpp:128