Added unproject

Broken and buggy font stuff
Fixed some typos
Fixed draw rect not using dim properly
This commit is contained in:
2025-10-05 21:11:18 +01:00
parent 5cabf845b6
commit eb3c81cd04
11 changed files with 349 additions and 22 deletions

View File

@@ -3,6 +3,29 @@
#define D_MAX_RECTS (262144)
typedef struct D_Glyph D_Glyph;
struct D_Glyph {
F32 advance;
V2f offset;
R2f box;
};
typedef struct D_Font D_Font;
struct D_Font {
D_Font *next;
F32 px;
F32 line_advance;
F32 ascent;
F32 descent;
F32 *kerning;
D_Glyph *glyphs;
Vk_Image image;
};
typedef struct D_Image D_Image;
struct D_Image {
Str8 name;
@@ -30,6 +53,9 @@ struct G_Camera;
typedef struct D_Context D_Context;
struct D_Context {
Vk_Buffer *rbo;
Vk_Buffer staging;
M_Arena *arena;
U32 n_pipelines;
Vk_Pipeline *pipelines;
@@ -37,6 +63,9 @@ struct D_Context {
U32 n_images;
D_Image *images;
U32 n_fonts;
D_Font *fonts;
U32 max_rects;
U32 n_rects;
D_Rect *rects;
@@ -65,9 +94,15 @@ struct D_RectOpts {
F32 angle;
union {
F32 w, h;
F32 scale, _h;
V2f dim;
struct {
F32 w, h;
};
struct {
F32 scale, _h;
};
};
union {
@@ -79,7 +114,11 @@ struct D_RectOpts {
function void D_Begin(D_Context *draw, Vk_Frame *frame, U32 max_rects);
function void D_End(D_Context *draw, Vk_Frame *frame);
function void D_Text(D_Context *draw, D_Font *font, Str8 text, F32 x, F32 y);
function void _D_Rect(D_Context *draw, D_RectOpts *opts);
#define D_Rect(draw, x, y, ...) _D_Rect(draw, &(D_RectOpts) { .p = V2F(x, y), .uv = R2F(V2F(0, 0), V2F(1, 1)), .scale = 1, .c = V4F(1, 1, 1, 1), ##__VA_ARGS__ })
function void D_FontLoad(D_Context *draw, Str8 path, F32 size);
#endif // LD_DRAW_CORE_H_