Anonymous user
Loading animated 3D data/OCaml: Difference between revisions
m
style improvements
m (libs used) |
m (style improvements) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1:
{{libheader|glMLite}}
{{libheader|xml-light}}
{{libheader|GLUT}}
<lang ocaml>(* loading the libraries *)
Line 141 ⟶ 143:
let parse_shape_contents c =
let geom = parse_geom(List.
and appearance = List.fold_left appearance_fold [] c in
let shape = (geom, appearance) in
Line 261 ⟶ 263:
let display scene = function () ->
glClear [GL_COLOR_BUFFER_BIT; GL_DEPTH_BUFFER_BIT];
glLoadIdentity ();
List.iter (function
Line 294 ⟶ 296:
glColor3v (get_val3 !t color)
) appearance;
glPushMatrix ();
glScalev (get_val3 !t size);
glutSolidCube ~size:1.0;
glPopMatrix ();
| _ -> () (* TODO other primitives *)
Line 306 ⟶ 308:
) scene;
glFlush ();
glutSwapBuffers ();
;;
Line 313 ⟶ 315:
let reshape ~width ~height =
glMatrixMode GL_PROJECTION;
glLoadIdentity ();
gluPerspective 30. (float width /. float height) 2. 30.;
glViewport 0 0 width height;
glMatrixMode GL_MODELVIEW;
glutPostRedisplay ();
;;
Line 329 ⟶ 331:
let () =
ignore(glutInit Sys.argv);
glutInitDisplayMode [GLUT_RGBA; GLUT_DOUBLE; GLUT_DEPTH];
glutInitWindowPosition ~x:200 ~y:200;
glutInitWindowSize ~width:400 ~height:300;
Line 348 ⟶ 350:
glutReshapeFunc ~reshape;
glutKeyboardFunc ~keyboard;
glutMainLoop ();
;;</lang>
|