//
// Created by m on 12/3/21.
//

#ifndef RLA_IIPP_RENDERER_HPP
#define RLA_IIPP_RENDERER_HPP
#include <string>
#include <memory>
#include <ostream>
#include <optional>

struct Color {
public:
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;

    Color(){}

    Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) : r(r), g(g), b(b), a(a) {}
};
#define COLOR_BLACK Color(0, 0, 0, 255)
#define COLOR_WHITE Color(255, 255, 255, 255)

struct SpriteSheet {
    std::string path;
    int sprite_width;
    int sprite_height;
    std::optional<Color> color_key;
};

struct Sprite {
    SpriteSheet *sprite_sheet;
    int index;
};

struct TextRenderDetails {
    std::string font_path;
    int size;
    Color color;

    TextRenderDetails(){};

    TextRenderDetails(const std::string &fontPath, int size, const Color &color) : font_path(
            fontPath), size(size), color(color) {}
};

struct RendererParams {
    std::string title;
    int width;
    int height;
    TextRenderDetails default_font;
};

class Renderer {
public:
    virtual void initialize(RendererParams params)=0;
    virtual void flush() = 0;
    virtual void draw_point(int x, int y, Color color) = 0;
    virtual void draw_text(std::optional<TextRenderDetails> details, std::string text,int x, int y)=0;
    virtual void draw_sprite(Sprite sprite, int x, int y)=0;
};

#endif //RLA_IIPP_RENDERER_HPP
