I want to convert a Double to a GLfloat. I want to use it for comparations.
xM <- newIORef 0.0
zM <- newIORef 0.0
mobs <- newIORef []
mapM_ (\x -> colision x xM) mobs
mobs is fulled with a method.
colision mob xC = do
xcama <- get xC
--zcama <- get zC
let menor = mob!!0
let mayor = mob!!7
--if xm>= xmin && xm <= xmax && zm >= zmin && zm <= zmax then renderText (1, (-1.4)) $ "Dead"
--else renderText (1, (-1.4)) $ "Warning..."
renderText (1, (-1.4)) $ "Warning..."
When I try to compile it show me this error:
"Couldn't match type 'Foreign.C.Types.CDouble' with 'Foreign.C.Types.CFloat' Expected type :GLfloat
Actual type: GLdouble
-----Solution:------
I use this code:
import GHC.Float
d2f = realToFrac :: GLdouble -> GLfloat
The general function to use to convert between different floating point types (and some others, such as Rational
) is realToFrac
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With