Expose events and scissoring

I'm still trying to create a "screenshot" mechanism for my GtkDrawingArea which will work even when the area isn't visible on-screen. I've made progress, but there's still a problem.

The GtkDrawingArea is OpenGL-enabled (cc'ing to the GtkGLExt list), and it's very difficult to draw OpenGL to an offscreen buffer without using OpenGL extensions, which I'd prefer to avoid. So my strategy is to do a normal expose event and just glReadPixels() the image from the GL_BACK buffer before the gdk_gl_drawable_swap_buffers() call.

The code works insofar as the expose event is triggered and the image written. However, the image which gets written often contains portions which aren't drawn properly. I'm presuming that the expose events aren't for the entire window (despite the fact that invalidated the whole thing), and that the rest is being silently scissored off somehow and left untouched.

I *could* try first doing a glReadPixels on the front buffer.....one hopes that anything not currently being exposed would be there. But that seems a bit dodgy. I'd prefer to have a way to force the entire drawing area to get drawn.

Anyone have any ideas?

The code is as follows:

me->screenshot_dest = img;//Flag to indicate the next expose should write to img
GdkWindow *wind = gtk_widget_get_parent_window(me->drawarea);
GdkEventExpose expose;
expose.type = GDK_EXPOSE;
expose.window = wind;
expose.send_event = TRUE;
expose.area.x = 0;
expose.area.y = 0;
expose.area.width = 0;
expose.area.height = 0;
expose.region = NULL;
expose.count = 0;
GdkEvent e;
e.expose = expose;
me->screenshot_dest = NULL;//done

I did wonder whether the fact that my expose event has 0 size would make a difference; I don't use the parameter in my function, but I really don't understand the mechanism well enough to say where else it might be relevant.

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