Version française
Home     About     Download     Resources     Contact us    
Browse thread
Example slowing down... (OpenGL/lablgl)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Example slowing down... (OpenGL/lablgl)
On Wednesday 11 April 2007 23:25, Oliver Bandel wrote:
>   http://en.wikipedia.org/wiki/OCaml
>
> =================================================================
>  let _ =
>     ignore( Glut.init Sys.argv );
>     Glut.initDisplayMode ~double_buffer:true ();
>     ignore (Glut.createWindow ~title:"OpenGL Demo");
>     let render () =
>       GlClear.clear [ `color ];
>       GlMat.rotate ~angle:(Sys.time() *. 0.01) ~z:1. ();
>       GlDraw.begins `triangles;
>       List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
>       GlDraw.ends ();
>       Glut.swapBuffers () in
>     Glut.displayFunc ~cb:render;
>     Glut.idleFunc ~cb:(Some Glut.postRedisplay);
>     Glut.mainLoop ()
> =================================================================

You'll notice the uncanny resemblance of that code to the code from OCaml for 
Scientists:

  http://www.ffconsultancy.com/products/ocaml_for_scientists/visualisation/

> Or is the OCaml-code in the above example
> written in bad OpenGl-style?

Yes. I should not have used Sys.time() in the Wikipedia example because it 
measures CPU time. Thus, as the program takes longer to run (e.g. in a larger 
window) the rate of spinning will be affected. So you cannot infer the 
graphics performance from the rate of spinning. Instead, you must add a time 
to count how many frames of animation are displayed each second.

This may be the problem. However, I'd be surprised if that makes a visible 
difference because your machine should be easily capable of spinning a 
triangle using only software rendering.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists