diff options
| author | lvntky <klevent1903@gmail.com> | 2024-11-21 19:25:48 +0300 |
|---|---|---|
| committer | lvntky <klevent1903@gmail.com> | 2024-11-21 19:25:48 +0300 |
| commit | c3514b55109e3fb62de3935e9e09516b289b2845 (patch) | |
| tree | 1d93a297a90b5141022b4b687e6600a5fcb7bed9 /example | |
| parent | 0fa46770ba044b95dd8c253b7d1e12ca324e1556 (diff) | |
[feature] some font loading but not works
Diffstat (limited to 'example')
| -rwxr-xr-x | example/empty_example | bin | 16824 -> 17064 bytes | |||
| -rw-r--r-- | example/empty_example.c | 63 |
2 files changed, 40 insertions, 23 deletions
diff --git a/example/empty_example b/example/empty_example Binary files differindex 8f1efd7..91358c5 100755 --- a/example/empty_example +++ b/example/empty_example diff --git a/example/empty_example.c b/example/empty_example.c index 85aa2eb..6eadd5f 100644 --- a/example/empty_example.c +++ b/example/empty_example.c @@ -7,27 +7,44 @@ int main() { - printf("version %s\n", fbgl_version_info()); - printf("name %s\n", fbgl_name_info()); - fbgl_t buffer; - if (fbgl_init("/dev/fb0", &buffer) == -1) { - fprintf(stdout, "error could not oppen fb device"); - return -1; - } - fbgl_set_bg(&buffer, 0xFF0000); - - for (size_t i = 0; i < 100; ++i) { - for (size_t j = 0; j < 100; ++j) { - fbgl_put_pixel(i, j, 0x00FFFF, &buffer); - } - } - int l = 0; - while (1) { - if(fbgl_check_esc_key()) { - fprintf(stdout, "esc pressed", fbgl_check_esc_key()); - - } - } - - return 0; + printf("version %s\n", fbgl_version_info()); + printf("name %s\n", fbgl_name_info()); + + fbgl_t buffer; + if (fbgl_init("/dev/fb0", &buffer) == -1) { + fprintf(stdout, "Error: could not open framebuffer device\n"); + return -1; + } + + fbgl_set_bg(&buffer, 0xFFFFFF); // Set background color to red + + + + // Load the PSF2 font + fbgl_psf2_header_t *font = fbgl_load_psf2_font("../asset/font.psf"); + if (!font) { + fprintf(stderr, "Error: failed to load PSF2 font.\n"); + fbgl_destroy(&buffer); + return -1; + } + + printf("Loaded PSF2 Font: %d glyphs, %dx%d px per character\n", font->numglyphs, font->width, font->height); + + // Render sample text + fbgl_render_text(&buffer, buffer.width, buffer.height, 100, 100, "Hello, framebuffer!", font); + + // Main loop checking for ESC key + int l = 0; + while (1) { + if (fbgl_check_esc_key()) { + fprintf(stdout, "ESC pressed\n"); + break; + } + } + + // Free the font memory + fbgl_free_psf2_font(font); + + fbgl_destroy(&buffer); + return 0; } |
