Re: drawing on offscreen surface



Thanks for your code. This draws a blue rectangle on a black background and the offscreen surface contents is rendered on main window.
But I also would like to draw green rectangle in main window so after final rendering of offscreen contents (the blue rectangle) on main window, I would get both blue and green rectangles on main window.
Can you please clarify how can I achieve that (both offscreen & main window contents being shown on main window)?

Thanks in advance!!

Regards
Prasanta

On Fri, Aug 10, 2012 at 2:22 PM, Jean Brefort <jean brefort normalesup org> wrote:
You should use something like:

cairo_set_source_surface(cr, surface, 0, 0);
cairo_paint(cr).
cairo_set_source_rgb(cr, 0, 0, 1);
cairo_rectangle(cr, 300,300, 200, 200);
cairo_stroke(cr);

This will paint the window with surface as source and then draw a blue
rectangle.

Le vendredi 10 août 2012 à 14:09 +0530, Prasanta Sadhukhan a écrit :
>
>
> On Fri, Aug 10, 2012 at 1:22 PM, Jean Brefort
> <jean brefort normalesup org> wrote:
>         This code is quite strange. Your call to
>         cairo_set_source_surface() is
>         not useful since you use cairo_set_source_rgb() just after.
>         You should
>         call cairo_paint() just after cairo_set_source_surface() if
>         you want it
>         to have any effect.
>
> If I do not call     cairo_set_source_rgb(cr, 0, 0, 1); how will get a
> blue rectangle?
> Just having   these is giving me a window with black background.
> cairo_set_source_surface(cr, surface, 0, 0);
> cairo_rectangle(cr, 300,300, 200, 200);
> cairo_stroke(cr);
> cairo_paint(cr).
>
> Can you please clarify?
> As I told, I would like to get a blue rectangle in offscreen surface
> and a green rectangle in main visible surface so after final rendering
> of offscreen contents on main window, I would get both rectangles on
> main window.
>
> Regards
> Prasanta
>
>         Hope it helps,
>         Jean
>
>         Le vendredi 10 août 2012 à 13:07 +0530, Prasanta Sadhukhan a
>         écrit :
>         > expose_event (GtkWidget *widget,GdkEventExpose *event,
>         gpointer
>         > data)
>         > {
>         >   g_print("draw event main\n");
>         >
>         >   cairo_t *cr = gdk_cairo_create(widget->window);
>         > // draw blue rectangle into offscreen
>         >   cairo_set_source_surface(cr, surface, 0, 0);
>         >   cairo_set_source_rgb(cr, 0, 0, 1);
>         >   cairo_rectangle(cr, 300, 300, 200, 200);
>         >   cairo_stroke(cr);
>         >   cairo_paint(cr);
>         >
>         > //draw green rectangle onto main window
>         >     cairo_set_source_rgb(cr, 0, 1, 0);
>         >   cairo_rectangle(cr, 100, 100, 200, 200);
>         >    cairo_stroke(cr)
>         > }
>         >
>         >
>         >
>
>
>         _______________________________________________
>         gtk-list mailing list
>         gtk-list gnome org
>         https://mail.gnome.org/mailman/listinfo/gtk-list
>





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