48 lines
1.4 KiB
C
48 lines
1.4 KiB
C
#pragma once
|
|
#include "stdint.h"
|
|
#include "stddef.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// 32-bit ARGB Color Palette Helpers
|
|
#define FB_COLOR(r, g, b) (((uint32_t)(r) << 16) | ((uint32_t)(g) << 8) | (uint32_t)(b))
|
|
#define FB_BLACK FB_COLOR(15, 17, 23)
|
|
#define FB_WHITE FB_COLOR(240, 246, 252)
|
|
#define FB_DARK_GRAY FB_COLOR(33, 38, 45)
|
|
#define FB_LIGHT_GRAY FB_COLOR(139, 148, 158)
|
|
#define FB_BLUE FB_COLOR(88, 166, 255)
|
|
#define FB_NAVY FB_COLOR(22, 27, 34)
|
|
#define FB_GREEN FB_COLOR(63, 185, 80)
|
|
#define FB_RED FB_COLOR(248, 81, 73)
|
|
#define FB_ORANGE FB_COLOR(210, 153, 34)
|
|
#define FB_PURPLE FB_COLOR(188, 140, 255)
|
|
#define FB_CYAN FB_COLOR(56, 189, 248)
|
|
|
|
typedef struct {
|
|
uint32_t *buffer;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t pitch;
|
|
uint32_t bpp;
|
|
int is_initialized;
|
|
} fb_context_t;
|
|
|
|
extern fb_context_t g_fb;
|
|
|
|
// Framebuffer API
|
|
int fb_init(void);
|
|
void fb_clear(uint32_t color);
|
|
void fb_draw_pixel(int x, int y, uint32_t color);
|
|
void fb_fill_rect(int x, int y, int w, int h, uint32_t color);
|
|
void fb_draw_rect(int x, int y, int w, int h, uint32_t color);
|
|
void fb_draw_char(int x, int y, char c, uint32_t fg, uint32_t bg);
|
|
void fb_draw_string(int x, int y, const char *str, uint32_t fg, uint32_t bg);
|
|
void fb_draw_window(int x, int y, int w, int h, const char *title);
|
|
void fb_demo_desktop(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|