-
Notifications
You must be signed in to change notification settings - Fork 3
/
videodevice.h
80 lines (57 loc) · 2.14 KB
/
videodevice.h
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
#pragma once
#include <GL/gl.h>
#include <glm/glm.hpp>
#include "result.h"
#include "mediaformat.h"
#include <map>
namespace videodevice
{
static const uint32_t NUM_FRAME_DATA_POINTERS = 4;
struct Device;
struct FrameBuffer
{
uint8_t* frameData[NUM_FRAME_DATA_POINTERS];
uint32_t lineSize[NUM_FRAME_DATA_POINTERS];
uint32_t width;
uint32_t height;
};
struct Renderer
{
virtual ~Renderer(){}
virtual Result Create() = 0;
virtual Result SetWindowSize(uint32_t width, uint32_t height) = 0;
};
struct FrameRenderer : public Renderer
{
virtual Result Render(FrameBuffer*) = 0;
virtual Result SetTextureSize(uint32_t width, uint32_t height) = 0;
};
struct TextRenderer : public Renderer
{
virtual Result Render(const std::string& text, const std::string& fontName, uint32_t fontSize, float x, float y, float scale, glm::vec3 color) = 0;
virtual Result GetSize(const std::string& text, const std::string& fontName, uint32_t fontSize, float& w, float& h) = 0;
};
struct Device
{
// texture size
GLuint width = 0;
GLuint height = 0;
// video size
GLuint windowWidth = 0;
GLuint windowHeight = 0;
// video renderer
FrameRenderer* renderer = nullptr;
// text renderer
TextRenderer* text = nullptr;
};
Result Init();
void GetSupportedFormat(VideoFormatList&) ;
Result Create(Device*& device, VideoFormat outputFormat);
Result DrawFrame(Device* device, FrameBuffer*);
Result DrawText(Device* device, const std::string& text, const std::string& fontName, uint32_t fontSize, float x, float y, float scale, glm::vec3 color);
Result GetTextSize(Device* device, const std::string& text, const std::string& fontName, uint32_t fontSize, float& w, float& h);
Result SetTextureSize(Device* device, uint32_t width, uint32_t height);
Result SetWindowSize(Device* device, uint32_t width, uint32_t height);
Result GetWindowSize(Device* device, uint32_t& width, uint32_t& height);
void Destroy(Device*& device);
}