eobish
annotate src/main.cc @ 2:cdbcae5b3b98
added fblib
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 18 Jan 2015 03:16:37 +0200 |
parents | 465ca72c9657 |
children |
rev | line source |
---|---|
nuclear@0 | 1 #include <stdio.h> |
nuclear@2 | 2 #include "fblib.h" |
nuclear@0 | 3 |
nuclear@0 | 4 static void display(); |
nuclear@0 | 5 |
nuclear@0 | 6 int main(int argc, char **argv) |
nuclear@0 | 7 { |
nuclear@2 | 8 if(fb_init(320, 240, 8) == -1) { |
nuclear@0 | 9 return 1; |
nuclear@0 | 10 } |
nuclear@2 | 11 fb_set_palette_entry(1, 255, 0, 0); |
nuclear@0 | 12 |
nuclear@0 | 13 for(;;) { |
nuclear@2 | 14 if(fb_process_events() == -1) { |
nuclear@2 | 15 break; |
nuclear@0 | 16 } |
nuclear@0 | 17 display(); |
nuclear@0 | 18 } |
nuclear@0 | 19 |
nuclear@0 | 20 done: |
nuclear@2 | 21 fb_shutdown(); |
nuclear@0 | 22 return 0; |
nuclear@0 | 23 } |
nuclear@0 | 24 |
nuclear@0 | 25 void display() |
nuclear@0 | 26 { |
nuclear@2 | 27 int width = fb_get_width(); |
nuclear@2 | 28 int height = fb_get_height(); |
nuclear@2 | 29 unsigned char *pixels = (unsigned char*)fb_begin_frame(); |
nuclear@0 | 30 |
nuclear@2 | 31 for(int i=0; i<width * height; i++) { |
nuclear@0 | 32 *pixels++ = 1; |
nuclear@0 | 33 } |
nuclear@0 | 34 |
nuclear@2 | 35 fb_end_frame(); |
nuclear@0 | 36 } |