diff options
| author | Levent Kaya <42411502+lvntky@users.noreply.github.com> | 2024-11-24 21:17:01 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-24 21:17:01 +0300 |
| commit | 766962f9970cc3d8ee5b49c8bc987fe14c9eda7c (patch) | |
| tree | 7a6b8abc927b0ef832d677fd80aa255ca7dd0951 /example/empty_example.c | |
| parent | 0898b3d26129f3880223d0d457fe05fd3f6be180 (diff) | |
| parent | f795c9d0bc73dca2cabb36c1889dc99422549def (diff) | |
Merge pull request #6 from dario-loi/master
[FIX] Move all implementation under include guard
Diffstat (limited to 'example/empty_example.c')
| -rw-r--r-- | example/empty_example.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/example/empty_example.c b/example/empty_example.c index aee9232..8c7d32d 100644 --- a/example/empty_example.c +++ b/example/empty_example.c @@ -1,53 +1,53 @@ #define FBGL_IMPLEMENTATION -//#define FBGL_HIDE_CURSOR +// #define FBGL_HIDE_CURSOR #define FBGL_USE_FREETYPE #include "../fbgl.h" -#include <stdio.h> #include <stddef.h> +#include <stdio.h> 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 open framebuffer device\n"); - return -1; - } - int color = 0x00000000; - + printf("version %s\n", fbgl_version_info()); + printf("name %s\n", fbgl_name_info()); - FT_Library library = fbgl_freetype_init(); - if (!library) { - fbgl_destroy(&buffer); - return -1; - } + fbgl_t buffer; + if (fbgl_init("/dev/fb0", &buffer) == -1) { + fprintf(stdout, "Error: could not open framebuffer device\n"); + return -1; + } + int color = 0x00000000; - FT_Face face = fbgl_load_font(library, "../asset/font_2.ttf", 24); // Adjust path and size - if (!face) { - fbgl_freetype_cleanup(library); - fbgl_destroy(&buffer); - return -1; - } + FT_Library library = fbgl_freetype_init(); + if (!library) { + fbgl_destroy(&buffer); + return -1; + } - // Render text to framebuffer - fbgl_render_freetype_text(&buffer, library, face, "Hello, World!", 50, 50); + FT_Face face = fbgl_load_font(library, "../asset/font_2.ttf", + 24); // Adjust path and size + if (!face) { + fbgl_freetype_cleanup(library); + fbgl_destroy(&buffer); + return -1; + } - // Main loop checking for ESC key - int l = 0; - while (1) { - - if (fbgl_check_esc_key()) { - fprintf(stdout, "ESC pressed\n"); - break; - } - //fbgl_set_bg(&buffer, i++); // Set background color to - for(int i = 0x000000; i <= 0xFFFFFF; i++) { - fbgl_set_bg(&buffer, i); + // Render text to framebuffer + fbgl_render_freetype_text(&buffer, library, face, "Hello, World!", 50, + 50); + + // Main loop checking for ESC key + int l = 0; + while (1) { + if (fbgl_check_esc_key()) { + fprintf(stdout, "ESC pressed\n"); + break; + } + // fbgl_set_bg(&buffer, i++); // Set background color to + for (int i = 0x000000; i <= 0xFFFFFF; i++) { + fbgl_set_bg(&buffer, i); + } } - } - fbgl_destroy(&buffer); - return 0; + fbgl_destroy(&buffer); + return 0; } |
