Skip to content

Instantly share code, notes, and snippets.

@fffej
Created May 11, 2010 06:43
Show Gist options
  • Save fffej/396987 to your computer and use it in GitHub Desktop.
Save fffej/396987 to your computer and use it in GitHub Desktop.
trun :: Double -> Double -> GLfloat
trun h i = realToFrac ((i-0.5) * h) :: GLfloat
drawVelocity :: (Grid,Grid) -> IO ()
drawVelocity (u,v) = do
color3f (Color3 1 1 1)
lineWidth $= 1.0
let h = 1.0 / realToFrac n
let f = trun h
renderPrimitive Lines $ forM_ [(x,y) | x<-[1..n], y<-[1..n] ]
(\(i,j) ->
do
uV <- readVal u (i,j)
vV <- readVal v (i,j)
vertex2f (Vertex2 (f (realToFrac i)) (f (realToFrac j)))
vertex2f (Vertex2 (f ((realToFrac i) + uV)) (f ((realToFrac j) + vV))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment