views:

172

answers:

1

Hi, I've been wanting to try out the FDX demo however it gave me a series of errors and warnings due to compatibility issues, so I've been trying to get it working correctly. The full code is on a pastebin.

I'm having trouble with the code here :

  let drawSurf f (device:Device) =
  let m,n = meshDims !mesh in 
  let data = Array.init (n*m) (fun k ->
                                 let i,j = k2ij !mesh k in
                                 let x,y = meshGet !mesh (i,j) in
                                 let z = f (x,y) in // single precision f 
                                 (x,y,z))
  in
  let strips = triangleRows n m |> map (map (blendPlace !mesh data)) in
  List.iter (fun strip -> drawTriangeStrip strip device) strips;
  let m,n = meshDims !mesh in 
  let lines = gridLines n m in
  let lines = lines |> map (colorPlace !mesh data Color.Black) in
  drawLineList lines device

which gives me the following error in F# interactive.

motion-sample.fs(438,53): error FS0001: Type mismatch. Expecting a
    ((('a * 'b) list -> 'c) * (('a * 'b) list -> 'd)) ref
but given a
    (float [,] * float [,]) ref.
The type '('a * 'b) list -> 'c' does not match the type 'float [,]'

Thanks for any help!

+1  A: 

I haven't had time to take a good look, but try changing the meshGet definition to

let meshGet (mesh:_[,]*_[,]) (i,j) = let X,Y = mesh in X.[i,j], Y.[i,j]

EDIT

Actually, even better, looks like there's a fresher copy at

http://code.msdn.microsoft.com/fsharpsamples/Release/ProjectReleases.aspx?ReleaseId=2705

you should use that rather than the years-old one posted on hubfs.

Brian
Thanks for the link!
Jean Azzopardi