[Haskell-cafe] New OpenGL package: efficient way to convert
datatypes?
Peter Verswyvelen
bugfact at gmail.com
Wed Sep 30 11:06:04 EDT 2009
I don't want to use the GL types directly since the OpenGL renderer is not
exposes in the rest of the API.
I was hoping that realToFrac would be a nop in case it would be identical to
an unsafeCoerce.
I guess one could make rules for that, but this tickets makes me wander if
that really works:
http://hackage.haskell.org/trac/ghc/ticket/1434
On Wed, Sep 30, 2009 at 4:58 PM, Roel van Dijk <vandijk.roel at gmail.com>wrote:
> If you are *really* sure that the runtime representation is the same
> you could use usafeCoerce. You could use a small test function for
> profiling, something like:
>
> convertGLfloat :: GLfloat -> Float
> convertGLFloat = realToFrac
> -- convertGLFloat = unsafeCoerce
>
> and toggle between the two (assuming you won't get a segmentation fault).
>
> Another option is to not convert at all but use the GL types
> everywhere. Either explicitly or by exploiting polymorphism.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090930/385cf85c/attachment.html
More information about the Haskell-Cafe
mailing list