/* Requires the directfb-devel package, compile with * gcc -I/usr/include/direcfb -o dfbtest dfbtest.c -ldirectfb */ #include #include #include #include #include #include #include #include #include #define DFBCHECK(x...) \ { \ int ret = x; \ if (ret != DFB_OK) { \ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ DirectFBErrorFatal( #x, ret ); \ } \ } int main(int argc, char **argv) { IDirectFB *dfb; IDirectFBDisplayLayer *dl; DFBWindowDescription wdesc; IDirectFBScreen *scr; IDirectFBWindow *window; IDirectFBSurface *surf; int screen_width, screen_height; // Create the frame buffer interface DFBCHECK(DirectFBInit(&argc, &argv)) DFBCHECK(DirectFBCreate(&dfb)); DFBCHECK(dfb->SetCooperativeLevel(dfb, DFSCL_EXCLUSIVE)); // Grab the interface to the screen primary display layer DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &dl)); DFBCHECK(dl->SetCooperativeLevel(dl, DLSCL_EXCLUSIVE)); DFBCHECK(dfb->GetScreen(dfb, 0, &scr)); DFBCHECK(scr->GetSize(scr, &screen_width, &screen_height)); DFBCHECK(dl->SetBackgroundColor(dl, 0, 0xff, 0, 0xff)); DFBCHECK(dl->SetBackgroundMode(dl, DLBM_COLOR)); /* Create a window */ memset(&wdesc, 0, sizeof(wdesc)); wdesc.flags = DWDESC_CAPS | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_PIXELFORMAT | DWDESC_SURFACE_CAPS | DWDESC_OPTIONS | DWDESC_STACKING; wdesc.caps = DWCAPS_DOUBLEBUFFER | DWCAPS_NODECORATION | DWCAPS_NOFOCUS; wdesc.width = 100; wdesc.height = 100; wdesc.posx = screen_width / 2 - 50; wdesc.posy = screen_height / 2 - 50; wdesc.surface_caps = DSCAPS_FLIPPING; wdesc.pixelformat = DSPF_RGB32; wdesc.options = DWOP_SCALE | DWOP_INDESTRUCTIBLE | DWOP_GHOST; wdesc.stacking = DWSC_UPPER; DFBCHECK(dl->CreateWindow(dl, &wdesc, &window)) window->SetOpacity(window, 0xff); window->GetSurface(window, &surf); surf->Clear(surf, 0xff, 0xff, 0xff, 0xff); surf->Flip(surf, NULL, DSFLIP_ONSYNC); window->SetOpacity(window, 0xff); sleep(10); surf->Release(surf); window->Destroy(window); window->Release(window); dl->Release(dl); dfb->Release (dfb); return 0; }