Cairo+glitz/Setup cairo
From Sidvind
| Note: glitz support in cairo-1.8 is broken! |
See cairo+glitz/Setup glitz with glx for details about getting glitz to work.
Cairo surface
One the glitz surface is created it is actually quite simple to have cairo use it as backend.
- // Create a cairo surface with glitz as backend.
- cairo_surface_t* pCairoSurface = cairo_glitz_surface_create (surface);
- // Create the cairo context as usual.
- cairo_t* cr = cairo_create (pCairoSurface);
Rendering sample
- // Clear the surface.
- cairo_scale(cr, 2.5, 2.5);
- cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
- cairo_paint (cr);
- // Use default operator and color.
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 1.0f);
- // This is one of the samples provided by the cairo documentation, see http://www.cairographics.org/samples/curve_to/
- double x=25.6, y=128.0;
- double x1=102.4, y1=230.4,
- x2=153.6, y2=25.6,
- x3=230.4, y3=128.0;
- cairo_move_to (cr, x, y);
- cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);
- cairo_set_line_width (cr, 10.0);
- cairo_stroke (cr);
- cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
- cairo_set_line_width (cr, 6.0);
- cairo_move_to (cr,x,y); cairo_line_to (cr,x1,y1);
- cairo_move_to (cr,x2,y2); cairo_line_to (cr,x3,y3);
- cairo_stroke (cr);
- // Swap buffers using glitz.
- glitz_drawable_swap_buffers(drawable);