From: hackbard Date: Sat, 15 Feb 2003 21:59:49 +0000 (+0000) Subject: - X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8863c0b9719b8dd511782494bebe85e802be45c;p=my-code%2Fivac.git - --- diff --git a/dfb_api.c b/dfb_api.c index 56534e3..fbc67fb 100644 --- a/dfb_api.c +++ b/dfb_api.c @@ -4,6 +4,7 @@ /* std includes */ #include +#include #include /* dfb includes */ @@ -14,86 +15,86 @@ /* global stuff */ /* well ... */ -static IDirectFB *dfb = NULL; -static IDirectFBSurface *primary = NULL; -static int screen_width = 0; -static int screen_height = 0; +IDirectFB *dfb = NULL; -static IDirectFBSurface *logo = NULL; +IDirectFBSurface *primary = NULL; +IDirectFBSurface *logo = NULL; +IDirectFBSurface *subsurface = NULL; +IDirectFBSurface *window = NULL; -static IDirectFBFont *font = NULL; -static char *text_top="Internet Video / Audio Conferencing"; +IDirectFBImageProvider *image_provider = NULL; +IDirectFBVideoProvider *video_provider = NULL; -/* image to load */ +static int screen_width = 0; +static int screen_height = 0; + +char dfb_video_dev[]="/dev/video"; +char text_top[]="Internet Video / Audio Conferencing"; char dfb_image[]="./images/ivac_logo.png"; -/* font to use */ char dfb_font[]="./fonts/decker.ttf"; -int main (int argc, char **argv) { - int i,font_width; - DFBFontDescription font_dsc; - DFBSurfaceDescription dsc; - /* image provider */ - IDirectFBImageProvider *provider; - - /* init */ - DirectFBInit(&argc,&argv); - DirectFBCreate(&dfb); - dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN); - dsc.flags=DSDESC_CAPS; - // 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); - - /* create the imag provider */ - dfb->CreateImageProvider(dfb,dfb_image,&provider); - /* get image/provider description */ - provider->GetSurfaceDescription(provider,&dsc); - printf("debug: w/h %d / %d\n",dsc.width,dsc.height); - /* create apropriate surface */ - dfb->CreateSurface(dfb,&dsc,&logo); - /* render image */ - provider->RenderTo(provider,logo,NULL); - provider->Release(provider); - - /* 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); - - primary->Release(primary); - dfb->Release(dfb); - - return 23; +/* small api */ +int dfb_init(int *argc,char **argv) { + DirectFBInit(argc,&argv); + DirectFBCreate(&dfb); + dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN); + return 1; +} + +int check_accel(void) { + DFBCardCapabilities caps; + dfb->GetCardCapabilities(dfb,&caps); + return (caps.acceleration_mask); +} + +int create_primary_surface(void) { + DFBSurfaceDescription desc; + memset(&desc,0,sizeof(DFBSurfaceDescription)); + desc.flags=DSDESC_CAPS; + desc.caps=DSCAPS_PRIMARY; + dfb->CreateSurface(dfb,&desc,&primary); + return 1; +} + +int create_image_provider(IDirectFBSurface *surface) { + dfb->CreateImageProvider(dfb,dfb_image,&image_provider); + image_provider->RenderTo(image_provider,surface,NULL); + image_provider->Release(image_provider); + return 1; +} + +int create_video_provider(IDirectFBSurface *surface) { + dfb->CreateVideoProvider(dfb,dfb_video_dev,&video_provider); + video_provider->PlayTo(video_provider,surface,NULL,NULL,NULL); + // video_provider->Release(video_provider); + return 1; } +int release_surface(IDirectFBSurface *surface) { + surface->Release(surface); + return 1; +} + +int release_dfb(void) { + dfb->Release(dfb); + return 1; +} + + +/* test api app */ +int main (int argc, char **argv) { + + dfb_init(&argc,argv); + + check_accel(); + + create_primary_surface(); + + create_image_provider(primary); + + sleep(5); + + release_surface(primary); + + return 1; +}