aboutsummaryrefslogtreecommitdiff
path: root/src/renderer/RSoftwareBackend.hpp
blob: 3e5e17d660b988bfd68bb6530f7858ec3853a5a8 (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
#pragma once

#include <SDL3/SDL.h>
#include <renderer/Renderer.hpp>


class RSoftwareBackend {
public:
    struct Canvas {
        uint32_t rshift;
        uint32_t gshift;
        uint32_t bshift;
        uint32_t ashift;
        int32_t w;
        int32_t h;
        uint32_t* pixels;
    };

    struct DestRect {
        int32_t x0;
        int32_t y0;
        int32_t x1;
        int32_t y1;
    };


public:
    RSoftwareBackend(Renderer& renderer);

    void Draw();
    void Clear(Color color);


private:
    void ResizeCanvas(int32_t w, int32_t h);
    void SortRenderEntities();

    void DrawRectangle(REntity_Rectangle& entity);
    void DrawAlphaBitmap(REntity_AlphaBitmap& entity);
    void DrawText(REntity_Text& entity);
    void DrawTextGlyph(Glyph& glyph, Color color, int32_t xscreen, int32_t yscreen);


private:
    Renderer& m_renderer;

    uint32_t m_gltexture_id{};
    Canvas m_canvas;
};