I'm trying to allow an offscreen render to a pixmap to occur now, instead of trying to force an expose event while a window is offscreen like I was before.
I've looked over the example code in pixmap.c that comes with GtkGLExt, but my adaptation of it isn't working. My configure-event handler: gboolean reshapeGL(GtkWidget *widget, GdkEventConfigure *evnt, gpointer data) { GUIWindow* me = (GUIWindow*)data; GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); assert(pthread_equal(me->mainthread, pthread_self())); fprintf(stderr,"reshaping window %d, %d %d %d %d\n",me->window_id,evnt->x,evnt->y,evnt->width,evnt->height); if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) return FALSE; me->lock(); me->xviewport = evnt->x; me->widthvp = evnt->width; me->yviewport = evnt->y; me->heightvp = evnt->height; glViewport(me->xviewport,me->yviewport,me->widthvp,me->heightvp); me->unlock(); gdk_gl_drawable_gl_end (gldrawable); if (me->osPixmap) g_object_unref(me->osPixmap); if (me->osContext) gdk_gl_context_destroy(me->osContext); me->osPixmap = gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height, -1); GdkGLConfig *glconfig = gdk_gl_config_new_by_mode ( GdkGLConfigMode(GDK_GL_MODE_RGB | GDK_GL_MODE_SINGLE)); GdkGLDrawable *osDrawable = GDK_GL_DRAWABLE ( gdk_pixmap_set_gl_capability (me->osPixmap, glconfig, NULL)); me->osContext = gdk_gl_context_new (osDrawable, glcontext, FALSE, GDK_GL_RGBA_TYPE); return FALSE; } That all works fine so far as I can tell. There may be some issues with when exactly I'm supposed to unref something; the whole reference counting scheme is less than well-documented. However, I'm not concerned about that for now. I also have this function, which is not linked to any particular event: gboolean doTakeScreenshot(gpointer data) { GUIWindow *me = (GUIWindow *)data; assert(pthread_equal(me->mainthread, pthread_self())); me->lock(); GdkGLDrawable *osDrawable = GDK_GL_DRAWABLE(me->osPixmap); if (!osDrawable || !me->osContext) { fprintf(stderr, "Warning, no offscreen pixbuf configured in aeGraphWindow::doTakeScreenshot.\n"); me->signal(&me->screenshot_complete); me->unlock(); return FALSE; } if (!gdk_gl_drawable_gl_begin (osDrawable, me->osContext)) { me->signal(&me->screenshot_complete); me->unlock(); return FALSE; } // OPENGL DRAWING HERE gdk_gl_drawable_wait_gl(osDrawable); glReadBuffer(GL_FRONT); glReadPixels(me->xviewport,me->yviewport,me->widthvp,me->heightvp, GL_RGBA,GL_UNSIGNED_BYTE,me->screenshot_dest->data[0]); me->signal(&me->screenshot_complete); me->unlock(); gdk_gl_drawable_gl_end (osDrawable); return FALSE; } It appears that gdk_gl_drawable_gl_begin() is failing here. What could cause that? Both the context and drawable being passed are valid pointers. However, I did notice that gdk_gl_context_get_gl_drawable(me->osContext) returned NULL, which I thought was odd. I'm not positive that my glReadPixels() is valid either, but I want to get past this hurdle before worrying about that one. Any ideas? _______________________________________________ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list