caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* LablGL question
@ 2007-09-02 17:41 Brian Hurt
  2007-09-03  1:37 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Hurt @ 2007-09-02 17:41 UTC (permalink / raw)
  To: caml-list


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.

Just wondering...

Brian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] LablGL question
  2007-09-02 17:41 LablGL question Brian Hurt
@ 2007-09-03  1:37 ` Jacques Garrigue
  2007-09-03  1:50   ` Carlos Scheidegger
  0 siblings, 1 reply; 3+ messages in thread
From: Jacques Garrigue @ 2007-09-03  1:37 UTC (permalink / raw)
  To: bhurt; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] LablGL question
  2007-09-03  1:37 ` [Caml-list] " Jacques Garrigue
@ 2007-09-03  1:50   ` Carlos Scheidegger
  0 siblings, 0 replies; 3+ messages in thread
From: Carlos Scheidegger @ 2007-09-03  1:50 UTC (permalink / raw)
  To: caml-list

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

Then again, if you really want to push vertices fast to a graphics card as
fast as possible, you would want to store them in-card using some sort of
recent OpenGL extension which does that, like vertex buffer objects:

http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt

However, for most cases, this shouldn't be any faster than a GlArray.vertex
call inside a display list...

-carlos


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-03  1:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-02 17:41 LablGL question Brian Hurt
2007-09-03  1:37 ` [Caml-list] " Jacques Garrigue
2007-09-03  1:50   ` Carlos Scheidegger

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).