From: hackbard Date: Tue, 26 Aug 2003 18:23:39 +0000 (+0000) Subject: - X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38a94016ecd0208d5475d31a7df3b684b1891ba1;p=my-code%2Fivac.git - --- diff --git a/dfbapi.c b/dfbapi.c index 45960be..7de46c3 100644 --- a/dfbapi.c +++ b/dfbapi.c @@ -8,29 +8,48 @@ #include #include "ivac.h" +// do +// int flip_blit_callback() +// int dfb_play_video() +// int dfb_stop_video() + int dfb_init(int arg_c,char **arg_v,struct ivac *ivac) { - DFBSurfaceDescription surface_dsc; - DFBFontDescription font_dsc; - + DFBSurfaceDescription sdsc; + // DFBFontDescription fdsc; + DFBWindowDescription wdsc; + + /* init */ DirectFBInit(&arg_c,&arg_v); DirectFBCreate(&(ivac->dfb_stuff.dfb)); - ivac->dfb_stuff.dfb->SetCooperativeLevel(ivac->dfb_stuff.dfb,DFSCL_FULLSCREEN); - surface_dsc.flags=DSDESC_CAPS; - surface_dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING; - ivac->dfb_stuff.dfb->CreateSurface(ivac->dfb_stuff.dfb,&surface_dsc,&(ivac->dfb_stuff.p_surface)); - ivac->dfb_stuff.p_surface->GetSize(ivac->dfb_stuff.p_surface,&(ivac->dfb_stuff.s_width),&(ivac->dfb_stuff.s_height)); + /* input devices and event stuff */ + ivac->dfb_stuff.dfb->GetInputDevice(ivac->dfb_stuff.dfb,DIDID_MOUSE,&(ivac->dfb_stuff.mouse)); + ivac->dfb_stuff.dfb->GetInputDevice(ivac->dfb_stuff.dfb,DIDID_KEYBOARD,&(ivac->dfb_stuff.keyboard)); + ivac->dfb_stuff.mouse->CreateEventBuffer(ivac->dfb_stuff.mouse,&(ivac->dfb_stuff.buffer)); - font_dsc.flags=DFDESC_HEIGHT; - font_dsc.height=ivac->dfb_stuff.s_height/20; + /* first window -- video window */ + ivac->dfb_stuff.dfb->GetDisplayLayer(ivac->dfb_stuff.dfb,DLID_PRIMARY,&(ivac->dfb_stuff.layer)); ivac->dfb_stuff.dfb->CreateVideoProvider(ivac->dfb_stuff.dfb,ivac->video_dev,&(ivac->dfb_stuff.v_provider)); + ivac->dfb_stuff.v_provider->GetSurfaceDescription(ivac->dfb_stuff.v_provider,&sdsc); + + wdsc.flags=DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT; + wdsc.posx=0; + wdsc.posy=0; + wdsc.width=sdsc.width; + wdsc.height=sdsc.height; + + ivac->dfb_stuff.layer->CreateWindow(ivac->dfb_stuff.layer,&wdsc,&(ivac->dfb_stuff.v_window)); + ivac->dfb_stuff.v_window->GetSurface(ivac->dfb_stuff.v_window,&(ivac->dfb_stuff.v_surface)); + ivac->dfb_stuff.v_window->SetOpacity(ivac->dfb_stuff.v_window,0xff); + ivac->dfb_stuff.v_provider->PlayTo(ivac->dfb_stuff.v_provider,ivac->dfb_stuff.v_surface,NULL,NULL,NULL); return 1; } int dfb_tini(struct ivac *ivac) { ivac->dfb_stuff.v_provider->Release(ivac->dfb_stuff.v_provider); - ivac->dfb_stuff.p_surface->Release(ivac->dfb_stuff.p_surface); + ivac->dfb_stuff.v_window->Release(ivac->dfb_stuff.v_window); + ivac->dfb_stuff.layer->Release(ivac->dfb_stuff.layer); ivac->dfb_stuff.dfb->Release(ivac->dfb_stuff.dfb); return 1; diff --git a/dfbapi.o b/dfbapi.o index c1ce110..4dc8798 100644 Binary files a/dfbapi.o and b/dfbapi.o differ diff --git a/ivac.c b/ivac.c index d4e1581..a9f270e 100644 --- a/ivac.c +++ b/ivac.c @@ -22,27 +22,12 @@ int usage(void) { return 1; } -int video_callback(void *ctx) { - struct ivac *ivac; - IDirectFBSurface *surf; - DFBSurfaceDescription desc; - - ivac=ctx; - puts("debug: callback!"); - ivac->dfb_stuff.v_provider->GetSurfaceDescription(ivac->dfb_stuff.v_provider,&desc); - printf("debug: w: %d -- h: %d\n",desc.width,desc.height); - ivac->dfb_stuff.dfb->CreateSurface(ivac->dfb_stuff.dfb,&desc,&surf); - ivac->dfb_stuff.p_surface->Blit(ivac->dfb_stuff.p_surface,surf,NULL,0,0); - ivac->dfb_stuff.p_surface->Flip(ivac->dfb_stuff.p_surface,NULL,DSFLIP_WAITFORSYNC); - ivac->dfb_stuff.count+=1; - if(ivac->dfb_stuff.count==5000) - ivac->dfb_stuff.v_provider->Stop(ivac->dfb_stuff.v_provider); - return DFENUM_OK; -} - int main(int argc, char **argv) { int i; struct ivac ivac; + DFBInputDeviceKeyState quit; + + quit=DIKS_UP; /* default */ strcpy(ivac.video_dev,VIDEO_DEV); @@ -75,19 +60,9 @@ int main(int argc, char **argv) { return -1; } - puts("debug: dfb init done!!"); - - ivac.dfb_stuff.count=0; - ivac.dfb_stuff.rect.x=5; - ivac.dfb_stuff.rect.y=5; - ivac.dfb_stuff.rect.w=500; - ivac.dfb_stuff.rect.h=400; - ivac.dfb_stuff.v_provider->PlayTo(ivac.dfb_stuff.v_provider,ivac.dfb_stuff.p_surface,&(ivac.dfb_stuff.rect),video_callback,(void *)&ivac); - - sleep(2); + getchar(); dfb_tini(&ivac); - puts("debug: dfb tini done!!"); return 1; } diff --git a/ivac.h b/ivac.h index beb9b82..030b144 100644 --- a/ivac.h +++ b/ivac.h @@ -19,15 +19,14 @@ struct dfb_stuff { IDirectFB *dfb; - IDirectFBSurface *p_surface; - IDirectFBFont *font; - IDirectFBInputDevice *keyboard; - IDirectFBEventBuffer *k_buffer; - IDirectFBVideoProvider *v_provider; + IDirectFBDisplayLayer *layer; IDirectFBImageProvider *i_provider; - int s_width,s_height; - DFBRectangle rect; - int count; + IDirectFBVideoProvider *v_provider; + IDirectFBWindow *window,*v_window;; + IDirectFBSurface *v_surface,*i_surface,*surface; + IDirectFBFont *font; + IDirectFBInputDevice *keyboard,*mouse; + IDirectFBEventBuffer *buffer; }; struct ivac { @@ -35,6 +34,7 @@ struct ivac { char video_dev[MAX_CHAR_VIDEO_DEV]; char audio_dev[MAX_CHAR_AUDIO_DEV]; unsigned char flags; + int count; };