summaryrefslogtreecommitdiff
path: root/applications/init/source/main.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-05-19 11:39:07 -0400
committerBenji Dial <benji@benjidial.net>2024-05-19 11:39:07 -0400
commitd2448d151edad03fb2ca2274cb02426f5fb69582 (patch)
treef5e92bf96fe3a87068a9365d693456d258c22180 /applications/init/source/main.cpp
parent17c1bd441de115720d7c6758550c49c1b4689900 (diff)
downloadhilbert-os-d2448d151edad03fb2ca2274cb02426f5fb69582.tar.gz
add font loading and rendering to daguerre
Diffstat (limited to 'applications/init/source/main.cpp')
-rw-r--r--applications/init/source/main.cpp29
1 files changed, 13 insertions, 16 deletions
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 <daguerre.hpp>
-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<daguerre::rgb24> 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<daguerre::rgb24> 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<bool> 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<daguerre::rgb24, daguerre::rgb24, invert>(
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);
}