Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rotate = ref 1.0
- let _ = Sdl.init [`VIDEO] ; at_exit Sdl.quit
- let key_handler k = match k with
- | {Sdlevent.keysym=Sdlkey.KEY_ESCAPE} ->
- print_endline "I'll miss you so much..." ;
- | {Sdlevent.keysym=Sdlkey.KEY_SPACE} ->
- print_endline "UP" ;
- | {Sdlevent.keysym=Sdlkey.KEY_DOWN} ->
- print_endline "DOWN";
- | _ -> ()
- let renderScene () =
- let current_time = ref (Sdltimer.get_ticks()) in
- GlClear.clear[`color;`depth];
- GlMat.rotate3 (!rotate) (0.0,0.0,1.0);
- GlDraw.begins `quad_strip;
- GlDraw.color (1.0, 0.0, 0.0);
- GlDraw.vertex3 (-0.5, 0.5, 0.0);
- GlDraw.vertex3 (-0.5, -0.5, 0.0);
- GlDraw.color (0.0, 0.0, 1.0);
- GlDraw.vertex3 (0.5, 0.5, 0.0);
- GlDraw.vertex3 (0.5,-0.5, 0.0);
- GlDraw.ends ();
- current_time := Sdltimer.get_ticks() - !current_time;
- if(!current_time < 10) then
- Sdltimer.delay (10 - !current_time);
- Glut.swapBuffers();
- Glut.postRedisplay();
- begin
- match Sdlevent.poll () with
- | Some (Sdlevent.KEYDOWN k) ->
- print_endline "nope"; key_handler k
- | None | _ -> print_endline "nopeee";
- end;
- Gl.flush();;
- 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:"3DMapPro - Edition Expert Business 2012");
- GlClear.color(1.,1.,1.);
- Glut.displayFunc ~cb:(renderScene);
- print_string "oui";
- Glut.keyboardFunc (fun ~key ~x ~y -> if key=27 then exit 0);
- Glut.mainLoop();;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement