Efficient rendering using pixbuf

Hi, I need to display my app on a stereoscopic screen, is there a way to do it in GTK?
So far, for lack of a better solution I override on_draw(), and create a pixbuf according to the screen format (horizontal interlace). Following is my code, please help me make it more efficient.
For example: can the first line, Container::on_draw() be replaced with some back-buffer rendering? I tried to find the gtkmm version of gdk_draw_drawable() or gdk_pixbuf_get_from_drawable().

bool MyContainer::on_draw(const Cairo::RefPtrCairo::Context& cr)
// 1. Crearte 2 pixbufs with the widget image
Gtk::Allocation allocation = get_allocation();
const int x = allocation.get_x();
const int y = allocation.get_y();
const int width = allocation.get_width();
const int height = allocation.get_height();
Cairo::RefPtrCairo::Surface s = cr->get_target();
double scale = 2.f;
auto pixbufL = Gdk::Pixbuf::create(s, x, y, width, scale * height);
auto pixbufR = Gdk::Pixbuf::create(s, x, y, width, scale * height);

// 2. fill m_refPixbuf with interlacing lines from pixmaps created above 
for (int i = 0 ; i < scale*height ; i++)
    if (i%2)
        pixbufL->copy_area(0, i, width, 1, m_refPixbuf, 0, i);
        pixbufR->copy_area(0, i, width, 1, m_refPixbuf, 0, i);
// 3. render the interlaced image
Gdk::Cairo::set_source_pixbuf(cr, m_refPixbuf);
return true;


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.