[Haskell-cafe] Loading a texture in OpenGL

Ben Lippmeier 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 [1].

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.

Ben.

[1] http://www.haskell.org/ghc/docs/latest/html/libraries/haskell2010-1.1.0.1/Foreign-ForeignPtr.html


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120207/9c06cae8/attachment.htm>


More information about the Haskell-Cafe mailing list