Lugdunum  0.1.0
Graphics.cpp
Go to the documentation of this file.
2 
3 #include <iterator>
4 #include <sstream>
5 #include <map>
6 
11 
12 namespace lug {
13 namespace Graphics {
14 
15 Graphics::Graphics(const std::string& appName, const Core::Version& appVersion) : _appName{appName}, _appVersion{appVersion} {}
16 
17 bool Graphics::init(const InitInfo& initInfo) {
18  return beginInit(initInfo) && finishInit();
19 }
20 
21 bool Graphics::beginInit(const InitInfo& initInfo) {
22  _initInfo = initInfo;
23 
24  switch (_initInfo.rendererType) {
26  _renderer = std::make_unique<Vulkan::Renderer>(*this);
27  break;
28  default:
29  LUG_LOG.error("Graphics: Can't init renderer with specified render type");
30  break;
31  }
32 
35 
37  return false;
38  }
39 
40  return true;
41 }
42 
44  if (!_renderer->finishInit()) {
45  return false;
46  }
47 
48  // Check if all mandatory modules are loaded
49  {
50  if (_loadedMandatoryModules.size() != _initInfo.mandatoryModules.size()) {
51  LUG_LOG.error("Graphics: Can't init the engine with all the mandatory modules");
52  return false;
53  }
54  }
55 
56 #if defined(LUG_DEBUG)
57  LUG_LOG.info("Graphics: Successfully init");
58 
59  {
60  std::stringstream ss{};
61  std::copy(_loadedMandatoryModules.begin(), _loadedMandatoryModules.end(), std::ostream_iterator<Module::Type>(ss, " "));
62  LUG_LOG.info("Graphics: Mandatory modules loaded : {}", ss.str());
63  }
64 
65  {
66  std::stringstream ss{};
67  std::copy(_loadedOptionalModules.begin(), _loadedOptionalModules.end(), std::ostream_iterator<Module::Type>(ss, " "));
68  LUG_LOG.info("Graphics: Optional modules loaded : {}", ss.str());
69  }
70 #endif
71 
72  return true;
73 }
74 
76  {
77  const auto it = std::find(std::begin(_loadedMandatoryModules), std::end(_loadedMandatoryModules), type);
78 
79  if (it != std::end(_loadedMandatoryModules)) {
80  _loadedMandatoryModules.erase(it);
81  }
82  }
83 
84  {
85  const auto it = std::find(std::begin(_loadedOptionalModules), std::end(_loadedOptionalModules), type);
86 
87  if (it != std::end(_loadedOptionalModules)) {
88  _loadedOptionalModules.erase(it);
89  }
90  }
91 }
92 
93 } // Graphics
94 } // lug
Stores the version of the Application.
Definition: Version.hpp:9
std::unique_ptr< Renderer > _renderer
Definition: Graphics.hpp:111
std::set< Module::Type > _loadedOptionalModules
Definition: Graphics.hpp:109
std::set< Module::Type > mandatoryModules
Definition: Graphics.hpp:33
Utility structure used to initialize the Graphics component.
Definition: Graphics.hpp:30
Core::Version _appVersion
Definition: Graphics.hpp:104
std::set< Module::Type > _loadedMandatoryModules
Definition: Graphics.hpp:108
Renderer::InitInfo rendererInitInfo
Definition: Graphics.hpp:32
bool finishInit()
Finish the initialization of the application with the informations filled in initInfo structure...
Definition: Graphics.cpp:43
bool beginInit(const InitInfo &initInfo)
Begin the initialization of the application with the informations filled in initInfo structure...
Definition: Graphics.cpp:21
std::set< Module::Type > optionalModules
Definition: Graphics.hpp:34
#define LUG_LOG
Definition: Logger.hpp:73
void unsupportedModule(Module::Type type)
Definition: Graphics.cpp:75
Class for graphics.
Definition: Graphics.hpp:25
bool init(const InitInfo &initInfo)
Initializes the application with the informations filled in initInfo structure.
Definition: Graphics.cpp:17