[Haskell-cafe] Loading a texture in OpenGL

Clark Gaebel cgaebel at csclub.uwaterloo.ca
Tue Feb 7 04:50:48 CET 2012

I would be running the GC manually at key points to make sure it gets
cleaned up. Mainly, before any scene changes when basically everything gets
thrown out anyways.

On Mon, Feb 6, 2012 at 10:49 PM, Ben Lippmeier <benl at ouroborus.net> wrote:

> 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-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120206/e73253a4/attachment.htm>

More information about the Haskell-Cafe mailing list