[GtkGLExt] capturing an opengl image, or painting OpenGL into a pixbuf?



Hi
I am trying to find a way to capture and save to file the current
contents of a Gtk::GL::DrawingArea.
Googling for this i found a method by Samuel Pelaez:

(IQScene is a Gtk::GL::DrawingArea)
void IQScene::save_image() {

    // First, get the Config
    Glib::RefPtr< Gdk::GL::Config > glconfig;
    glconfig = get_gl_config();

    // Second, create a Gdk::Pixmap
    Glib::RefPtr< Gdk::Pixmap > pixmap;
    pixmap = Gdk::Pixmap::create(get_window(),
                                 get_width(), get_height(),
                                 glconfig->get_depth() );

    // Create a Gdk::Drawable from pixmap
    Glib::RefPtr< Gdk::Drawable > drawable( pixmap );

    // Now create the Gdk::Pixbuf
    Glib::RefPtr< Gdk::Pixbuf > pixbuf;
    pixbuf = Gdk::Pixbuf::create( drawable,0,0,get_width(),get_height() );

    // And finally save the image
    pixbuf->save( "image.jpg", "jpeg" );
}

When i use this method, an image with the dimensions of my IQScene is created.
However the ontents of the image is different, everytime the method is called.
It usually consists of little fragments from menu bars, other widgets
of my application, or the terminal window.

Does anybody see where the problem could be?

Or is there maybe a possibility to draw OpenGL directly into a pixbuf?

Thank You
  Jody


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