我是Haskell的初學者,嘗試了GPipe。在Haskell中,如何爲這個函數提供正確的編號?
下面的代碼罰款運行:
shader <- compileShader $ do
primitiveStream <- toPrimitiveStream id
let transPrims = fmap
(\(pos,col) -> (perspective (pi/3) 1 1 100 !* pos, col))
primitiveStream
fragmentStream <- rasterize
(const (FrontAndBack, ViewPort (V2 0 0) (V2 500 500), DepthRange 0 1))
transPrims
drawContextColor (const (ContextColorOption NoBlending (V3 True True True)))
fragmentStream
不過,我有2個變量WINDOWWIDTH和WINDOWHEIGHT(包括類型爲int),當我嘗試這樣做:
shader <- compileShader $ do
primitiveStream <- toPrimitiveStream id
let transPrims = fmap
(\(pos,col)
-> (perspective (pi/3) (windowWidth/windowHeight) 1 100 !* pos, col))
primitiveStream
fragmentStream <- rasterize
(const (FrontAndBack, ViewPort (V2 0 0) (V2 500 500), DepthRange 0 1))
transPrims
drawContextColor (const (ContextColorOption NoBlending (V3 True True True)))
fragmentStream
我得到編譯錯誤:
Couldn't match type ‘S V Float’ with ‘Int’
Expected type: Shader
os
(ContextFormat RGBFloat())
(PrimitiveArray Triangles (B4 Float, B3 Float))
(PrimitiveStream Triangles (V4 Int, V3 VFloat))
Actual type: Shader
os
(ContextFormat RGBFloat())
(PrimitiveArray Triangles (B4 Float, B3 Float))
(PrimitiveStream Triangles (VertexFormat (B4 Float, B3 Float)))
想到它可能想要一個浮點數,我做(toFloat $ windowWidth/windowHeight)
:
Couldn't match type ‘Float’ with ‘S V Float’
Expected type: VFloat
如何獲得VFloat?
'(WINDOWWIDTH ::智力)/(WINDOWHEIGHT ::智力)'是一種錯誤。這不是報告的錯誤,但它是一個錯誤。 – crockeea