Boost logo

Boost :

Subject: Re: [boost] [flyweight] key value with objects not constructible from a key
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-11-13 12:23:08


Mathias Gaunard wrote:
> Michael Marcin wrote:
>
>> When loading a texture in OpenGL the texture is bound to the current
>> OpenGL context which is stored per thread. OpenGL textures must be
>> destroyed and recreated when you change resolution because you must
>> also destroy and recreate your OpenGL context. A thread can have
>> multiple contexts but only 1 may be current at time. The collection of
>> textures, which flyweight stores in its factory, is logically bound to
>> the current render context on the current thread.
>
> So you need a per-context factory.
> Boost.Flyweight factories are global by design, the way I see them. So
> it's not ideal for what you want.
> You can get around this by putting the context in the key, however.
>

With the way OpenGL works only one context can be active at a time per
thread. By using a custom hold I think I can change the active factory
when I changed the active context.

I need to think about the factory in the key thing more though.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk