Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-07 Thread L Corbijn
On Tue, Feb 7, 2012 at 5:23 AM, Austin Seipp mad@gmail.com wrote: Just to clarify, this guarantee possibly could be made, ghc just doesn't do it now. In the past ghc never guaranteed a finalizer would ever be run. Regardless I would be wary of trusting finalizers to clean up very scarce

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-07 Thread Clark Gaebel
Sounds hairy. Is there any way to get reference counting garbage collection in Haskell? On Tue, Feb 7, 2012 at 9:26 AM, L Corbijn aspergesoe...@gmail.com wrote: On Tue, Feb 7, 2012 at 5:23 AM, Austin Seipp mad@gmail.com wrote: Just to clarify, this guarantee possibly could be made, ghc

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-07 Thread Alex Mason
It's possible ResourceT from the yesod guys could be quite useful. It allows you to manually release things, but also ensures that things are released in case of exceptions. It also supports, from what I can tell, some kind of reference counting for use with multiple threads (the deallocator isn't

[Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Using the OpenGL package on Hackage, how do I load a texture from an array? In the red book[1], I see their code using glGenTextures and glBindTexture, but I can't find these in the documentation. Are there different functions I should be calling? [1] http://glprogramming.com/red/chapter09.html

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Jason Dagit
On Mon, Feb 6, 2012 at 12:00 PM, Clark Gaebel cgae...@csclub.uwaterloo.ca wrote: Using the OpenGL package on Hackage, how do I load a texture from an array? The answer will depend on a few things: * Which OpenGL package you use, for example OpenGL vs. OpenGLRaw * What type of 'array' you

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Thank you both. I'll be sure to try these out. As a matter of fact, I _am_ using JuicyPixels. I didn't realize there was a version on github which uses Vector. Thanks for letting me know. Regards, - clark On Mon, Feb 6, 2012 at 5:55 PM, Jason Dagit dag...@gmail.com wrote: On Mon, Feb 6,

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Ben Lippmeier
On 07/02/2012, at 7:00 AM, Clark Gaebel wrote: Using the OpenGL package on Hackage, how do I load a texture from an array? In the red book[1], I see their code using glGenTextures and glBindTexture, but I can't find these in the documentation. Are there different functions I should be

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
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

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Ben Lippmeier
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

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
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 b...@ouroborus.net wrote: On 07/02/2012, at 2:40 PM, Clark Gaebel wrote:

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Ben Lippmeier
On 07/02/2012, at 2:50 PM, Clark Gaebel wrote: 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. From the docs: newForeignPtr :: FinalizerPtr a - Ptr a - IO (ForeignPtr

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Is the Haskell garbage collector conservative, or precise? If it's conservative, then this will only usually work. If it's precise, it should always work. On Mon, Feb 6, 2012 at 10:56 PM, Ben Lippmeier b...@ouroborus.net wrote: On 07/02/2012, at 2:50 PM, Clark Gaebel wrote: I would be

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Austin Seipp
It's a precise GC of course (conservative collection would be madness considering how much memory Haskell programs chew through.) That still doesn't ensure your finalizer will run during the next GC even if all the references are gone by then. Sent from my iPhone^H^H^H^H^HPortable Turing machine

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Even the next major, manually triggered GC? I'm just dealing with GHC here, if that simplifies the discussion. Although important and good to know, I don't really care what the spec says here. I just want to know if, with the current implementation of GHC, finalizeres will be run if a GC is

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Austin Seipp
Just to clarify, this guarantee possibly could be made, ghc just doesn't do it now. In the past ghc never guaranteed a finalizer would ever be run. Regardless I would be wary of trusting finalizers to clean up very scarce resources. A malloc'd buffer is probably fine to have a finalizer for,