diff options
| author | Levent Kaya <42411502+lvntky@users.noreply.github.com> | 2024-11-28 01:01:46 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-28 01:01:46 +0300 |
| commit | 8b25ef20ab3ffa29238f8b4bb2c6c0b7ec886caa (patch) | |
| tree | 84f143235b5e1e6f1d9d06764ac35addd4b97f5e /examples/texture.c | |
| parent | eff7f86c4b81e804b13c5606fcc73a6dbfa58677 (diff) | |
| parent | 528209831fc8f188df895acae83174bb81996c96 (diff) | |
Merge pull request #12 from dario-loi/master
Code quality and warning removal
Diffstat (limited to 'examples/texture.c')
| -rw-r--r-- | examples/texture.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/examples/texture.c b/examples/texture.c index afa0985..f3e0f0c 100644 --- a/examples/texture.c +++ b/examples/texture.c @@ -6,19 +6,25 @@ int main(int argc, char **argv) { - // Initialize framebuffer - fbgl_t framebuffer; - if (fbgl_init(NULL, &framebuffer) != 0) { - fprintf(stderr, "Failed to initialize framebuffer.\n"); + if (argc < 2) { + fprintf(stderr, "Usage: %s <texture_path>\n", argv[0]); return EXIT_FAILURE; } // Load a TGA texture const char *texture_path = argv[1]; + fbgl_tga_texture_t *texture = fbgl_load_tga_texture(texture_path); if (!texture) { fprintf(stderr, "Failed to load texture.\n"); - fbgl_destroy(&framebuffer); + + return EXIT_FAILURE; + } + + // Initialize framebuffer + fbgl_t framebuffer; + if (fbgl_init(NULL, &framebuffer) != 0) { + fprintf(stderr, "Failed to initialize framebuffer.\n"); return EXIT_FAILURE; } @@ -55,8 +61,10 @@ int main(int argc, char **argv) texture_y + texture->height >= framebuffer.height) { dy = -dy; // Reverse vertical direction when hitting the top or bottom edge } + nanosleep( + (struct timespec[]){ { 0, (int)5e7 } }, + NULL); // Delay to make the marquee effect visible (adjust as needed) - usleep(50000); // Delay to make the marquee effect visible (adjust as needed) framesize--; } |
