Lightweight framebuffer library.
PixelFB is a lightweight linux framebuffer library that can draw text, draw rectangles and lines, etc.
It is really simple! Just copy the header file to your current directory and import it like this:
#include "pixelfb.h"fb_open(FBContext *fb) --> Opens the /dev/fb0 device node.
fb_close(FBContext *fb) --> Closes the framebuffer.
fb_putpixel(FBContext *fb, int x, int y, uint32_t color) --> Write a singular pixel.
fb_fill(FBContext *fb, uint32_t color) --> Fills the background with the color.
fb_hline(FBContext *fb,int x,int y,int length,uint32_t color) --> Draws a horizontal line.
fb_vline(FBContext *fb,int x,int y,int length,uint32_t color) --> Draws a vertical line.
fb_rect(FBContext *fb,int x,int y,int w,int h,uint32_t color) --> Draws a rectangle.
fb_draw_char(FBContext *fb, int x, int y, char c, uint32_t color) --> Draws a character.
fb_draw_text(FBContext *fb, int x, int y, const char* text, uint32_t color) --> Draws a whole line of string.#include "pixelfb.h"
#include <stdio.h>
int main() {
FBContext fb; // Required or won't compile
if(fb_open(&fb) != 0) {
perror("fb_open");
return 1;
}
// Fill background gray
fb_fill(&fb, rgb(128,128,128));
// Draw a white rectangle
fb_rect(&fb, 50, 50, 100, 60, rgb(255,255,255));
// Wait for key press so you can see it
getchar();
fb_close(&fb);
return 0;
}