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: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Example slowing down... (OpenGL/lablgl)
On Thu, 12 Apr 2007, Jon Harrop wrote:

> On Thursday 12 April 2007 15:33, Oliver Bandel wrote:
> > > http://www.ffconsultancy.com/products/ocaml_for_scientists/visualisation/
> >
> > There I get an error messaage that glutCreateWindow is called before
> > glutInit.
>
> Ugh, sorry. They changed freeglut to be more pedantic (which might actually
> fix some crashing issues I had with Presenta). You need to call glut.init as
> the Wikipedia example does.
>
> > I have not looked at the examle in detail,
> > but if it's not an OCaml-problem then that's fine.
>
> Well, I think it is probably just the choice of "time" function. Try it to
> make sure though.

No, it seems to be related to the matrix accumulating numerical errors.
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 () =
    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 ()




--
Martin Jambon
http://martin.jambon.free.fr