Version française
Home     About     Download     Resources     Contact us    
Browse thread
LablGL question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] LablGL question
From: Brian Hurt <bhurt@spnz.org>

> Is there a reason why, in gl.mli, point3 is defined as a tuple, and not a 
> structure or array or other datatype that holds floats unboxed?  Having it 
> an unboxed type would be a double advantage- unboxing in Ocaml, and the 
> ability to call the vector vectors on the openGL side of things without 
> having to copy the data.

No deep reason. Just that performance of function calls was not the
main motivation, but rather ease of use.
Note also that
* boxing in caml does not matter that much, as functions using point3
  take only one argument of this type, and there are no arrays of
  points in the API (in that case raw arrays are used, which are
  unboxed).
* ocaml arrays and structures are indeed unboxed, but on some
  architectures you cannot cast them to (double*) because of alignment
  restrictions. So at least on those architectures copying is needed.
  (Well, looking at the glx code in Mesa this seems unnecessary with
  X11, because it doesn't load those values to registers, but being
  optimal would be complex indeed.)

If performance is you concern, you can use GlArray.vertex to draw a
full array of unboxed vertices in one step.

Jacques Garrigue