From 01a4f2c8c28af1fd4bd973c430c087f1b9a25a22 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 16 Feb 2003 00:55:59 +0000 Subject: [PATCH] - --- dfb_api.c | 62 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/dfb_api.c b/dfb_api.c index 14c3cda..00bc88c 100644 --- a/dfb_api.c +++ b/dfb_api.c @@ -19,21 +19,22 @@ IDirectFB *dfb = NULL; IDirectFBSurface *primary = NULL; IDirectFBSurface *logo = NULL; -IDirectFBSurface *subsurface = NULL; +IDirectFBSurface *video = NULL; IDirectFBSurface *window = NULL; IDirectFBImageProvider *image_provider = NULL; IDirectFBVideoProvider *video_provider = NULL; -static int screen_width = 0; -static int screen_height = 0; +int screen_width = 0; +int screen_height = 0; char dfb_video_dev[]="/dev/v4l/video0"; char text_top[]="Internet Video / Audio Conferencing"; char dfb_image[]="./images/ivac_logo.png"; char dfb_font[]="./fonts/decker.ttf"; -/* small api */ +/* small api - directfb usage kinda sux: foo->bar(foo,...) wtf?!?!?! */ + int dfb_init(int *argc,char **argv) { DirectFBInit(argc,&argv); DirectFBCreate(&dfb); @@ -56,17 +57,47 @@ int create_primary_surface(void) { return 1; } -int show_image(IDirectFBSurface *surface) { +int get_surface_size(IDirectFBSurface *surface,int *width,int *height) { + surface->GetSize(surface,width,height); + return 1; +} + +int get_primary_surface_size(void) { + get_surface_size(primary,&screen_width,&screen_height); + return 1; +} + +int create_logo_surface(void) { + DFBSurfaceDescription desc; + DFBImageDescription image_desc; dfb->CreateImageProvider(dfb,dfb_image,&image_provider); - image_provider->RenderTo(image_provider,surface,NULL); + image_provider->GetSurfaceDescription(image_provider,&desc); + image_provider->GetImageDescription(image_provider,&image_desc); + printf("image description: caps=%x red=%hhd green=%hhd blue=%hhd\n",image_desc.caps, + image_desc.colorkey_r, + image_desc.colorkey_g, + image_desc.colorkey_b); + dfb->CreateSurface(dfb,&desc,&logo); + image_provider->RenderTo(image_provider,logo,NULL); image_provider->Release(image_provider); return 1; } - -int play_video(IDirectFBSurface *surface) { + +int create_video_surface(void) { + DFBSurfaceDescription desc; + DFBVideoProviderCapabilities caps; dfb->CreateVideoProvider(dfb,dfb_video_dev,&video_provider); - video_provider->PlayTo(video_provider,surface,NULL,NULL,NULL); - // video_provider->Release(video_provider); + video_provider->GetSurfaceDescription(video_provider,&desc); + video_provider->GetCapabilities(video_provider,&caps); + printf("video capabilities: %x\n",caps); + dfb->CreateSurface(dfb,&desc,&video); + video_provider->PlayTo(video_provider,video,NULL,NULL,NULL); + video_provider->Release(video_provider); + return 1; +} + +int clear_screen(IDirectFBSurface *surface) { + surface->FillRectangle(surface,0,0,screen_width,screen_height); return 1; } @@ -89,11 +120,16 @@ int main (int argc, char **argv) { check_accel(); create_primary_surface(); + printf("primary surface created\n"); + + // create_video_surface(); + create_logo_surface(); + + get_primary_surface_size(); - // play_video(primary); - show_image(primary); + clear_screen(primary); - primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC); + // primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC); sleep(5); -- 2.20.1