-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplaymanager.h
More file actions
98 lines (73 loc) · 2 KB
/
displaymanager.h
File metadata and controls
98 lines (73 loc) · 2 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Created by Ian Parker on 06/03/2025.
//
#ifndef DISPLAYS_H
#define DISPLAYS_H
#include <string>
#include <vector>
#include <gst/gst.h>
#include <XPLMDisplay.h>
#include "logger.h"
#include <yaml-cpp/node/node.h>
class XStreamPlugin;
struct Texture;
struct Display
{
GstElement* appSrc = nullptr;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
std::string name;
std::shared_ptr<Texture> texture;
uint8_t* buffer = nullptr;
Display() = default;
Display(int x, int y, int width, int height, const std::string &name, const std::shared_ptr<Texture> &texture) :
x(x),
y(y),
width(width),
height(height),
name(name),
texture(texture)
{
buffer = new uint8_t[width * height * 4];
}
~Display()
{
delete[] buffer;
}
};
struct Texture
{
int textureNum = 0;
int textureWidth = 0;
int textureHeight = 0;
uint8_t* buffer = nullptr;
std::vector<std::shared_ptr<Display>> displays;
~Texture()
{
delete[] buffer;
}
};
class DisplayManager : private Logger
{
bool m_running = false;
std::vector<std::shared_ptr<Texture>> m_textures;
std::vector<std::shared_ptr<Display>> m_displays;
float m_lastUpdate = 0.0f;
static void copyDisplay(const std::shared_ptr<Texture> &texture, const std::shared_ptr<Display> &display);
static int updateCallback(XPLMDrawingPhase inPhase, [[maybe_unused]] int inIsBefore, void *inRefcon);
std::shared_ptr<Texture> checkTexture(YAML::Node &displayDef, int textureNum, YAML::Node &textureDef);
void dumpTexture(int i, std::string icao);
void update();
bool findDefinition(YAML::Node &result);
public:
DisplayManager() : Logger("DisplayManager") {}
~DisplayManager() override = default;
bool start();
bool stop();
bool findDisplays();
[[nodiscard]] std::vector<std::shared_ptr<Display>> getDisplays() const { return m_displays; }
void dumpTextures();
};
#endif //DISPLAYS_H