diff options
Diffstat (limited to 'example')
| -rw-r--r-- | example/.gitignore | 1 | ||||
| -rw-r--r-- | example/empty_example.c | 53 | ||||
| -rw-r--r-- | example/raw_mode.c | 20 | ||||
| -rw-r--r-- | example/rectangle.c | 61 | ||||
| -rw-r--r-- | example/red.c | 14 |
5 files changed, 0 insertions, 149 deletions
diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 567609b..0000000 --- a/example/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/example/empty_example.c b/example/empty_example.c deleted file mode 100644 index 8c7d32d..0000000 --- a/example/empty_example.c +++ /dev/null @@ -1,53 +0,0 @@ -#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; -} diff --git a/example/raw_mode.c b/example/raw_mode.c deleted file mode 100644 index 449a824..0000000 --- a/example/raw_mode.c +++ /dev/null @@ -1,20 +0,0 @@ -#define FBGL_IMPLEMENTATION -#include "../fbgl.h" -#include <stdio.h> - -int main(int argc, char *argv[]) -{ - fbgl_t fb; - fbgl_init("/dev/fb0", &fb); - - fbgl_set_bg(&fb, 0xFFFFFF); - - while (1) { - if (fbgl_check_esc_key()) { - printf("pressed"); - fbgl_set_bg(&fb, 0x000000); - } - } - - return 0; -} diff --git a/example/rectangle.c b/example/rectangle.c deleted file mode 100644 index ecc1afd..0000000 --- a/example/rectangle.c +++ /dev/null @@ -1,61 +0,0 @@ -#define FBGL_IMPLEMENTATION -#include "../fbgl.h" - -int main(int argc, char *argv[]) -{ - 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 the background to white - - fbgl_point_t start = { 100, 100 }; - fbgl_point_t end = { 200, 200 }; - fbgl_draw_rectangle_outline(start, end, 0xFF0000, - &buffer); // Draw red rectangle outline - - fbgl_point_t start2 = { 600, 400 }; - fbgl_point_t end2 = { 800, 800 }; - uint32_t colors[] = { 0xFFC00, 0x00FF00, 0x0000FF, - 0xFF00FF }; // Yellow, Green, Blue, Magenta - size_t color_index = 0; - - // Initial position of the marquee rectangle - int dx = 15; // Horizontal speed - int dy = 8; // Vertical speed - - while (1) { - // Clear the framebuffer (set background) - fbgl_set_bg(&buffer, 0xFFFFFF); - - // Draw the moving filled rectangle - fbgl_draw_rectangle_filled(start2, end2, colors[color_index], - &buffer); - - // Move the filled rectangle by updating its position - start2.x += dx; - end2.x += dx; - start2.y += dy; - end2.y += dy; - - // Reverse direction if the rectangle hits the screen boundary - if (start2.x <= 0 || end2.x >= buffer.width) { - dx = -dx; - color_index++; - } - if (start2.y <= 0 || end2.y >= buffer.height) { - dy = -dy; - color_index++; - } - if (color_index >= 4) { - color_index = 0; - } - - usleep(50000); // Delay to make the animation visible (adjust as needed) - } - - fbgl_destroy(&buffer); - return 0; -} diff --git a/example/red.c b/example/red.c deleted file mode 100644 index 7f64dbd..0000000 --- a/example/red.c +++ /dev/null @@ -1,14 +0,0 @@ -#define FBGL_IMPLEMENTATION -#include "../fbgl.h" -#include <stdio.h> - -int main(int argc, char *argv[]) -{ - fbgl_t fb; - fbgl_init("/dev/fb0", &fb); - fbgl_set_bg(&fb, 0xFF0000); - while (1) { - } - - return 0; -} |
