Re: Saving OpenGL image to file



Solved.
The routine below does the job.�
(Sorry for wasting your time)

// Class "scene" inherits from Gtk::GL::DrawingArea).
void
scene::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" );
}



On Thu, Mar 24, 2011 at 5:31 PM, Samuel Pelaez <samuel pelaez gmail com> wrote:
Hi,

I am developing a GUI for data visualization using OpenGL. This is done through the gtkglextmm library, using the Gtk::GL::DrawingArea widget.

Now I want to add the "Save image" feature. As far as I understand, saving images in gtk is done through Gdk::Pixbuf objects, which can be instantiated from a Gdk::Drawable, but NOT from a Gdk::GL::Drawable.

My problem is: How do I create an instance of Gdk::Pixbuf if all I have is a Gdk::GL::Drawable (or Gdk::GL::DrawingArea)??

Any suggestions will be highly appreciated.
Best regards,
Samuel.




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