caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] lablGL and camlimages
@ 2002-02-20  7:04 Bor-Yuh Evan Chang
  2002-02-20 21:48 ` malc
  0 siblings, 1 reply; 2+ messages in thread
From: Bor-Yuh Evan Chang @ 2002-02-20  7:04 UTC (permalink / raw)
  To: caml-list

Hello,

I am using the lablGL library to use Open GL in OCaml.  I am trying to
read from the frame buffer (using GlPix.read) and output to a file (a jpeg
using camlimages), but I am having difficulties.  Has anyone tried this or
have any pointers to where I can find some additional information?

Thank You,
Evan Chang

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] lablGL and camlimages
  2002-02-20  7:04 [Caml-list] lablGL and camlimages Bor-Yuh Evan Chang
@ 2002-02-20 21:48 ` malc
  0 siblings, 0 replies; 2+ messages in thread
From: malc @ 2002-02-20 21:48 UTC (permalink / raw)
  To: Bor-Yuh Evan Chang; +Cc: caml-list

On Wed, 20 Feb 2002, Bor-Yuh Evan Chang wrote:

> Hello,
> 
> I am using the lablGL library to use Open GL in OCaml.  I am trying to
> read from the frame buffer (using GlPix.read) and output to a file (a jpeg
> using camlimages), but I am having difficulties.  Has anyone tried this or
> have any pointers to where I can find some additional information?
What kind of difficulties? lablgl or camlimages related? In any case here
goes very simple template to output picture to TGA, you can work from
there.

method screenshot =
  let w = Togl.width togl
  and h = Togl.height togl in
  let pixels = GlPix.read
      ~x:0 ~y:0
      ~width:w ~height:h
      ~format:`rgb ~kind:`ubyte
  in
  let praw = GlPix.to_raw pixels in
  let raw = Raw.gets ~pos:0 ~len:(Raw.byte_size praw) praw in
  let w = GlPix.width pixels in
  let h = GlPix.height pixels in
  let f = open_out_bin "shot.tga" in
  let outb = output_byte f in
  let outw w = output_byte f (w land 0xff); output_byte f (w lsr 8) in
  outw 0;
  outb 2;
  for i = 0 to 8 do outb 0 done;
  outw w; outw h;
  outb 24;
  outb 0;
  for i = 0 to pred (w * h) do
    outb raw.(i * 3 + 2);
    outb raw.(i * 3 + 1);
    outb raw.(i * 3 + 0);
  done;
  close_out f

-- 
mailto:malc@pulsesoft.com

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-02-20 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-20  7:04 [Caml-list] lablGL and camlimages Bor-Yuh Evan Chang
2002-02-20 21:48 ` malc

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