Home | History | Annotate | Download | only in test
      1 #ifdef __STRICT_ANSI__
      2 #define _BSD_SOURCE
      3 #endif
      4 #include <rfb/rfb.h>
      5 #include <math.h>
      6 
      7 static void initBackground(rfbScreenInfoPtr server)
      8 {
      9   unsigned int i,j;
     10 
     11   for(i=0;i<server->width;i++)
     12     for(j=0;j<server->height;j++) {
     13       server->frameBuffer[(j*server->width+i)*4+0]=i&0xff;
     14       server->frameBuffer[(j*server->width+i)*4+1]=j&0xff;
     15       server->frameBuffer[(j*server->width+i)*4+2]=(i*j)&0xff;
     16     }
     17 }
     18 
     19 int main(int argc,char** argv)
     20 {
     21   int width=400,height=300,w=20,x,y;
     22   double r,phi=0;
     23 
     24   rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4);
     25   if(!server)
     26     return 0;
     27   server->frameBuffer=(char*)malloc(width*height*4);
     28   initBackground(server);
     29   server->deferUpdateTime=0;
     30   rfbInitServer(server);
     31 
     32   r=0;
     33   while(1) {
     34     if(r<=0) {
     35       initBackground(server);
     36       rfbMarkRectAsModified(server,0,0,width,height);
     37       r=0.43;
     38       phi=0;
     39     } else {
     40       r-=0.0001;
     41       phi+=0.02;
     42       if(phi>2*M_PI)
     43 	phi-=2*M_PI;
     44     }
     45     x=width*(0.5+cos(phi)*r);
     46     y=height*(0.5+sin(phi)*r);
     47     if(x>=0 && y>=0 && x+w<=width && y+w<=height) {
     48       unsigned int dx=width*0.5*(1-cos(phi)*r)-x,
     49       		dy=height*0.5*(1-sin(phi)*r)-y;
     50       rfbDoCopyRect(server,x,y,x+w,y+w,-dx,-dy);
     51     }
     52     rfbProcessEvents(server,50000);
     53   }
     54   return(0);
     55 }
     56