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 Thursday 12 April 2007 21:26, Martin wrote:
> No, it seems to be related to the matrix accumulating numerical errors.

No. It is the time function.

You can check the numerical error by computing the determinant, which remains 
accurate to 1 part in 10^5 after 3600 frames. The mean numerical error 
probably scales as sqrt n because the floats are "random".

> The following works just fine:
>
> let _ =
>   ignore( Glut.init Sys.argv );
>   Glut.initDisplayMode ~double_buffer:true ();
>   ignore (Glut.createWindow ~title:"OpenGL Demo");
>   let angle t = 10. *. t *. t in
>   let render () =

let a = GlMat.to_array(GlMat.get_matrix `modelview_matrix) in
let d = a.(0).(0)*.a.(1).(1) -. a.(1).(0)*.a.(0).(1) in
Printf.printf "%f\n" d;

>     GlClear.clear [ `color ];
>     GlMat.load_identity ();
>     GlMat.rotate ~angle: (angle (Sys.time ())) ~z:1. ();
>     GlDraw.begins `triangles;
>     List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
>     GlDraw.ends ();
>     Glut.swapBuffers () in
>   GlMat.mode `modelview;
>   Glut.displayFunc ~cb:render;
>   Glut.idleFunc ~cb:(Some Glut.postRedisplay);
>   Glut.mainLoop ()

The original also works fine, depending what results you expect and whether 
you've forced vsync. If you want to check the latter, run nvidia-settings and 
select "OpenGL Settings".

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