Boost logo

Boost :

Subject: Re: [boost] [flyweight] key value with objects not constructible from a key
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-11-13 09:01:55


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.

> A singleton isn't really a good fit for a flyweight factory of OpenGL
> textures.
>
> As for the image loaders themselves for at least some of them I have to
> create multiple instances in order to use them concurrently.

You could have a global concurrent queue and you could take one from it
to load a file then put it back once done.


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