2021-12-29 16:21:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-05 16:45:52 +01:00
|
|
|
#include "schrift.h"
|
2021-12-29 16:21:14 +01:00
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
// visible screen sizes
|
2022-02-03 14:08:08 +01:00
|
|
|
#define SCREEN_WIDTH 854
|
2021-12-29 16:21:14 +01:00
|
|
|
#define SCREEN_HEIGHT 480
|
|
|
|
|
|
|
|
union Color {
|
2023-01-05 16:45:52 +01:00
|
|
|
explicit Color(uint32_t color) {
|
2022-02-02 19:12:52 +01:00
|
|
|
this->color = color;
|
2021-12-29 16:21:14 +01:00
|
|
|
}
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
|
|
|
this->r = r;
|
|
|
|
this->g = g;
|
|
|
|
this->b = b;
|
|
|
|
this->a = a;
|
2021-12-29 16:21:14 +01:00
|
|
|
}
|
|
|
|
|
2023-01-05 16:45:52 +01:00
|
|
|
uint32_t color{};
|
2021-12-29 16:21:14 +01:00
|
|
|
struct {
|
|
|
|
uint8_t r;
|
|
|
|
uint8_t g;
|
|
|
|
uint8_t b;
|
|
|
|
uint8_t a;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class DrawUtils {
|
|
|
|
public:
|
2022-02-02 19:12:52 +01:00
|
|
|
static void initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void beginDraw();
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void endDraw();
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void clear(Color col);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void drawPixel(uint32_t x, uint32_t y, Color col) { drawPixel(x, y, col.r, col.g, col.b, col.a); }
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
|
|
|
|
|
|
|
static void drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col);
|
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static void drawPNG(uint32_t x, uint32_t y, const uint8_t *data);
|
2021-12-29 16:21:14 +01:00
|
|
|
|
2023-01-05 16:45:52 +01:00
|
|
|
static bool initFont();
|
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void deinitFont();
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void setFontSize(uint32_t size);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2021-12-29 16:21:14 +01:00
|
|
|
static void setFontColor(Color col);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static void print(uint32_t x, uint32_t y, const char *string, bool alignRight = false);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static void print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight = false);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static uint32_t getTextWidth(const char *string);
|
2023-01-05 16:45:52 +01:00
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static uint32_t getTextWidth(const wchar_t *string);
|
2021-12-29 16:21:14 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static bool isBackBuffer;
|
|
|
|
|
2022-02-02 19:12:52 +01:00
|
|
|
static uint8_t *tvBuffer;
|
2021-12-29 16:21:14 +01:00
|
|
|
static uint32_t tvSize;
|
2022-02-02 19:12:52 +01:00
|
|
|
static uint8_t *drcBuffer;
|
2021-12-29 16:21:14 +01:00
|
|
|
static uint32_t drcSize;
|
|
|
|
};
|