]> www.hackdaworld.org Git - my-code/ivac.git/blob - old/dfbapi.c
introduced special network return codes, added {de,}select, connect, close, set functions
[my-code/ivac.git] / old / dfbapi.c
1 /* dfb functions
2  *
3  * author: hackbard@hackdaworld.dyndns.org
4  *
5  */
6
7 #include <stdio.h>
8 #include <directfb.h>
9 #include "ivac.h"
10
11 int flip_blit_callback(void *ctx) {
12         struct ivac *ivac=ctx;
13
14         ivac->dfb_stuff.v_surface->Flip(ivac->dfb_stuff.v_surface,NULL,0);
15
16         return 1;
17 }
18
19 int dfb_play_video(struct ivac *ivac) {
20
21         ivac->dfb_stuff.v_provider->PlayTo(ivac->dfb_stuff.v_provider,ivac->dfb_stuff.v_surface,NULL,flip_blit_callback,(void *)ivac);
22
23         return 1;
24 }
25         
26 int dfb_stop_video(struct ivac *ivac) {
27
28         ivac->dfb_stuff.v_provider->Stop(ivac->dfb_stuff.v_provider);
29         
30         return 1;
31 }
32
33 int dfb_init(int arg_c,char **arg_v,struct ivac *ivac) {
34         DFBSurfaceDescription sdsc;
35         // DFBFontDescription fdsc;
36         DFBWindowDescription wdsc;
37
38         /* init */      
39         DirectFBInit(&arg_c,&arg_v);
40         DirectFBCreate(&(ivac->dfb_stuff.dfb));
41
42         /* input devices and event stuff */
43         ivac->dfb_stuff.dfb->GetInputDevice(ivac->dfb_stuff.dfb,DIDID_MOUSE,&(ivac->dfb_stuff.mouse));
44         ivac->dfb_stuff.dfb->GetInputDevice(ivac->dfb_stuff.dfb,DIDID_KEYBOARD,&(ivac->dfb_stuff.keyboard));
45         ivac->dfb_stuff.mouse->CreateEventBuffer(ivac->dfb_stuff.mouse,&(ivac->dfb_stuff.buffer));
46
47         /* first window -- video window */
48         ivac->dfb_stuff.dfb->GetDisplayLayer(ivac->dfb_stuff.dfb,DLID_PRIMARY,&(ivac->dfb_stuff.layer));
49         ivac->dfb_stuff.dfb->CreateVideoProvider(ivac->dfb_stuff.dfb,ivac->video_dev,&(ivac->dfb_stuff.v_provider));
50         ivac->dfb_stuff.v_provider->GetSurfaceDescription(ivac->dfb_stuff.v_provider,&sdsc);
51
52         wdsc.flags=DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT;
53         wdsc.posx=0;
54         wdsc.posy=0;
55         wdsc.width=sdsc.width;
56         wdsc.height=sdsc.height;
57
58         ivac->dfb_stuff.layer->CreateWindow(ivac->dfb_stuff.layer,&wdsc,&(ivac->dfb_stuff.v_window));
59         ivac->dfb_stuff.v_window->GetSurface(ivac->dfb_stuff.v_window,&(ivac->dfb_stuff.v_surface));
60         ivac->dfb_stuff.v_window->SetOpacity(ivac->dfb_stuff.v_window,0xff);
61
62         return 1;
63 }
64
65 int dfb_tini(struct ivac *ivac) {
66         ivac->dfb_stuff.v_provider->Release(ivac->dfb_stuff.v_provider);
67         ivac->dfb_stuff.v_window->Release(ivac->dfb_stuff.v_window);
68         ivac->dfb_stuff.layer->Release(ivac->dfb_stuff.layer);
69         ivac->dfb_stuff.dfb->Release(ivac->dfb_stuff.dfb);
70         
71         return 1;
72 }