2 * dfb_api.c - api to dfb interface
13 #define MY_FONT_HEIGHT 18
18 IDirectFB *dfb = NULL;
20 IDirectFBSurface *primary = NULL;
21 IDirectFBSurface *logo = NULL;
22 IDirectFBSurface *video = NULL;
23 IDirectFBSurface *window = NULL;
25 IDirectFBImageProvider *image_provider = NULL;
26 IDirectFBVideoProvider *video_provider = NULL;
29 int screen_height = 0;
31 char dfb_video_dev[]="/dev/v4l/video0";
32 char text_top[]="Internet Video / Audio Conferencing";
33 char dfb_image[]="./images/ivac_logo.png";
34 char dfb_font[]="./fonts/decker.ttf";
36 /* small api - directfb usage kinda sux: foo->bar(foo,...) wtf?!?!?! */
38 int dfb_init(int *argc,char **argv) {
39 DirectFBInit(argc,&argv);
41 dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN);
45 int check_accel(void) {
46 DFBCardCapabilities caps;
47 dfb->GetCardCapabilities(dfb,&caps);
48 return (caps.acceleration_mask);
51 int create_primary_surface(void) {
52 DFBSurfaceDescription desc;
53 memset(&desc,0,sizeof(DFBSurfaceDescription));
54 desc.flags=DSDESC_CAPS;
55 desc.caps=DSCAPS_PRIMARY;
56 dfb->CreateSurface(dfb,&desc,&primary);
60 int get_surface_size(IDirectFBSurface *surface,int *width,int *height) {
61 surface->GetSize(surface,width,height);
65 int get_primary_surface_size(void) {
66 get_surface_size(primary,&screen_width,&screen_height);
70 int create_logo_surface(void) {
71 DFBSurfaceDescription desc;
72 DFBImageDescription image_desc;
73 dfb->CreateImageProvider(dfb,dfb_image,&image_provider);
74 image_provider->GetSurfaceDescription(image_provider,&desc);
75 image_provider->GetImageDescription(image_provider,&image_desc);
76 printf("image description: caps=%x red=%hhd green=%hhd blue=%hhd\n",image_desc.caps,
77 image_desc.colorkey_r,
78 image_desc.colorkey_g,
79 image_desc.colorkey_b);
80 dfb->CreateSurface(dfb,&desc,&logo);
81 image_provider->RenderTo(image_provider,logo,NULL);
82 image_provider->Release(image_provider);
86 int create_video_surface(void) {
87 DFBSurfaceDescription desc;
88 DFBVideoProviderCapabilities caps;
89 dfb->CreateVideoProvider(dfb,dfb_video_dev,&video_provider);
90 video_provider->GetSurfaceDescription(video_provider,&desc);
91 video_provider->GetCapabilities(video_provider,&caps);
92 printf("video capabilities: %x\n",caps);
93 dfb->CreateSurface(dfb,&desc,&video);
94 video_provider->PlayTo(video_provider,video,NULL,NULL,NULL);
95 video_provider->Release(video_provider);
99 int clear_screen(IDirectFBSurface *surface) {
100 surface->FillRectangle(surface,0,0,screen_width,screen_height);
104 int release_surface(IDirectFBSurface *surface) {
105 surface->Release(surface);
109 int release_dfb(void) {
116 int main (int argc, char **argv) {
118 dfb_init(&argc,argv);
122 create_primary_surface();
123 printf("primary surface created\n");
125 // create_video_surface();
126 create_logo_surface();
128 get_primary_surface_size();
130 clear_screen(primary);
132 // primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC);
136 release_surface(primary);