yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
headless_overlay_renderer.h
Go to the documentation of this file.
1#ifndef YAZE_APP_SERVICE_HEADLESS_OVERLAY_RENDERER_H_
2#define YAZE_APP_SERVICE_HEADLESS_OVERLAY_RENDERER_H_
3
4#include <cstdint>
5#include <vector>
6
7namespace yaze {
8namespace app {
9namespace service {
10
11// CPU pixel-buffer rasterizer — draws filled rects, outlines, and lines
12// directly into an RGBA byte buffer. Replaces ImDrawList* for headless
13// (off-screen) rendering. Knows nothing about ROM format, HTTP, or ImGui.
14//
15// Coordinate space: pixel coordinates relative to top-left of the buffer,
16// before scale is applied. All draw calls apply the scale factor so callers
17// can work in "room tile" space (8px/tile at scale 1.0) and pass scale > 1
18// for upsampled output.
20 public:
21 // rgba: RGBA byte buffer (4 bytes per pixel, row-major).
22 // width/height: dimensions of the buffer in pixels.
23 // scale: pixel scale factor — multiply all coordinates/sizes by this.
24 HeadlessOverlayRenderer(std::vector<uint8_t>& rgba, int width, int height,
25 float scale = 1.0f);
26
27 // Filled rectangle with alpha blending.
28 void DrawFilledRect(float x, float y, float w, float h, uint8_t r, uint8_t g,
29 uint8_t b, uint8_t a);
30
31 // Outlined rectangle (border only), 1px thick.
32 void DrawRect(float x, float y, float w, float h, uint8_t r, uint8_t g,
33 uint8_t b, uint8_t a);
34
35 // Bresenham line.
36 void DrawLine(float x0, float y0, float x1, float y1, uint8_t r, uint8_t g,
37 uint8_t b, uint8_t a);
38
39 private:
40 // Alpha-blend src onto dst at pixel (px, py). Out-of-bounds writes are
41 // silently ignored.
42 void BlendPixel(int px, int py, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
43
44 std::vector<uint8_t>& rgba_;
45 int width_;
47 float scale_;
48};
49
50} // namespace service
51} // namespace app
52} // namespace yaze
53
54#endif // YAZE_APP_SERVICE_HEADLESS_OVERLAY_RENDERER_H_
void DrawRect(float x, float y, float w, float h, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void BlendPixel(int px, int py, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void DrawLine(float x0, float y0, float x1, float y1, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void DrawFilledRect(float x, float y, float w, float h, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
HeadlessOverlayRenderer(std::vector< uint8_t > &rgba, int width, int height, float scale=1.0f)