#pragma once

#include "base/base_core.h"

struct Renderer;
struct Clay_RenderCommandArray;

struct RendererDesc {
    void    *window_handle = nullptr;
    S32  width         = 1280;
    S32  height        = 720;
    S32  frame_count   = 2;
};

Renderer *renderer_create(RendererDesc *desc);
void      renderer_destroy(Renderer *renderer);
B32       renderer_begin_frame(Renderer *renderer);
void      renderer_end_frame(Renderer *renderer, Clay_RenderCommandArray render_commands);
void      renderer_resize(Renderer *renderer, S32 width, S32 height);
void      renderer_set_font_scale(Renderer *renderer, F32 scale);
void      renderer_set_clear_color(Renderer *renderer, F32 r, F32 g, F32 b);

// Text measurement callback compatible with UI_MeasureTextFn
// Measures text of given length (NOT necessarily null-terminated) at font_size pixels.
// user_data should be the Renderer pointer.
struct Vec2F32;
Vec2F32 renderer_measure_text(const char *text, S32 length, F32 font_size, void *user_data);

// Upload an RGBA8 icon atlas texture for icon rendering (4 bytes per pixel)
void renderer_create_icon_atlas(Renderer *renderer, const U8 *data, S32 w, S32 h);
