blob: 397f62d0b150445439b8966ada68dcf55adc5cd1 (
plain)
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
|
/* -------------------------------------------
Copyright Mahrouss Logic
------------------------------------------- */
#ifndef __INC_FB_HPP__
#define __INC_FB_HPP__
#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>
namespace HCore {
enum class FramebufferColorKind : UChar {
RGB32,
RGB16,
RGB8,
INVALID,
};
class FramebufferContext final {
public:
UIntPtr m_Base;
UIntPtr m_Bpp;
UInt m_Width;
UInt m_Height;
};
class Framebuffer final {
public:
explicit Framebuffer(Ref<FramebufferContext *> &addr)
: m_FrameBufferAddr(addr) {}
~Framebuffer() {}
Framebuffer &operator=(const Framebuffer &) = delete;
Framebuffer(const Framebuffer &) = default;
volatile UIntPtr *operator[](const UIntPtr &pos);
operator bool();
const FramebufferColorKind &Color(
const FramebufferColorKind &colour = FramebufferColorKind::INVALID);
Ref<FramebufferContext *> &Leak();
/// @brief Draws a rectangle inside the fb.
/// @param width
/// @param height
/// @param x
/// @param y
/// @param color
/// @return
Framebuffer &DrawRect(SizeT width, SizeT height, SizeT x, SizeT y,
UInt32 color);
/// @brief Puts a pixel on the screen.
/// @param x where in X
/// @param y where in Y
/// @param color the color of it.
/// @return
Framebuffer &PutPixel(SizeT x, SizeT y, UInt32 color);
private:
Ref<FramebufferContext *> m_FrameBufferAddr;
FramebufferColorKind m_Colour;
};
/***********************************************************************************/
/// Color utils.
/***********************************************************************************/
const UInt32 kRgbRed = 0x000000FF;
const UInt32 kRgbGreen = 0x0000FF00;
const UInt32 kRgbBlue = 0x00FF0000;
const UInt32 kRgbBlack = 0x00000000;
const UInt32 kRgbWhite = 0xFFFFFFFF;
} // namespace HCore
/***********************************************************************************/
/// Color macros.
/***********************************************************************************/
#define RGB(R, G, B) (HCore::UInt32)(0x##R##G##B)
#endif /* ifndef __INC_FB_HPP__ */
|