win32 drawing text

This commit is contained in:
Krzosa Karol
2025-01-08 09:34:53 +01:00
parent 7c282bacb2
commit 189902dae6
17 changed files with 11794 additions and 46 deletions

View File

@@ -3,7 +3,13 @@
#include "core/core_inc.c"
#include "app/app.c"
#include "gfx2d/gfx2d.c"
#define STB_TRUETYPE_IMPLEMENTATION
#include "render/stb_truetype.h"
#include "render/backup_font.c"
#include "render/font.c"
#include "render/render_opengl.c"
// #include "gfx2d/gfx2d.c"
#include "ui.c"
@@ -19,7 +25,7 @@
typedef struct globals_t globals_t;
struct globals_t {
gfx_t *gfx;
// gfx_t *gfx;
app_event_t event;
};
gb globals_t *globals;
@@ -30,28 +36,11 @@ fn void app_init(void) {
ma_arena_t *perm = &tcx._perm;
globals = ma_push_type(perm, globals_t);
globals->gfx = ma_push_type(perm, gfx_t);
// globals->gfx = ma_push_type(perm, gfx_t);
rn_init(perm);
ui_init(perm);
}
#if 0
ui_begin_expander("app_event_t");
{
ui_edit_enum("kind: app_event_kind_t = %S");
ui_begin_expander("mouse_wheel_delta: v3f64_t");
{
ui_edit_f64(&x, "x: %f", x);
ui_edit_f64(&y, "y: %f", y);
ui_edit_f64(&z, "z: %f", z);
}
ui_end_expander();
}
ui_end_expander();
#endif
fn b32 app_update(app_event_list_t events) {
ui_begin_frame();
defer_block(ui_begin_build(), ui_end_build()) {
@@ -104,6 +93,15 @@ fn b32 app_update(app_event_list_t events) {
}
{
app_event_t *ev = events.last;
rn_begin(v2f64_to_v2f32(ev->window_size));
rn_base_draw_string(&rn_state.main_font, s8_lit("hello world!"), v2f32(0,0), black_color_global, true);
rn_end(v2f64_to_v2f32(ev->window_size), white_color_global);
}
#if 0
// These steps should be totally optional!!
{
app_event_t *ev = events.last;
@@ -137,6 +135,7 @@ fn b32 app_update(app_event_list_t events) {
ui_draw(globals->gfx);
gfx_end(globals->gfx);
}
#endif
ui_end_frame();
return false;

View File

@@ -72,7 +72,7 @@ ui_box_t *ui_alloc_box(ui_id_t id) {
void ui_init(ma_arena_t *arena) {
assert(ui->box_arena != tcx.temp);
assert(arena != tcx.temp);
ui = ma_push_type(arena, ui_t);
ui->box_arena = arena;
@@ -277,6 +277,7 @@ void ui_end_frame(void) {
}
}
#if 0
void ui_draw(gfx_t *gfx) {
// compute standalone sizes: (pixels, text_content)
for (ui_preorder_iter_t it = ui_iterate_preorder(ui->root); ui_preorder_iter_is_valid(it); ui_iter_advance_preorder(&it)) {
@@ -310,4 +311,5 @@ void ui_draw(gfx_t *gfx) {
ui_box_t *box = it.box;
}
}
}
#endif