X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=dfb_api.c;h=56534e3f0954dac0d84911084ababdf828d43eb8;hb=85121cf5ceb381e5502a8f6cb6423d54c152cdfe;hp=06415344faa7d4d3afb9aece346ecea346f3fc4f;hpb=1a0f1529fb2086dbbb93b3d8164389c844d84fab;p=my-code%2Fivac.git diff --git a/dfb_api.c b/dfb_api.c index 0641534..56534e3 100644 --- a/dfb_api.c +++ b/dfb_api.c @@ -9,30 +9,40 @@ /* dfb includes */ #include +#define MY_FONT_HEIGHT 18 + /* global stuff */ /* well ... */ static IDirectFB *dfb = NULL; -/* surface */ static IDirectFBSurface *primary = NULL; static int screen_width = 0; static int screen_height = 0; + static IDirectFBSurface *logo = NULL; + +static IDirectFBFont *font = NULL; +static char *text_top="Internet Video / Audio Conferencing"; + /* image to load */ char dfb_image[]="./images/ivac_logo.png"; +/* font to use */ +char dfb_font[]="./fonts/decker.ttf"; int main (int argc, char **argv) { - int i; + int i,font_width; + DFBFontDescription font_dsc; DFBSurfaceDescription dsc; /* image provider */ IDirectFBImageProvider *provider; /* init */ - DirectFBInit (&argc, &argv); - DirectFBCreate (&dfb); - dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN); + DirectFBInit(&argc,&argv); + DirectFBCreate(&dfb); + dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN); dsc.flags=DSDESC_CAPS; - dsc.caps=DSCAPS_PRIMARY | DSCAPS_FLIPPING; + // dsc.caps=DSCAPS_PRIMARY | DSCAPS_FLIPPING; + dsc.caps=DSCAPS_PRIMARY; dfb->CreateSurface(dfb,&dsc,&primary); primary->GetSize(primary,&screen_width,&screen_height); printf("debug: w/h = %d / %d\n",screen_width,screen_height); @@ -46,20 +56,37 @@ int main (int argc, char **argv) { dfb->CreateSurface(dfb,&dsc,&logo); /* render image */ provider->RenderTo(provider,logo,NULL); - provider->Release(provider); - /* slide logo */ + /* create font */ + font_dsc.flags=DFDESC_HEIGHT; + font_dsc.height=MY_FONT_HEIGHT; + dfb->CreateFont(dfb,dfb_font,&font_dsc,&font); + + /* set font */ + primary->SetFont(primary,font); + font->GetStringWidth(font,text_top,-1,&font_width); + + + /* slide logo + write text_top */ for(i = -dsc.width; i < screen_width; i++) { /* clear screen */ primary->FillRectangle(primary,0,0,screen_width,screen_height); + /* write text */ + primary->SetColor(primary,0x0,0x0,0x0,0xff); + primary->DrawString(primary,text_top,-1,(screen_width/2)-(font_width/2), + screen_height/4,DSTF_LEFT); + /* blit image */ primary->Blit(primary,logo,NULL,i,(screen_height-dsc.height)/2); /* flip */ primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC); - } + } + + /* release font */ + font->Release(font); /* release image */ logo->Release(logo);