let vertices = [] let faces = [] let color = Array.to_list (Array.init 0 (fun _ -> Random.float 1.0, Random.float 1.0, Random.float 1.0)) let name = "" let size = 3.0 let display () = GlClear.clear [`color]; List.iter2 (fun face color -> GlDraw.color color; GlDraw.begins `polygon; List.iter (fun i -> GlDraw.vertex3 (List.nth vertices i)) face; GlDraw.ends (); ) faces color; Gl.flush (); Glut.swapBuffers ();; let keyboard ~key ~x ~y = match key with | 27 -> exit 0 | 119 -> GlMat.rotate ~angle: 2.0 ~x:1.0 (); display () (* up *) | 115 -> GlMat.rotate ~angle:(-.2.0) ~x:1.0 (); display () (* down *) | 97 -> GlMat.rotate ~angle: 2.0 ~y:1.0 (); display () (* left *) | 100 -> GlMat.rotate ~angle:(-.2.0) ~y:1.0 (); display () (* right *) | 113 -> GlMat.rotate ~angle: 2.0 ~z:1.0 (); display () (* spin left *) | 101 -> GlMat.rotate ~angle:(-.2.0) ~z:1.0 (); display () (* spin right *) | _ -> Printf.printf "Unknown key: %d\n" key;; let main () = ignore(Glut.init Sys.argv); Glut.initDisplayMode ~alpha:true ~depth:true () ; Glut.initWindowSize ~w:500 ~h:500 ; ignore(Glut.createWindow ~title:name); GlMat.ortho ~x:(-.size, size) ~y:(-.size, size) ~z:(-.size, size); GlDraw.cull_face `back; Gl.enable `cull_face; GlClear.color (0.5, 0.5, 0.5); (* цвет фона *) Glut.displayFunc ~cb:display; Glut.keyboardFunc ~cb:keyboard; Glut.mainLoop (); ;; main ();;