[Haskell-cafe] New OpenGL package: efficient way to convert datatypes?

Roel van Dijk vandijk.roel at gmail.com
Wed Sep 30 10:58:55 EDT 2009


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.


More information about the Haskell-Cafe mailing list