-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
47 lines (31 loc) · 1.05 KB
/
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
static_assert(__cplusplus >= 202002L, "C++20 required");
#include <cpptrace.hpp>
#include <getopt.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h>
#include <memory>
#include "args.hpp"
#include "src/waylandGfx.hpp"
int main(int argc, char **argv) {
cpptrace::register_terminate_handler();
Args::parse(argc, argv);
Config::load();
std::unique_ptr<PlatformGfx> gfx = std::make_unique<WaylandGfx>();
gfx->init();
auto loop_accounting_ticks = 0ULL;
auto loop_accounting_last = std::chrono::high_resolution_clock::now();
gfx->platformEventLoop([&]() {
auto const t_now = std::chrono::high_resolution_clock::now();
auto const t_diff = std::chrono::duration_cast<std::chrono::milliseconds>(
t_now - loop_accounting_last)
.count();
if (t_diff > 1000) {
std::cerr << std::format("fps: {}\n", loop_accounting_ticks);
loop_accounting_ticks = 0;
loop_accounting_last = t_now;
}
loop_accounting_ticks++;
return true;
});
return 0;
}