-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
55 lines (43 loc) · 971 Bytes
/
main.cpp
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
#include "canvas.hpp"
#include "options.hpp"
#ifdef USE_NETWORK_EPOLL
#include "network_epoll.hpp"
#else
#include "network_asio.hpp"
#endif
#if defined(USE_FBDEV)
#include "display_fbdev.hpp"
#else
#include "display_glfw.hpp"
#endif
#ifdef USE_FREETYPE
#include "text.hpp"
#endif
#include <iostream>
int main(int, char** argv) try
{
Options opt;
if (!opt.parse(argv)) {
opt.printUsage(argv);
return 1;
}
Display display(opt.buffer.x, opt.buffer.y, opt.fullscreen);
NetworkHandler* networkHandler;
display.bindCanvas = [&] () {
std::fill_n(display.canvas.data, display.canvas.width * display.canvas.height, 0);
if (!opt.quiet) {
#ifdef USE_FREETYPE
writeInfoText(display.canvas, opt.port);
#endif
}
networkHandler = new NetworkHandler(display.canvas, opt.port, opt.threadCount);
};
display.releaseCanvas = [&] () {
delete networkHandler;
};
display();
}
catch (const std::exception& e) {
std::cerr << e.what() << '\n';
return 1;
}