Re: [AD] Open GL bitmaps

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tue, 2008-03-11 at 08:28 +0000, Peter Hull wrote:
> On Sat, Mar 8, 2008 at 10:31 AM, Milan Mimica <milan.mimica@xxxxxxxxxx> wrote:
> > Look at the comments for al_is_compatible_bitmap().
> That's fine, but a bit restrictive in general.

I think we should try to share the context if possible - but it may not
always be possible, e.g. if different windows use different pixel
formats or something like that. Maybe also allow the user to request to
share or not with a new display creation flag.

> Anyway a new problem has occurred. I've tightened up the thread
> safety/object lifetime of my implementation and started getting
> errors! In exnew_multiwin and exnewapi, bitmaps are created for the
> display, then the main loop runs until all the displays have been
> closed by the user, then the bitmaps are deleted. My problem is that
> closing the display closes the OpenGL context and therefore the
> textures are invalid. When the bitmaps are destroyed I get an access
> violation in glDeleteTextures.
> 
> Possible solutions are for each display to manage its bitmaps, or
> simply to hold on to a global reference to the GL context while the
> app is running (all Cocoa memory management is done by reference
> counting)
> 
> Any thoughts on this one?
> 

Without thinking about it too much, I would say each display should
manage its bitmaps. Simply keep a list of them - then when the display
is closed, delete the textures (and set the texture field in each bitmap
to 0). We should also find some clever way to re-attach the bitmaps to a
display later so they could upload their memory copies as textures
again.

For shared contexts, only the last display should do that of course, so
for that some kind of reference counting is probably needed - unless the
underlying OpenGL implementation already does it for us, so a function
like GLX_release_context(context) would do nothing unless the passed
context has only a single user left.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/