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



Hi Jody,

You're probably creating a Pixmap from the drawing area's X Window, not
from its GL buffer. Have a look at glReadPixels [1]; it'll copy the
frame buffer to main memory, so you can save it to a file.

Best regards,
Thomas

[1] http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml

Am Dienstag, den 22.05.2012, 16:18 +0200 schrieb jody:
> 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
> _______________________________________________
> gtkglext-list mailing list
> gtkglext-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkglext-list

-- 
GnuPG:          http://tdz.users.sourceforge.net/tdz.asc
Fingerprint:    16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08

jsapigen - A free glue-code generator for Mozilla SpiderMonkey. See
http://jsapigen.sourceforge.net for more information.

Attachment: signature.asc
Description: This is a digitally signed message part



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