[HOpenGL] 2D textures with OpenGL and GLUT

Jason Dagit dagitj at gmail.com
Tue Jul 8 16:32:03 UTC 2014


On Tue, Jul 8, 2014 at 9:20 AM, Elise Huard <haskell at elisehuard.be> wrote:

> I wanted to thank you, because pointing to unsafeCoerce was a nice bit
> of serendipity.  I'll admit I thought it was nitpicking initially, but
> I did a quick pass at cleaning things up last week after your mail
> (not perfect, but this was a prototype so I'm not looking for pretty):
>
>
> https://github.com/elisehuard/game-prototype/commit/5cf85fa60f325dbe610b5e1f017c9427e304daf6
>
> and that fixed the texture mapping!
> Consider me informed on that issue :)
>

Cool! By the way, the 'proper way' to convert between Double and CDouble is
to use realToFrac:

Prelude Foreign.C.Types λ> realToFrac (1 :: Double) :: CDouble
1.0

In specific case like this (Double <-> CDouble) it should be equivalent
(but as a user of the library you shouldn't depend on know that). In some
cases it can be a performance hit, but that's what RULEs pragmas are for.
Moreover, some versions of the Haskell OpenGL bindings made it so that
GLdouble was not the same type as CDouble. So the safest way is to use
realToFrac and depend on the library writer to provide RULEs that make it
efficient.

I hope that helps,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/hopengl/attachments/20140708/daf64bbc/attachment.html>


More information about the HOpenGL mailing list