-
Notifications
You must be signed in to change notification settings - Fork 0
/
buffer_image.h
73 lines (48 loc) · 1.62 KB
/
buffer_image.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
/*
* GLViewer is a simple interface for opengl by handling the GLCore library
*
*/
#pragma once
#include "glviewer_common.h"
namespace GLViewer {
// Forward declare
class Viewer;
// Identifier for a image buffer
struct ImageBufferID {
ImageBufferID(uint ID) : id(ID) {}
uint id;
};
// A renderable image element
class RenderableImage
{
public:
// Don't construct directly, create with factory
RenderableImage(Viewer* viewer, ImageTexture texture, const glm::vec2& position2d, const glm::vec2& size, const glm::vec4& colour);
RenderableImage(Viewer* viewer, ImageTexture texture, const glm::vec3& position3d, const glm::vec2& size, const glm::vec4& colour);
private:
ImageTexture m_Texture;
glm::vec2 m_Position;
glm::vec2 m_Size;
glm::vec4 m_Colour;
bool m_Valid = false;
void Render();
friend class ImageBuffer;
};
// An image buffer to render image elements
class ImageBuffer
{
public:
void Add2DImage(ImageTexture texture, const glm::vec2& position2d, const glm::vec2& size, const glm::vec4& colour = { 1.0f, 1.0f, 1.0f, 1.0f });
void Add3DImage(ImageTexture texture, const glm::vec3& position3d, const glm::vec2& size, const glm::vec4& colour = { 1.0f, 1.0f, 1.0f, 1.0f });
// Don't construct directly, create with factory
ImageBuffer(Viewer* viewer);
private:
void ClearAll();
void SetData(std::function<void(ImageBuffer&)> cb_AddData);
void Render();
Viewer* m_Parent;
ImageBufferID m_ID;
std::vector<RenderableImage> m_Images;
friend class Buffers;
};
} // End namespace GLViewer