Re: [GtkGLExt] Fwd: reparenting a GtkDrawingArea with OpenGL




>Date: Wed, 20 May 2009 15:08:57 -0400
>From: Braden McDaniel <braden endoframe com>
>Subject: Re: [GtkGLExt] Fwd:  reparenting a GtkDrawingArea with OpenGL
>To: gtkglext-list gnome org
>Message-ID: <4A145549 1040806 endoframe com>
>Content-Type: text/plain; charset=UTF-8; format=flowed
>
>On 5/20/09 2:43 PM, Jeff Eberl wrote:
>
>> After a lot of print statements, and some new callbacks, I've discovered
>> half of the problem.
>>
>> I was keeping the gtkContext* around, and it's been invalidated. So a
>> simple call to gtk_widget_get_gl_context fixed that.
>>
>> I connected to the realize and unrealize signals, and the remove calls
>> unrealize, and the add calls realize. But there is another problem, the
>> glLists and glTextures seem to be getting invalidated. Looking at the
>> gears code, it looks like the realize creates a new list (glGenList) but
>> there's no where that the list gets deleted. Does this mean the gears
>> app is leaking video resources? Or is it getting cleaned up somewhere?
>
>Technically, yes. But I think that the video driver will clean up any
>resources associated with the context when the context goes away.
>
>> For now, I'm going to delete all lists and textures in the unrealize
>> event, and create them again in the realize event. I'm hoping this is
>> overkill, and someone knows how to fix, or revalidate the lists/textures
>> without completely reallocating them.
>
>I think deleting them yourself is the safe, responsible thing to
>do--kind of like freeing memory in a C program.  Sure, most modern
>operating systems will reacquire the memory when the process ends; but
>even in programs that aren't expected to be long running it's considered
>good practice to release resources when you're done with them.
>
>I do not think there's any way to "revalidate" these resources.  But are
>you really going to be swapping these widgets around so much that the
>cost of reallocation is likely to be onerous?

The real issue with recreating these lists is that this application is networked, and the lists are the only local storage of some information.  So recreating the list is a pain, because I'd need to store the drawing items locally, and then redraw them when someone switched the two widgets.  I did find a solution (in this list's archive actually).  Basically, you create a gdkPixmap with a shared context with my widget.  I never do anything with the pixmap, so It doesn't cost much, and the lists and textures never get removed from video memory when I reparent the windows.  Can I link directly to the previous post? Here is the solution I found: http://mail.gnome.org/archives/gtkglext-list/2005-January/msg00012.html

So I added that, and I also still need to make sure to "get" the context pointer each time I use it, because it still changes after a reparent (that's not that surprising, I should have been doing that all along).

Thanks for your help.



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