Hi,

I think this is crashing because you didn't initialize the dsc variable;

add the following lines before creating the primary surface.

  dsc.flags = DSDESC_CAPS;
  dsc.caps  = DSCAPS_PRIMARY;
and retry this should work.


On Mon, May 4, 2009 at 12:08 PM, Ali Javadi <ali.djav...@gmail.com> wrote:

> I want to use Cairo with DirectFB, but it cause system to crash, can anyone
> help me?
>
> #include <stdio.h>
> #include <unistd.h>
> #include <directfb.h>
> #include <cairo.h>
> #include <cairo-features.h>
> /*
>  * Disable cairo DirectFB backend until it becomes stable enough.
>  */
>
> #ifdef CAIRO_HAS_DIRECTFB_SURFACE
> # include <cairo-directfb.h>
> #endif
>
> static IDirectFB *dfb = NULL;
> static IDirectFBSurface *primary = NULL;
> static int screen_width  = 0;
> static int screen_height = 0;
>
> #define DFBCHECK(x...)                                         \
>   {                                                            \
>     DFBResult err = x;                                         \
>                                                                \
>     if (err != DFB_OK)                                         \
>       {                                                        \
>         fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
>         DirectFBErrorFatal( #x, err );                         \
>       }                                                        \
>   }
>
> int main (int argc, char **argv)
> {
>   DFBSurfaceDescription dsc;
>
>   DFBCHECK (DirectFBInit (&argc, &argv));
>   DFBCHECK (DirectFBCreate (&dfb));
>
>   DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
>   DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
>
>   cairo_surface_t *csurface=cairo_directfb_surface_create(dfb,primary);
>
>   cairo_surface_destroy(csurface);
>
>
>   primary->Release( primary );
>   dfb->Release( dfb );
>
>   return 23;
> }
>
>
> _______________________________________________
> directfb-users mailing list
> directfb-users@directfb.org
> http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users
>
>
_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to