- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
Latest commit
74 lines (59 loc) · 1.6 KB
/
Copy pathmain.cpp
File metadata and controls
74 lines (59 loc) · 1.6 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
67
68
69
70
71
72
73
74
#include<SDL.h>
#include<iostream>
#include<fstream>
#include<gst/gst.h>
#include"RenderableText.h"
#include"HomeAssistant.h"
usingnamespacestd::chrono_literals;
using std::clog;
using std::endl;
#ifdef TARGET_OS_OSX
#defineSDL_DRIVER"cocoa"
#else
#defineSDL_DRIVER"KMSDRM"
#endif
intupdater(void *data) {
auto *homeAssistant = static_cast<HomeAssistant *>(data);
while (homeAssistant->running()) {
homeAssistant->update();
SDL_Delay(500);
}
return0;
}
intmain()
{
text_init();
auto init_re = SDL_VideoInit(SDL_DRIVER);
if (init_re != 0) {
std::cerr << "Unable to initialise the display!" << std::endl;
exit(EXIT_FAILURE);
}
SDL_Window *window;
SDL_Renderer *renderer;
SDL_CreateWindowAndRenderer(1920, 1080, SDL_WINDOW_SHOWN, &window, &renderer);
if (nullptr == window)
{
std::cerr << "SDL_CreateWindow(): " << SDL_GetError() << '\n';
exit(EXIT_FAILURE);
}
SDL_ShowCursor(SDL_DISABLE);
gst_init(nullptr, nullptr);
HomeAssistant homeAssistant;
SDL_Event event;
SDL_CreateThread(updater, "Updater", &homeAssistant);
while(homeAssistant.running()) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
homeAssistant.stop();
}
}
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
SDL_RenderClear(renderer);
homeAssistant.render(renderer);
SDL_RenderPresent(renderer);
SDL_Delay(40);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
}