[Haskell-cafe] Loading a texture in OpenGL
benl at ouroborus.net
Tue Feb 7 04:49:06 CET 2012
On 07/02/2012, at 2:40 PM, Clark Gaebel wrote:
> Awesome. Thanks!
> As a follow up question, how do I add a finalizer to a normal variable? OpenGL returns an integer handle to your texture in graphics memory, and you have to call deleteObjectNames on it. Is there any way to have this automatically run once we lose all references to this variable (and all copies)?
I don't know. I've only used ForeignPtrs with finalisers before .
One problem with these finalisers is that GHC provides no guarantees on when they will be run. It might be just before the program exits, instead of when the pointer actually becomes unreachable. Because texture memory is a scarce resource, I wouldn't want to rely on a finaliser to free it -- though I suppose this depends on what you're doing.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe