Re: GdkGLPixmap troubles



Well, I've solve the initial issue---I was trying to cast a GdkPixmap when I should have been trying to cast a GdkGLPixmap. The bad cast warning was hidden because I'd forgotten I'd closed stderr on that program.

However, the images aren't coming out right when the "host window" isn't on-screen. This is odd, since the pixmap is supposed to be sharing lists, textures, etc with the window's context, but not otherwise related to anything on-screen.

It *looks* to me like what's getting drawn when the window is off-screen is a small part of the image, almost as if the orthographic projection were messed up; but I've checked that, it's fine. So is the viewport. So it must be something else?

----- Original Message -----
From: Lindley M French <lfrench1 gmu edu>
Date: Wednesday, August 26, 2009 2:46 pm
Subject: [GtkGLExt] GdkGLPixmap troubles

> 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?
> _______________________________________________
> gtkglext-list mailing list
> gtkglext-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkglext-list
> 


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