caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Example slowing down... (OpenGL/lablgl)
Date: Thu, 12 Apr 2007 08:15:24 +0100	[thread overview]
Message-ID: <200704120815.24433.jon@ffconsultancy.com> (raw)
In-Reply-To: <20070411222521.GA1603@first.in-berlin.de>

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


  parent reply	other threads:[~2007-04-12  7:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-11 22:25 Oliver Bandel
2007-04-12  0:07 ` [Caml-list] " skaller
2007-04-12 14:09   ` Oliver Bandel
2007-04-12  7:15 ` Jon Harrop [this message]
2007-04-12 14:33   ` Oliver Bandel
2007-04-12 19:46     ` Jon Harrop
2007-04-12 20:26       ` Martin Jambon
2007-04-12 22:19         ` Jon Harrop
2007-04-13  0:30           ` Martin Jambon
2007-04-13  0:44             ` Jon Harrop
2007-04-12 20:47       ` Oliver Bandel
2007-04-13  1:12       ` skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200704120815.24433.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).