diff options
| author | dario-loi <loi.1940849@studenti.uniroma1.it> | 2024-11-24 20:21:45 +0100 |
|---|---|---|
| committer | dario-loi <loi.1940849@studenti.uniroma1.it> | 2024-11-24 20:21:45 +0100 |
| commit | a3bfd065071e2dd4e772fae9da7908ce523148c6 (patch) | |
| tree | 68b062d79a1b5e59c2bcba2ca8df1cef9852f656 /example/empty_example.c | |
| parent | 274cacc5fadb3c3a220b833f027eee47cbda824c (diff) | |
| parent | cd0a47245a54c249eca7ef1c0d86bc4aa3489e9b (diff) | |
Merge branch 'master' into bugfixes
Diffstat (limited to 'example/empty_example.c')
| -rw-r--r-- | example/empty_example.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/example/empty_example.c b/example/empty_example.c new file mode 100644 index 0000000..8c7d32d --- /dev/null +++ b/example/empty_example.c @@ -0,0 +1,53 @@ +#define FBGL_IMPLEMENTATION +// #define FBGL_HIDE_CURSOR +#define FBGL_USE_FREETYPE +#include "../fbgl.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; + + FT_Library library = fbgl_freetype_init(); + if (!library) { + fbgl_destroy(&buffer); + return -1; + } + + 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; + } + + // 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; +} |
