00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "FBlib.h"
00017 #include <stdio.h>
00018 #include <stdlib.h>
00019 #include <time.h>
00020
00021 #define MAX_SECS 30
00022 #define UPDATE_INTERVAL 5
00023
00024 int update;
00025
00026 void sig_alarm(int sig)
00027 {
00028 update=1;
00029
00030 }
00031
00032 int main()
00033 {
00034 FB_pixel col;
00035 int x, xfont, y, yfont;
00036 long start_time, cur_time;
00037 long num_lines = 0;
00038 int dir = 0, cx, cy, radius = 1;
00039
00040 FB_initlib("/dev/fb0");
00041 signal(SIGALRM, sig_alarm);
00042 srandom(time(NULL));
00043 FB_getres(&x, &y);
00044 y -= 20;
00045 yfont = y+2;
00046 xfont = 10;
00047 FB_rectfill(0, y, x, y+20, FB_makecol(0,0,0,0));
00048 alarm(UPDATE_INTERVAL);
00049 start_time = time(NULL);
00050 cur_time = time(NULL);
00051 update = 1;
00052 cx = x/2;
00053 cy = y/2;
00054 while((cur_time - start_time) < MAX_SECS)
00055 {
00056 if(update)
00057 {
00058 update=0;
00059 cur_time = time(NULL);
00060 signal(SIGALRM, sig_alarm);
00061 alarm(UPDATE_INTERVAL);
00062 FB_rectfill(0, y, x, y+20, FB_makecol(0,0,0,0));
00063 FB_printf(xfont, yfont, FB_makecol(255,255,255,0), "This test takes 30 seconds, drawn %g lines/s", (double)num_lines/(cur_time - start_time));
00064 }
00065 if(dir == 0)
00066 {
00067 col=FB_makecol(random()%255,random()%255,random()%255,random()%255);
00068 FB_circle(cx, cy, radius, col);
00069 radius++;
00070 if(radius > x/2)
00071 dir=1;
00072 }
00073 else
00074 {
00075 col=FB_makecol(random()%255,random()%255,random()%255,random()%255);
00076 FB_circle(cx, cy, radius, col);
00077 radius--;
00078 if(radius < 1)
00079 dir=0;
00080 }
00081 num_lines++;
00082 }
00083 FB_clear_screen(FB_makecol(0,0,0,0));
00084 FB_exit();
00085 printf("Drawn %g circles in %d seconds, it's %g circles/s\n", (double)num_lines, MAX_SECS, (double)num_lines/MAX_SECS);
00086 return 0;
00087 }
00088