summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--examples/keyboard.c91
-rw-r--r--examples/raw_mode.c20
-rw-r--r--examples/texture.c6
-rw-r--r--examples/texture_show_fps.c16
5 files changed, 6 insertions, 131 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50a4e39..fad5d22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,9 +27,7 @@ add_example(line)
add_example(rectangle)
add_example(red)
add_example(texture)
-add_example(raw_mode)
add_example(framebuf_info)
add_example(text)
add_example(texture_show_fps)
-add_example(keyboard)
-add_example(circle) \ No newline at end of file
+add_example(circle)
diff --git a/examples/keyboard.c b/examples/keyboard.c
deleted file mode 100644
index 51a488e..0000000
--- a/examples/keyboard.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <stdio.h>
-#include <stdbool.h>
-#define FBGL_IMPLEMENTATION
-#include "fbgl.h"
-
-#define RECT_WIDTH 50
-#define RECT_HEIGHT 30
-#define MOVE_STEP 10
-#define BG_COLOR 0x000000 // Black
-#define RECT_COLOR 0xFFFFFF // White
-
-int main(void)
-{
- // Initialize framebuffer
- fbgl_t framebuffer;
- if (fbgl_init(NULL, &framebuffer) != 0) {
- fprintf(stderr, "Failed to initialize framebuffer\n");
- return EXIT_FAILURE;
- }
-
- // Initialize keyboard
- if (fbgl_keyboard_init() != 0) {
- fprintf(stderr, "Failed to initialize keyboard\n");
- fbgl_destroy(&framebuffer);
- return EXIT_FAILURE;
- }
-
- atexit(fbgl_keyboard_clean); // Cleanup on exit
- atexit((void (*)(void))fbgl_destroy, &framebuffer);
-
- // Initial rectangle position
- fbgl_point_t top_left = {framebuffer.width / 2 - RECT_WIDTH / 2, framebuffer.height / 2 - RECT_HEIGHT / 2};
- fbgl_point_t bottom_right = {top_left.x + RECT_WIDTH, top_left.y + RECT_HEIGHT};
-
- // Main loop
- while (!fbgl_check_esc_key()) {
- // Update keyboard state
- fbgl_keyboard_update();
-
- // Clear screen
- fbgl_set_bg(&framebuffer, BG_COLOR);
-
- // Move rectangle based on key input
- if (fbgl_key_down('w')) {
- top_left.y -= MOVE_STEP;
- bottom_right.y -= MOVE_STEP;
- }
- if (fbgl_key_down('s')) {
- top_left.y += MOVE_STEP;
- bottom_right.y += MOVE_STEP;
- }
- if (fbgl_key_down('a')) {
- top_left.x -= MOVE_STEP;
- bottom_right.x -= MOVE_STEP;
- }
- if (fbgl_key_down('d')) {
- top_left.x += MOVE_STEP;
- bottom_right.x += MOVE_STEP;
- }
-
- // Ensure rectangle stays within screen bounds
- if (top_left.x < 0) {
- top_left.x = 0;
- bottom_right.x = RECT_WIDTH;
- }
- if (top_left.y < 0) {
- top_left.y = 0;
- bottom_right.y = RECT_HEIGHT;
- }
- if (bottom_right.x > framebuffer.width) {
- bottom_right.x = framebuffer.width;
- top_left.x = framebuffer.width - RECT_WIDTH;
- }
- if (bottom_right.y > framebuffer.height) {
- bottom_right.y = framebuffer.height;
- top_left.y = framebuffer.height - RECT_HEIGHT;
- }
-
- // Draw the rectangle
- fbgl_draw_rectangle_filled(top_left, bottom_right, RECT_COLOR, &framebuffer);
-
- // Refresh frame (add a delay if needed)
- usleep(16000); // ~60 FPS
- }
-
- // Cleanup
- fbgl_keyboard_clean();
- fbgl_destroy(&framebuffer);
-
- return EXIT_SUCCESS;
-}
diff --git a/examples/raw_mode.c b/examples/raw_mode.c
deleted file mode 100644
index de97e78..0000000
--- a/examples/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/examples/texture.c b/examples/texture.c
index 75a67d7..afa0985 100644
--- a/examples/texture.c
+++ b/examples/texture.c
@@ -60,12 +60,6 @@ int main(int argc, char **argv)
framesize--;
}
- // Wait for the user to press the escape key before exiting
- printf("Press ESC to exit...\n");
- while (!fbgl_check_esc_key()) {
- // You can add additional rendering logic here if needed
- }
-
// Clean up
fbgl_destroy_texture(texture);
fbgl_destroy(&framebuffer);
diff --git a/examples/texture_show_fps.c b/examples/texture_show_fps.c
index 0b079c7..90ddc4f 100644
--- a/examples/texture_show_fps.c
+++ b/examples/texture_show_fps.c
@@ -50,7 +50,6 @@ int main(int argc, char **argv)
fbgl_psf1_font_t *font = fbgl_load_psf1_font(argv[2]);
while (framesize) {
-
// Clear the framebuffer (set background)
fbgl_set_bg(&framebuffer, 0x000000);
@@ -71,23 +70,18 @@ int main(int argc, char **argv)
if (texture_y <= 0 ||
texture_y + texture->height >= framebuffer.height) {
dy = -dy; // Reverse vertical direction when hitting the top or bottom edge
- }
+ }
-
- fbgl_render_psf1_text(&framebuffer, font, "FPS: ", 5, 0, 0xFF0000);
+ fbgl_render_psf1_text(&framebuffer, font, "FPS: ", 5, 0,
+ 0xFF0000);
char *fps = float_to_string(fbgl_get_fps());
- fbgl_render_psf1_text(&framebuffer, font, fps, 100, 0, 0xFF0000);
+ fbgl_render_psf1_text(&framebuffer, font, fps, 100, 0,
+ 0xFF0000);
usleep(50000); // Delay to make the marquee effect visible (adjust as needed)
framesize--;
}
- // Wait for the user to press the escape key before exiting
- printf("Press ESC to exit...\n");
- while (!fbgl_check_esc_key()) {
- // You can add additional rendering logic here if needed
- }
-
// Clean up
fbgl_destroy_texture(texture);
fbgl_destroy(&framebuffer);