[Haskell-cafe] Re: Wrapping FTGL in FFI calls
Jules Bean
jules at jellybean.co.uk
Fri Jun 20 16:43:51 EDT 2008
Sorry, it's "realToFrac". Typo!
Jefferson Heard wrote:
> Exactly. thanks!
>
> On Fri, Jun 20, 2008 at 4:26 PM, Jules Bean <jules at jellybean.co.uk
> <mailto:jules at jellybean.co.uk>> wrote:
>
> Jefferson Heard wrote:
>
> Oh, and I should say the function I want to implement is
>
> getFontBBox :: Font -> String -> IO [Float]
>
> I do know how to marhsal/unmarshal the String. Just not the
> CFloat array to Haskell [Float]
>
>
> import Foreign.C
> import Foreign.Ptr
> import Foreign.Marshal.Array
>
> import Control.Applicative((<$>))
>
> oneway :: Ptr CFloat -> IO [Float]
> oneway p = map real2Frac <$> peekArray 4 p
>
> the other way you would probably want withArray, but I think this is
> the way you need?
>
>
>
>
>
> --
> I try to take things like a crow; war and chaos don't always ruin a
> picnic, they just mean you have to be careful what you swallow.
>
> -- Jessica Edwards
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list