{"id":19645895,"url":"https://github.com/vvaltchev/tfblib","last_synced_at":"2025-06-30T23:36:44.385Z","repository":{"id":43752112,"uuid":"148843047","full_name":"vvaltchev/tfblib","owner":"vvaltchev","description":"A Tiny Linux Framebuffer Library","archived":false,"fork":false,"pushed_at":"2023-01-21T21:09:04.000Z","size":376,"stargazers_count":113,"open_issues_count":0,"forks_count":21,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-06-08T18:48:47.793Z","etag":null,"topics":["c","framebuffer","library","linux"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vvaltchev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-14T21:21:28.000Z","updated_at":"2025-06-01T18:29:38.000Z","dependencies_parsed_at":"2023-02-12T12:45:53.729Z","dependency_job_id":null,"html_url":"https://github.com/vvaltchev/tfblib","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/vvaltchev/tfblib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaltchev%2Ftfblib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaltchev%2Ftfblib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaltchev%2Ftfblib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaltchev%2Ftfblib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vvaltchev","download_url":"https://codeload.github.com/vvaltchev/tfblib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaltchev%2Ftfblib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262869327,"owners_count":23377277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","framebuffer","library","linux"],"created_at":"2024-11-11T14:35:47.550Z","updated_at":"2025-06-30T23:36:44.347Z","avatar_url":"https://github.com/vvaltchev.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tfblib (Tiny Framebuffer Library)\n\n![Build](https://github.com/vvaltchev/tfblib/workflows/Linux/badge.svg)\n[![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://vvaltchev.github.io/tfblib/tfblib_8h.html)\n[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)\n\n`Tfblib` is a simple and low-level graphics library for drawing to the Linux\nframebuffer. Currently, it is capable of drawing lines, rectangles and text.\nIt has support both for embedded (compiled-in) fonts in the library and\ndynamically loaded `PSF` fonts at runtime. In addition to drawing functions,\n`Tfblib` has a minimal support for keyboard input that allows simple\napplications to put the TTY input in *raw mode* and read keystrokes. Both\nblocking and non-blocking modes are supported.\n\n![Drawing example](other/drawing.png)\n![Drawing text example](other/text.png)\n\nBuilding\n---------\n\nBuilding `Tfblib` as a static library is simple as executing (in project's root\ndirectory):\n\n```\n$ mkdir build\n$ cd build\n$ cmake ..\n$ make\n```\nThe `make` command will build the library along with the programs in the\nexamples/ directory. In case a release build (with optimizations) is desired,\nthe `cmake` command has to be run this way (assuming the current working\ndirectory is the build directory):\n\n    cmake -DCMAKE_BUILD_TYPE=Release ..\n\nOr:\n\n    cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n\nIn case a release build with debug info is desired.\n\nA \"hello world\" application\n-----------------------------\n\nUsing `Tfblib` is extremely simple. Here below, there's an example about how\nto initialize the library and draw a rectangle at the center of the screen.\n\n```C\n#include \u003cstdio.h\u003e\n#include \u003ctfblib/tfblib.h\u003e\n#include \u003ctfblib/tfb_colors.h\u003e\n\nint main(int argc, char **argv)\n{\n   int rc;\n\n   if ((rc = tfb_acquire_fb(0, NULL, NULL)) != TFB_SUCCESS) {\n      fprintf(stderr, \"tfb_acquire_fb() failed with error code: %d\\n\", rc);\n      return 1;\n   }\n\n   uint32_t w = tfb_screen_width();\n   uint32_t h = tfb_screen_height();\n   uint32_t rect_w = w / 2;\n   uint32_t rect_h = h / 2;\n\n   /* Paint the whole screen in black */\n   tfb_clear_screen(tfb_black);\n\n   /* Draw some text on-screen */\n   tfb_draw_string(10, 10, tfb_white, tfb_black, \"Press ENTER to quit\");\n\n   /* Draw a red rectangle at the center of the screen */\n   tfb_draw_rect(w / 2 - rect_w / 2,  /* x coordinate */\n                 h / 2 - rect_h / 2,  /* y coordinate */\n                 rect_w,              /* width */\n                 rect_h,              /* height */\n                 tfb_red              /* color */);\n\n   getchar();\n   tfb_release_fb();\n   return 0;\n}\n```\n\nCompatibility\n--------------\n\n`Tfblib` has been designed to work on the `Linux` kernel, on any hardware. It has\nbeen tested on `x86` and on `ARM` machines (Raspberry Pi 3). It addition to that,\nit works on [Tilck](https://github.com/vvaltchev/tilck), which is a small Linux\ncompatible kernel.\n\n![Tetris on Tilck](other/tetris.png)\n\nIn order to compile `Tfblib` for `Tilck` is necessary to use a 32-bit x86\nLinux `GCC` toolchian using `libmusl` and link everything statically. After\ncompiling this way, the examples will run both on Linux and on Tilck natively.\nBut, the **easiest way** to do that is just to use Tilck's build system.\nJust drop a copy (or a symlink) of `Tfblib`'s main directory in the following\nsubdirectory of the `Tilck` project:\n\n```\nuserapps/extra\n```\n\nThan just run:\n\n```\n$ ./scripts/cmake_run\n```\n\nAnd finally build Tilck with `make`. The `Tfblib` examples will be visible in\n`/usr/bin/`, on Tilck.\n\nLimitations\n-------------\n\nFor the moment, the library supports only 32-bpp video modes.\n\nOnline API reference\n----------------------\n\nA pre-generated `doxygen` documentation is available at:\nhttps://vvaltchev.github.io/tfblib/tfblib_8h.html\n\n\nGenerating the documentation locally\n--------------------------------------\n\nIn order to generate the documentation locally, make sure you have `doxygen`\ninstalled on your system and just run it in project's root directory.\nThe output html files will be placed in `\u003cPROJECT_ROOT_DIR\u003e/doxydocs/html`.\nJust open `index.html` with your browser.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvaltchev%2Ftfblib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvaltchev%2Ftfblib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvaltchev%2Ftfblib/lists"}