1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| let idList = ref None
let addPoints pnts =
GlDraw.begins `points;
List.iter GlDraw.vertex3 pnts;
GlDraw.ends();;
let renderScene() =
GlClear.clear[`color;`depth];
begin match !idList with
| None ->
let _list = GlList.create `compile_and_execute in
GlDraw.color (0.0, 0.0, 0.0);
addPoints [ 0.0, 0.0, 1.0;
0.2, 0.2, 1.0;
(-0.2), 0.2, 1.0;
0.2, (-0.2), 1.0;
(-0.2), (-0.2), 1.0 ];
GlList.ends(); (* Une fois tous les points ajout,
on termine la liste *)
idList := Some _list;
| Some idList ->
GlList.call idList; (* Affiche toute la liste *)
end;
Gl.flush();
Glut.swapBuffers();
Glut.postRedisplay();
;;
let () =
ignore(Glut.init Sys.argv);
Glut.initDisplayMode ~alpha:true ~double_buffer:true ~depth:true ();
Glut.initWindowPosition ~x:100 ~y:100;
Glut.initWindowSize ~w:500 ~h:500;
ignore(Glut.createWindow ~title:"Afficher un point");
GlClear.color(1.0,1.0,1.0);
Glut.displayFunc ~cb:renderScene;
Glut.keyboardFunc ~cb:(fun ~key ~x ~y -> if key = 27 then exit 0);
Glut.mainLoop();; |
Partager