summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorLevent Kaya <42411502+lvntky@users.noreply.github.com>2024-11-24 15:52:47 +0300
committerGitHub <noreply@github.com>2024-11-24 15:52:47 +0300
commitbd57db823e34d6522e33adb37692f988a4e606ef (patch)
treee5485cccfab864d90f327bb2e5a911c08fcfa224 /README.md
parent5813f6a1c2b83d1c2a115d87ca684c5d1e11e299 (diff)
parentf1cde5cdc57e18a455859582ee2fd56b6e61c714 (diff)
Merge pull request #5 from dario-loi/master
[docs] Fixed example code in README.md
Diffstat (limited to 'README.md')
-rw-r--r--README.md23
1 files changed, 15 insertions, 8 deletions
diff --git a/README.md b/README.md
index d324714..a564393 100644
--- a/README.md
+++ b/README.md
@@ -25,9 +25,11 @@
### Installation
-No installation is required! Simply copy the `fbgl.h` file into your project directory and include it in your source files.
+No installation is required! Simply copy the `fbgl.h` file into your project directory and include it in your source files,
+while also defining the `FBGL_IMPLEMENTATION` macro in one of your source files.
```c
+#define FBGL_IMPLEMENTATION
#include "fbgl.h"
```
@@ -40,31 +42,36 @@ No installation is required! Simply copy the `fbgl.h` file into your project dir
Here’s a simple program that initializes the framebuffer, clears it to a blue color, and draws a red diagonal line.
```c
-#include <stdio.h>
#include "fbgl.h"
+#define FBGL_IMPLEMENTATION
+#include <stdio.h>
+
+int main()
+{
+
+ fbgl_t buffer;
-int main() {
// Initialize the framebuffer
- if (fbgl_init("/dev/fb0") != 0) {
+ if (fbgl_init("/dev/fb0", &buffer) != 0) {
fprintf(stderr, "Failed to initialize framebuffer\n");
return 1;
}
- printf("Framebuffer size: %dx%d\n", fbgl_get_width(), fbgl_get_height());
+ printf("Framebuffer size: %dx%d\n", fb_get_width(), fb_get_height());
// Clear framebuffer to blue
fbgl_clear(0x0000FFFF); // Blue color
// Draw a red diagonal line
- for (int i = 0; i < fbgl_get_width() && i < fbgl_get_height(); i++) {
- fbgl_put_pixel(i, i, 0xFFFF0000); // Red
+ for (int i = 0; i < fb_get_width() && i < fb_get_height(); i++) {
+ fbgl_put_pixel(i, i, 0xFFFF0000, &buffer); // Red
}
// Wait for user input before exiting
getchar();
// Clean up
- fbgl_destroy();
+ fbgl_destroy(&buffer);
return 0;
}
```