Re: drawing on offscreen surface



Hi!

> Thanks for the code.
> However, it does not draw anything. I assume the draw rectangle need to be
> done in draw_cb() so I added this code in
>   cairo_set_source_surface(cr, surface, 0, 0);
>
>   cairo_set_source_rgb(cr, 0, 1, 0);
>   cairo_rectangle(cr, 300, 300, 200, 200);
>   cairo_stroke(cr);
>   cairo_paint(cr);
>
> but it still does not draw any rectangle. Do I not need to have "expose"
> handler to draw?

What version of GTK+ are you using? Simple app I sent to you uses
version 3 and will not work properly with version 2. If you're using
GTK+ version 2, you'll need to make some minor changes (replace "draw"
signal with "expose-event" signal, update draw callback prototype and
manually create cairo context for GTkDrawingArea's GdkWindow).

> Also, I would like to know how to render contents from main window AND from
> offscreen both together on main visible window
> say, a primitive (Rectangle) on main window and another primitive (circle)
> from offscreen? Could you please show me how?

Not sure what is giving you trouble here. Drawing from offscreen is
done by two simple function calls: cairo_set_source_surface() and
cairo_paint(). If you need something else drawn onto your widgets,
simply draw that from inside draw (or expose-event for GTK+ 2.x)
callbackusing cairo drawing functions.

Cheers,
Tadej

-- 
Tadej Borovšak
blog.borovsak.si
tadeboro gmail com
tadej borovsak gmail com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]