Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <sys/ioctl.h>
- #include <sys/mman.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include "frameutils.h"
- int mainloop(FrameBuffer *fb) {
- int active = 1;
- while(active) {
- active = 0;
- }
- return 0;
- }
- int main() {
- FrameBuffer fb; //Framebuffer properties
- fb.fd = open("/dev/fb0", O_RDWR); //Framebuffer device
- ioctl(fb.fd, FBIOGET_VSCREENINFO, &fb.vinfo); //Get variable screen info
- fb.vinfo.grayscale = 0;
- fb.vinfo.bits_per_pixel = 32;
- fb.vinfo.yres_virtual = fb.vinfo.yres * 2;
- if(ioctl(fb.fd, FBIOPUT_VSCREENINFO, &fb.vinfo) == -1) { //Set variable screen info
- perror("App ioctl FBIOPUT_VSCREENINFO");
- return -1;
- }
- ioctl(fb.fd, FBIOGET_VSCREENINFO, &fb.vinfo); //Get variable screen info
- ioctl(fb.fd, FBIOGET_FSCREENINFO, &fb.finfo);
- long screensize = fb.vinfo.yres_virtual * fb.finfo.line_length; //Size needed for allocation.
- fb.fbp = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fb.fd, (off_t)0); //Map fb to memory.
- fill_box(10, 10, 500, 500, &fb, pixel_color(0xff, 0xff, 0x00, &fb));
- printf("Allocated: %d MB (%d bytes).\nReal resolution: %ix%i.\nVirtual resolution: %ix%i.\n", screensize / 1000000, screensize, fb.vinfo.xres, fb.vinfo.yres, fb.vinfo.xres_virtual, fb.vinfo.yres_virtual);
- close(fb.fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement