Re: [GtkGLExt] Sharing display lists among a dynamic set of widgets [solved]



Thierry Bernier wrote:

I have a similar problem under MinGW (over XP) : when I reparent a Widget containing a GtkGLExtended widget in its children tree, the displqy lists are losts after the reparent. Every other GL call works, but calling the lists draws nothing.

The solution for me was to create a GdkGLPixmap that matches the screen depth, generate a GdkGLContext for it, and use that as the shared list context for all of my views. Using an offscreen pixmap solves the problem of how to create a hidden widget and where to put it. A code snippet without error-handling and cleanup:

/** Returns a global GdkGLContext that can be used to share
    OpenGL display lists between multiple drawables with
    dynamic lifetimes */
GdkGLContext* get_share_list()
{
   static GdkGLContext* share_list = 0;

   if(!share_list)
     {
       GdkGLConfig* const config = gdk_gl_config_new_by_mode(
         static_cast<GdkGLConfigMode>(
           GDK_GL_MODE_RGBA |
           GDK_GL_MODE_DOUBLE |
           GDK_GL_MODE_DEPTH));

       GdkPixmap* const pixmap =
         gdk_pixmap_new(0, 8, 8, gdk_gl_config_get_depth(config));

       GdkGLPixmap* const glpixmap =
         gdk_pixmap_set_gl_capability(pixmap, config, 0);

       share_list = gdk_gl_context_new(
         gdk_pixmap_get_gl_drawable(pixmap), 0, true, GDK_GL_RGBA_TYPE);
    }

  return share_list;
}

I will post a bug, if you think this is really one.

I'd check to see what reparenting is doing, first. Since GLX context is tied closely to individual drawables, it wouldn't surprise me to see that things stop working if the drawable changes, which I assume is happening when you reparent.

Cheers,
Tim




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