From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p41EOU4O032454 for ; Sun, 1 May 2011 16:24:30 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0BAPNsvU3RVdo2mGdsb2JhbACmEwgUAQEBAQEICQ0HFCWlZYJCinyCKoNjNIheAQEDBoV6BI55ijo7gy8 X-IronPort-AV: E=Sophos;i="4.64,297,1301868000"; d="scan'208";a="98433049" Received: from mail-yi0-f54.google.com ([209.85.218.54]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 May 2011 16:24:17 +0200 Received: by yie12 with SMTP id 12so2722750yie.27 for ; Sun, 01 May 2011 07:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=/WpJ1SvFVnHcZHbUt7ew/RHa7l1qU9IjT1v6ECZWNiM=; b=GxsXWS12pT95udPtkzxvDs9qsgwoaInnu/dmGDXs89I82zouegxnKao633oh6znMGh KZn9cdAyWE1AMARLM0WMFyO1dY562HLofeAtQ8drmDT4T4YRoaTStkO/EcYKwFd33yHT pc/DZqKBdlyFJgvbz+lB54qzk76TjdB0a6ydA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=XsJPKMjcy/JxS3RM9RH3QxLU6DY13PQLztHn/GFUQ0cPlu1EbWom31y9VS3rYq3rkE GWFaxxmHA7CX9ETrObBvJuWUqP92y4XDeH6BG5V4GsKwTbn/HHbqhYm0wHu2hEMapGmS b1PB9/vOG6mvus2ufJ+KPfEMzT4rZ+KanauBQ= MIME-Version: 1.0 Received: by 10.101.194.19 with SMTP id w19mr4361744anp.103.1304259852918; Sun, 01 May 2011 07:24:12 -0700 (PDT) Received: by 10.100.10.1 with HTTP; Sun, 1 May 2011 07:24:12 -0700 (PDT) Date: Sun, 1 May 2011 16:24:12 +0200 Message-ID: From: Peter Ronnquist To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Validation-by: peter.ronnquist@gmail.com Subject: [Caml-list] f#/mono vs ocaml runtime system - open gl animation screen tearing. While making the simple examples for SDL+opengl for the C language I realized that even the C version showed "stuttering" but the fsharp version is completely smooth and synced to the vblank. Appearantly the fsharp version somehow manages to sync to the vblank probably thanks to the openTK api: do base.VSync <- VSyncMode.On I had to configure the nvidia driver with X Server XVideo Settings: Video Texture Adaptor -> Sync to VBlank Video Blitter Adaptor Settings -> Sync to VBlank OpenGL Settings Performance -> Sync to VBlank -> Allow Flipping then both the C sdl opengl version and ocaml sdl openg version worked smoothly. So to sum it up, I had the wrong setting of the nvidia driver and was fooled sinced the fsharp version still synced with the vblank. I am posting the ocaml sdl openg test program here in case someone would like to try it on debian 6 squeeze: Sorry for the "false alarm", it was not ocamls fault, and thank you for the good advice. (* Using opengl, sdl and revised syntax. Compile with: camlopt -pp camlp4r -I . -I +sdl -I +lablgl bigarray.cmxa sdl.cmxa lablgl.cmxa unix.cmxa str.cmxa simple2.ml -o simple2 *) open Sdlevent; open Sdlkey; open Sdlgl; (* Window size in pixels *) value x_size_window = 512; value y_size_window = 512; (* Space coordinates *) value upper_size = 1.5; value lower_size = -1.5; value left_size = -1.5; value right_size = 1.5; value init_gl width height = do { GlDraw.viewport ~x:0 ~y:0 ~w:width ~h:height; GlClear.color (0.0, 0.0, 0.0) ~alpha:0.0; GlClear.clear [`color; `depth]; GlDraw.shade_model `smooth; GlMat.load_identity (); GlClear.color (0.1, 0.3, 0.1); GlDraw.shade_model `smooth; }; value time = let start = Unix.gettimeofday () in fun () -> Unix.gettimeofday () -. start ; value key_left_is_down = ref False; value key_right_is_down = ref False; (* Start of program *) value () = do { Sdl.init [`VIDEO]; at_exit Sdl.quit; set_attr [DOUBLEBUFFER True]; ignore (Sdlvideo.set_video_mode x_size_window y_size_window [`OPENGL ; `DOUBLEBUF ; `RESIZABLE ; `HWSURFACE]); init_gl x_size_window y_size_window; let render () = do { GlMat.mode `projection; GlMat.load_identity (); GluMat.ortho2d ~x:(-1.5, 1.5) ~y:(-1.5, 1.5); GlMat.mode `modelview; GlMat.load_identity (); GlClear.clear [ `color ; `depth]; GlMat.translate ~x:(sin (time ()*.2.0) *. 1.) ~z:1. (); GlDraw.begins `quads; List.iter GlDraw.vertex2 [ ( -0.2, -0.5); (0.2, -0.5); (0.2, 0.5); (-0.2, 0.5)]; GlDraw.ends (); Gl.flush (); Sdlgl.swap_buffers (); } in let quit_loop = ref False in while not quit_loop.val do { (* Calculate elapsed time since last rendering *) render (); match Sdlevent.poll () with [ Some( KEYDOWN {keysym = KEY_ESCAPE} ) -> do { print_endline "You pressed escape! The fun is over now."; quit_loop.val := True } | Some( KEYDOWN {keysym = KEY_LEFT} ) -> do { key_left_is_down.val := True; } | Some( KEYDOWN {keysym = KEY_RIGHT} ) -> do { key_right_is_down.val := True; } | Some( KEYUP {keysym = KEY_LEFT} ) -> do { key_left_is_down.val := False; } | Some( KEYUP {keysym = KEY_RIGHT} ) -> do { key_right_is_down.val := False; } | Some event -> do { print_endline (string_of_event event); } | None -> () ] }; };