我正在尝试遵循本教程,当我尝试构建项目时编译器会返回此错误
No instance for (Fractional (GLdouble -> GLdouble))
arising from a use of `keyboard'
Possible fix:
add an instance declaration for (Fractional (GLdouble -> GLdouble))
In the first argument of `Just', namely `(keyboard pPos)'
In the second argument of `($=)', namely `Just (keyboard pPos)'
In a stmt of a 'do' block:
keyboardMouseCallback $= Just (keyboard pPos)
这是代码
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT as GLUT
import Squares
import OrbitingPointOfView
import ColorCube
import Data.IORef
main = do
(progName,_) <- getArgsAndInitialize
initialDisplayMode $= [WithDepthBuffer,DoubleBuffered]
createWindow progName
depthFunc $= Just Less
pPos <- newIORef (90::Int, 270::Int, 2)
keyboardMouseCallback $= Just (keyboard pPos) -- <--- causes the problem
displayCallback $= display pPos
reshapeCallback $= Just reshape
mainLoop
display pPos = do
loadIdentity
setPointOfView pPos
clear [ColorBuffer,DepthBuffer]
colorCube 1
swapBuffers
keyboard pPos c _ _ _ = keyForPos pPos c
指导我如何解决这个问题...