[Haskell-cafe] open gl type conversions
Sven Panne
svenpanne at gmail.com
Fri May 22 06:56:59 UTC 2015
2015-05-22 7:13 GMT+02:00 <briand at aracnet.com>:
> [...] GL.Size really needs a CInt so it seems like I have to do some sort
of explicit conversion, but I can never seem to figure out exactly how to
find the necessary function.
To be exact, Size expects 2 GLsizei
<http://hackage.haskell.org/package/OpenGLRaw-2.5.0.0/docs/Graphics-Rendering-OpenGL-Raw-Types.html#t:GLsizei>
arguments,
and GLsizei is a type synonym for CInt
<http://hackage.haskell.org/package/base-4.8.0.0/docs/Foreign-C-Types.html#t:CInt>,
but what this latter type actually is shouldn't matter most of the time.
The only thing you need to know here is that it's an integral number, and
your swiss army knife for conversion between integral numerical types is:
fromIntegral
<http://hackage.haskell.org/package/base-4.8.0.0/docs/Prelude.html#v:fromIntegral>
:: (Integral a, Num b) => a -> b
Don't be scared by its canonical definition (fromInteger . toInteger), GHC
has enough RULES to make this very efficient most of the time or even a
no-op.
Cheers,
S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150522/63351986/attachment.html>
More information about the Haskell-Cafe
mailing list