buf size redueced to 1000 again
[my-code/ivac.git] / dfb_api.c
diff --git a/dfb_api.c b/dfb_api.c
new file mode 100644 (file)
index 0000000..0641534
--- /dev/null
+++ b/dfb_api.c
@@ -0,0 +1,72 @@
+/*
+ * dfb_api.c - api to dfb interface
+ */
+
+/* std includes */
+#include <stdio.h>
+#include <unistd.h>
+
+/* dfb includes */
+#include <directfb.h>
+
+/* global stuff */
+
+/* well ... */
+static IDirectFB *dfb = NULL;
+/* surface */
+static IDirectFBSurface *primary = NULL;
+static int screen_width  = 0;
+static int screen_height = 0;
+static IDirectFBSurface *logo = NULL;
+/* image to load */
+char dfb_image[]="./images/ivac_logo.png";
+
+int main (int argc, char **argv) {
+  int i;
+  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;
+  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);
+
+  /* slide logo */
+  for(i = -dsc.width; i < screen_width; i++) {
+      /* clear screen */
+      primary->FillRectangle(primary,0,0,screen_width,screen_height);
+
+      /* blit image */
+      primary->Blit(primary,logo,NULL,i,(screen_height-dsc.height)/2);
+
+      /* flip */
+      primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC);
+    }
+
+  /* release image */
+  logo->Release(logo);
+
+  primary->Release(primary);
+  dfb->Release(dfb);
+  
+  return 23;
+}
+