low level render working
This commit is contained in:
85
low_level_render.h
Normal file
85
low_level_render.h
Normal file
@@ -0,0 +1,85 @@
|
||||
// class that handles low-level rendering operations, such as drawing pixels and shapes to the display.
|
||||
// This class is framework-agnostic and focuses solely on manipulating a 1-bit per pixel buffer.
|
||||
// Constructor Args:
|
||||
// uint8_t* buffer: Pointer to the bit buffer
|
||||
// int width: Display width in pixels
|
||||
// int height: Display height in pixels
|
||||
|
||||
#ifndef LOW_LEVEL_RENDER_H
|
||||
#define LOW_LEVEL_RENDER_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Font extern declarations
|
||||
extern const unsigned char font_5x5[96][6];
|
||||
extern const unsigned char font_7linedigital[96][6];
|
||||
extern const unsigned char font_BMplain[96][6];
|
||||
extern const unsigned char font_Blokus[96][6];
|
||||
extern const unsigned char font_HISKYF21[96][6];
|
||||
extern const unsigned char font_Minimum[96][6];
|
||||
extern const unsigned char font_SUPERDIG[96][6];
|
||||
extern const unsigned char font_acme_5_outlines[96][6];
|
||||
extern const unsigned char font_aztech[96][6];
|
||||
extern const unsigned char font_crackers[96][6];
|
||||
extern const unsigned char font_haiku[96][6];
|
||||
extern const unsigned char font_sloth[96][6];
|
||||
extern const unsigned char font_zxpix[96][6];
|
||||
|
||||
class LowLevelRenderer {
|
||||
private:
|
||||
uint8_t* bit_buffer;
|
||||
int V_WIDTH;
|
||||
int V_HEIGHT;
|
||||
const unsigned char (*current_font)[96][6];
|
||||
bool clipping_enabled;
|
||||
int clip_x, clip_y, clip_width, clip_height;
|
||||
bool text_color;
|
||||
void draw_corner_arc(int center_x, int center_y, int radius, int quadrant, bool on);
|
||||
void fill_bottom_flat_triangle(int x1, int y1, int x2, int y2, int x3, int y3, bool on);
|
||||
void fill_top_flat_triangle(int x1, int y1, int x2, int y2, int x3, int y3, bool on);
|
||||
bool is_point_in_clip_rect(int x, int y);
|
||||
|
||||
public:
|
||||
LowLevelRenderer(uint8_t* buffer, int width, int height);
|
||||
|
||||
// Font management
|
||||
void set_font(const unsigned char (*font)[96][6]);
|
||||
void set_text_color(bool color);
|
||||
|
||||
// --- 1-BIT DRAWING PRIMITIVES ---
|
||||
void set_pixel(int x, int y, bool on);
|
||||
void draw_line(int x0, int y0, int x1, int y1, bool on);
|
||||
void draw_rectangle(int x, int y, int width, int height, bool on);
|
||||
void draw_filled_rectangle(int x, int y, int width, int height, bool on);
|
||||
void draw_rounded_rectangle(int x, int y, int width, int height, int radius, bool on);
|
||||
void draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3, bool on);
|
||||
void draw_filled_triangle(int x1, int y1, int x2, int y2, int x3, int y3, bool on);
|
||||
void draw_ellipse(int center_x, int center_y, int radius_x, int radius_y, bool on);
|
||||
void draw_filled_ellipse(int center_x, int center_y, int radius_x, int radius_y, bool on);
|
||||
void draw_polygon(const std::vector<std::pair<int, int>>& points, bool on);
|
||||
void draw_filled_polygon(const std::vector<std::pair<int, int>>& points, bool on);
|
||||
void draw_arc(int center_x, int center_y, int radius, int start_angle, int end_angle, bool on);
|
||||
|
||||
// Bitmap drawing
|
||||
void draw_bitmap(const unsigned char* bitmap, int x, int y, int width, int height, bool invert = false);
|
||||
|
||||
// Clipping functions
|
||||
void set_clip_rect(int x, int y, int width, int height);
|
||||
void reset_clip_rect();
|
||||
bool is_clipping_enabled() const;
|
||||
|
||||
// Buffer operations
|
||||
void invert_buffer();
|
||||
void clear_buffer();
|
||||
|
||||
void draw_circle(int x, int y, int radius, bool on);
|
||||
void draw_filled_circle(int x, int y, int radius, bool on);
|
||||
void draw_char_vcol(int x, int y, char c);
|
||||
void draw_string(int x, int y, const std::string &text, int spacing = 1);
|
||||
void draw_char_scaled(int x, int y, char c, int scale);
|
||||
void draw_string_scaled(int x, int y, const char* text, int scale, int spacing = 1);
|
||||
};
|
||||
|
||||
#endif // LOW_LEVEL_RENDER_H
|
||||
Reference in New Issue
Block a user