From d2448d151edad03fb2ca2274cb02426f5fb69582 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 19 May 2024 11:39:07 -0400 Subject: add font loading and rendering to daguerre --- applications/init/source/main.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'applications') diff --git a/applications/init/source/main.cpp b/applications/init/source/main.cpp index 6aa85a4..c5df77c 100644 --- a/applications/init/source/main.cpp +++ b/applications/init/source/main.cpp @@ -1,9 +1,9 @@ #include -void overlay_encode( +void alpha_overlay( daguerre::hilbert_color &dest, const daguerre::rgb24 &src) { if (src.r != 0xff || src.g != 0x00 || src.b != 0xff) - daguerre::encode(dest, src); + daguerre::default_overlay(dest, src); } void invert(daguerre::rgb24 &dest, const daguerre::rgb24 &src) { @@ -17,14 +17,15 @@ int main(int, char **) { auto framebuffer = daguerre::get_hilbert_framebuffer(); daguerre::image burden; - std::FILE *burden_file = std::fopen("/assets/burden.ppm", "r"); - daguerre::try_load_ppm(burden_file, burden); - std::fclose(burden_file); + daguerre::try_load_ppm("/assets/burden.ppm", burden); daguerre::image pointer; - std::FILE *pointer_file = std::fopen("/assets/pointer.ppm", "r"); - daguerre::try_load_ppm(pointer_file, pointer); - std::fclose(pointer_file); + daguerre::try_load_ppm("/assets/pointer.ppm", pointer); + + daguerre::fixed_bitmap_font terminus; + daguerre::try_load_psf("/assets/terminus-bold-18x10.psf", terminus); + + terminus.overlay_text<>(burden, 0, 0, "this is a test"); int32_t width = burden.width < framebuffer.width ? burden.width : framebuffer.width; @@ -39,9 +40,7 @@ int main(int, char **) { int32_t old_mouse_y = new_mouse_y; bool was_left_mouse_down = false; - daguerre::overlay_region< - daguerre::hilbert_color, daguerre::rgb24, daguerre::encode>( - framebuffer, x, y, burden, 0, 0, width, height); + daguerre::overlay_region<>(framebuffer, x, y, burden, 0, 0, width, height); while (1) { @@ -96,8 +95,7 @@ int main(int, char **) { daguerre::overlay_region( burden, 0, 0, burden, 0, 0, width, height); - daguerre::overlay_region< - daguerre::hilbert_color, daguerre::rgb24, daguerre::encode>( + daguerre::overlay_region<>( framebuffer, x, y, burden, 0, 0, width, height); anything_changed = true; @@ -105,12 +103,11 @@ int main(int, char **) { } if (anything_changed) { - daguerre::overlay_region< - daguerre::hilbert_color, daguerre::rgb24, daguerre::encode>( + daguerre::overlay_region<>( framebuffer, old_mouse_x + x, old_mouse_y + y, burden, old_mouse_x, old_mouse_y, pointer.width, pointer.height); daguerre::overlay_region< - daguerre::hilbert_color, daguerre::rgb24, overlay_encode>( + daguerre::hilbert_color, daguerre::rgb24, alpha_overlay>( framebuffer, new_mouse_x + x, new_mouse_y + y, pointer, 0, 0, pointer.width, pointer.height); } -- cgit v1.2.3