Re: [GtkGLExt] capturing video clips





The real issue with this which is also an issue for taking screenshots, is that the obscured parts of an onscreen widget like a gtk_drawing_area will have "junk" in them (not get rendered) and so there will be junk in your captured image/movie. For example, I'd go for a coffee, my screensaver would kick in and my encoder would record nothing but junk.

To prevent this, it is good to switch to using an offscreen widget. For example, use a GtkImage to display an offscreen "GdkPixmap" and render your OpenGL scenes to the GdkPixmap. This way, the GdkPixmap is always fully rendered because it is offscreen and "captures" of the GdkPixmap (NOT THE GtkImage) are always right regardless of whether GtkImage is fully rendered or not. However, I have had tones of troubles getting GdkPixmap rendering to work and it still doesn't work on many graphics card (offscreen rendering not working well at all!). If you are using a GdkPixmap, then the corresponding call above would be replaced by:

---------------------------------------

screenshot = gdk_pixbuf_get_from_drawable( screenshot, GDK_DRAWABLE(pixmap), gdk_colormap_get_system(), 0, 0, 0, 0, scapture.enc_width, scapture.enc_height );

Where:

GdkPixmap *pixmap;
pixmap = gdk_pixmap_new( NULL, width, height, gdk_gl_config_get_depth(glconfig) );
glpixmap = gdk_pixmap_set_gl_capability( pixmap, glconfig, NULL );
gtk_image_set_from_pixmap( GTK_IMAGE(image), pixmap, NULL );

-----------------------------------------
or you could just try reading the back buffer from OpenGL directly, with glReadPixels. No extra pixmap no nothing. the call is simple:

glReadBuffer(GL_BACK);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

if you're not using double buffering, this might not work.

where width and height are the size of your gl window, and pixels is a pointer to a buffer of width * height * 3 bytes (for RGB)

http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/readbuffer.html
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/readpixels.html



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