-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphicalAPI.cpp
More file actions
68 lines (56 loc) · 1.49 KB
/
GraphicalAPI.cpp
File metadata and controls
68 lines (56 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
** EPITECH PROJECT, 2020
** GraphicalAPI.cpp
** File description:
** header for GraphicalAPI.c
*/
#include <Polymorph/Core.hpp>
#include <Polymorph/Types.hpp>
#include <Polymorph/Debug.hpp>
#include <Polymorph/Settings.hpp>
#include <utility>
#include "GraphicalAPI/GraphicalAPI.hpp"
Polymorph::GraphicalAPI::GraphicalAPI(std::string handlerPath)
{
_handlerPath = std::move(handlerPath);
if (_instance != nullptr)
throw GraphicalException("Cannot create several Graphical API instance at once.", Logger::MAJOR);
_instance = this;
}
#ifdef _WIN32
HINSTANCE Polymorph::GraphicalAPI::getHandler()
{
if (!_instance)
return nullptr;
return _instance->_handler;
}
#else
void *Polymorph::GraphicalAPI::getHandler()
{
if (!_instance)
return nullptr;
return _instance->_handler;
}
#endif
Polymorph::GraphicalAPI::~GraphicalAPI()
{
CurrentDisplay.reset();
_displays.clear();
_instance = nullptr;
}
void Polymorph::GraphicalAPI::reloadAPI(const std::string& newHandler)
{
if (!_instance)
{
Logger::log("No Graphic API handler available to reload.", Logger::MAJOR);
return;
}
_instance->loadHandler(newHandler);
_instance->_handlerPath = newHandler;
}
Polymorph::Display Polymorph::GraphicalAPI::createDisplay(std::shared_ptr<Settings::VideoSettings> &videoSettings, const std::string &title)
{
auto n = std::make_shared<DisplayModule>(videoSettings, title);
_instance->_displays.push_back(n);
return Display(n);
}