我想将 Double 转换为 GLfloat。我想用它来做比较。
xM <- newIORef 0.0
zM <- newIORef 0.0
mobs <- newIORef []
mapM_ (\x -> colision x xM) mobs
mobs 充满了一种方法。
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..."
当我尝试编译它时,会显示此错误:
“无法将 'Foreign.C.Types.CDouble' 类型与 'Foreign.C.Types.CFloat' 预期类型匹配:GLfloat
实际类型:GLdouble
- - -解决方案: - - -
我使用这段代码:
import GHC.Float
d2f = realToFrac :: GLdouble -> GLfloat