summaryrefslogtreecommitdiff
path: root/examples/empty_example.c
diff options
context:
space:
mode:
authorLevent Kaya <42411502+lvntky@users.noreply.github.com>2024-11-25 00:44:07 +0300
committerGitHub <noreply@github.com>2024-11-25 00:44:07 +0300
commit8aed83d2e77c006eebf21776487f788ef12216de (patch)
tree14d7dfd2b4c86dcb3b27912513439b4648145733 /examples/empty_example.c
parentff43c66c491b443b7522a3b3d716905ee9732b60 (diff)
parent8650f5e1d7bb72625ae5d6cda2974f6fafa6362d (diff)
Merge pull request #8 from dario-loi/bugfixes
Diffstat (limited to 'examples/empty_example.c')
-rw-r--r--examples/empty_example.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/examples/empty_example.c b/examples/empty_example.c
new file mode 100644
index 0000000..352824a
--- /dev/null
+++ b/examples/empty_example.c
@@ -0,0 +1,53 @@
+#define FBGL_IMPLEMENTATION
+//#define FBGL_HIDE_CURSOR
+#define FBGL_USE_FREETYPE
+#include "fbgl.h"
+
+#include <stdio.h>
+#include <stddef.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;
+}