Advertisement
trini

dfb.c

Oct 1st, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <directfb.h>
  4.  
  5. static IDirectFB *dfb = NULL;
  6. static IDirectFBSurface *primary = NULL;
  7. static int screen_width = 0;
  8. static int screen_height = 0;
  9.  
  10. #define DFBCHECK(x...) \
  11. { \
  12. DFBResult err = x; \
  13. \
  14. if (err != DFB_OK) \
  15. { \
  16. fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
  17. DirectFBErrorFatal( #x, err ); \
  18. } \
  19. }
  20.  
  21. int main (int argc, char **argv)
  22. {
  23. DFBSurfaceDescription dsc;
  24.  
  25. DFBCHECK (DirectFBInit (&argc, &argv));
  26. DFBCHECK (DirectFBCreate (&dfb));
  27. DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
  28.  
  29. dsc.flags = DSDESC_CAPS;
  30. dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
  31.  
  32. DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
  33. DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
  34. DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
  35.  
  36. DFBCHECK (primary->SetColor (primary, 0x80, 0x80, 0xff, 0xff));
  37. DFBCHECK (primary->DrawLine (primary,
  38. 0, screen_height / 2,
  39. screen_width - 1, screen_height / 2));
  40. DFBCHECK (primary->Flip (primary, NULL, 0));
  41.  
  42. sleep (5);
  43.  
  44. primary->Release( primary );
  45. dfb->Release( dfb );
  46.  
  47. return 23;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement