buf size redueced to 1000 again
[my-code/ivac.git] / dfb_api.c
1 /*
2  * dfb_api.c - api to dfb interface
3  */
4
5 /* std includes */
6 #include <stdio.h>
7 #include <unistd.h>
8
9 /* dfb includes */
10 #include <directfb.h>
11
12 /* global stuff */
13
14 /* well ... */
15 static IDirectFB *dfb = NULL;
16 /* surface */
17 static IDirectFBSurface *primary = NULL;
18 static int screen_width  = 0;
19 static int screen_height = 0;
20 static IDirectFBSurface *logo = NULL;
21 /* image to load */
22 char dfb_image[]="./images/ivac_logo.png";
23
24 int main (int argc, char **argv) {
25   int i;
26   DFBSurfaceDescription dsc;
27   /* image provider */
28   IDirectFBImageProvider *provider;
29
30   /* init */
31   DirectFBInit (&argc, &argv);
32   DirectFBCreate (&dfb);
33   dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN);
34   dsc.flags=DSDESC_CAPS;
35   dsc.caps=DSCAPS_PRIMARY | DSCAPS_FLIPPING;
36   dfb->CreateSurface(dfb,&dsc,&primary);
37   primary->GetSize(primary,&screen_width,&screen_height);
38   printf("debug: w/h = %d / %d\n",screen_width,screen_height);
39
40   /* create the imag provider */
41   dfb->CreateImageProvider(dfb,dfb_image,&provider);
42   /* get image/provider description */
43   provider->GetSurfaceDescription(provider,&dsc);
44   printf("debug: w/h %d / %d\n",dsc.width,dsc.height);
45   /* create apropriate surface */
46   dfb->CreateSurface(dfb,&dsc,&logo);
47   /* render image */
48   provider->RenderTo(provider,logo,NULL);
49
50   provider->Release(provider);
51
52   /* slide logo */
53   for(i = -dsc.width; i < screen_width; i++) {
54       /* clear screen */
55       primary->FillRectangle(primary,0,0,screen_width,screen_height);
56
57       /* blit image */
58       primary->Blit(primary,logo,NULL,i,(screen_height-dsc.height)/2);
59
60       /* flip */
61       primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC);
62     }
63
64   /* release image */
65   logo->Release(logo);
66
67   primary->Release(primary);
68   dfb->Release(dfb);
69   
70   return 23;
71 }
72