-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDekiRenderSystem.h
More file actions
64 lines (51 loc) · 2.28 KB
/
DekiRenderSystem.h
File metadata and controls
64 lines (51 loc) · 2.28 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
#pragma once
#include <cstdint>
#include "DekiEngine.h"
#include "Color.h"
#include "providers/IDekiRenderSystem.h"
// Forward declarations
class DekiObject;
class CameraComponent;
class DekiRenderer;
class DekiRenderSystem : public IDekiRenderSystem
{
private:
uint8_t* render_buffer;
int32_t screen_width;
int32_t screen_height;
DekiColorFormat color_format;
bool m_IsFirstRender = true;
bool m_OwnsBuffer = true;
// Active renderer (non-owning — caller manages lifetime)
DekiRenderer* m_Renderer = nullptr;
// Cached camera (searched once, invalidated on prefab change)
CameraComponent* m_CachedCamera = nullptr;
Prefab* m_CachedCameraPrefab = nullptr;
public:
DekiRenderSystem();
~DekiRenderSystem() override;
bool Setup(int32_t width, int32_t height, DekiColorFormat format) override;
void Render(Prefab* current_prefab) override;
void ClearBuffer(uint8_t r, uint8_t g, uint8_t b);
void ClearBuffer(const deki::Color& color);
// Renderer management
void SetRenderer(DekiRenderer* renderer) override { m_Renderer = renderer; }
DekiRenderer* GetRenderer() const override { return m_Renderer; }
// Access methods for external systems (like HAL)
const uint8_t* GetFrameBuffer() const override { return render_buffer; }
int32_t GetScreenWidth() const override { return screen_width; }
int32_t GetScreenHeight() const override { return screen_height; }
DekiColorFormat GetColorFormat() const override { return color_format; }
// Pixel operations (optimized for fast execution)
void GetPixel(int32_t x, int32_t y, uint8_t* r, uint8_t* g, uint8_t* b) const;
deki::Color GetPixel(int32_t x, int32_t y) const;
int GetBytesPerPixel(DekiColorFormat format);
// IDekiRenderSystem interface — delegates to the static implementation
void RenderToBuffer(Prefab* prefab, ICamera* camera,
uint8_t* buffer, int32_t width, int32_t height,
DekiColorFormat format) override;
// Static render function (the actual implementation)
static void RenderToBufferStatic(Prefab* prefab, ICamera* camera,
uint8_t* buffer, int32_t width, int32_t height,
DekiColorFormat format);
};