let vertices = [(-1., -1., -1.); (-1., 1., -1.); ( 1., 1., -1.); ( 1., -1., -1.); ( 1., -1., 1.); ( 1., 1., 1.); (-1., 1., 1.); (-1., -1., 1.);];; let faces = [[3; 2; 1; 0]; [7; 6; 5; 4]; [7; 4; 3; 0]; [1; 2; 5; 6]; [3; 4; 5; 2]; [0; 1; 6; 7]];; let color = [(1., 1., 1.); (0., 1., 1.); (1., 1., 0.); (1., 0., 1.); (1., 0., 0.); (0., 0., 1.)];; let display () = GlClear.clear [`color; `depth]; (* типа clear_graph () *) GlDraw.color (0.3, 0.5, 0.7); GlDraw.begins `polygon; GlDraw.vertex3 (-2.0, 2.0, -1.01); GlDraw.vertex3 (-2.0, -2.0, -1.01); GlDraw.vertex3 ( 2.0, -2.0, -1.01); GlDraw.vertex3 ( 2.0, 2.0, -1.01); GlDraw.ends (); List.iter2 (fun face color -> GlDraw.color ~alpha:0.5 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 | 49 -> GlMat.rotate ~angle:2.0 ~x:1.0 (); display () | 50 -> GlMat.rotate ~angle:2.0 ~y:1.0 (); display () | 51 -> GlMat.rotate ~angle:2.0 ~z:1.0 (); display () | _ -> Printf.printf "Unknown key: %d" key;; let main () = ignore(Glut.init Sys.argv); Glut.initDisplayMode ~alpha:true ~depth:true () ; Glut.initWindowSize ~w:500 ~h:500 ; ignore(Glut.createWindow ~title:"Cube"); GlMat.ortho ~x:(-4.0,4.0) ~y:(-4.0,4.0) ~z:(-4.0,4.0); GlDraw.cull_face `back; Gl.enable `cull_face; Gl.enable `blend; Gl.enable `depth_test; GlClear.color (0.5, 0.5, 0.5); (* цвет фона *) Glut.displayFunc ~cb:display; Glut.keyboardFunc ~cb:keyboard; Glut.mainLoop (); ;; main ();;