fork download
  1. module PointsRendering (
  2. display,
  3. Point
  4. ) where
  5.  
  6. import Graphics.UI.GLUT
  7. import Graphics.Rendering.OpenGL
  8. import Random
  9.  
  10.  
  11. type Point = (GLfloat, GLfloat, GLfloat)
  12.  
  13.  
  14. makeVertx = mapM_ (\(x,y,z) -> vertex $ Vertex3 x y z)
  15.  
  16. getRand :: IO Float
  17. getRand = getStdRandom (randomR (0,1))
  18.  
  19.  
  20. renderAs :: PrimitiveMode -> [Point] -> IO ()
  21. renderAs mode points = renderPrimitive mode (makeVertx points)
  22.  
  23. renderInWindow displayFunction = do
  24. (progName,_) <- getArgsAndInitialize
  25. createWindow "Primitive shapes"
  26. displayCallback $= displayFunction
  27. mainLoop
  28.  
  29.  
  30. displayPoints :: PrimitiveMode -> [Point] -> IO ()
  31. displayPoints mode points = do
  32. renderAs mode points
  33. flush
  34.  
  35. display :: PrimitiveMode -> [Point] -> IO ()
  36. display mode points = renderInWindow (display' mode points)
  37.  
  38. display' :: PrimitiveMode -> [Point] -> IO ()
  39. display' mode points = do
  40. clear [ColorBuffer]
  41. currentColor $= Color4 0 0.3 1 1
  42. displayPoints mode points
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty