From: malc <malc@pulsesoft.com>
To: Bor-Yuh Evan Chang <bechang@andrew.cmu.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] lablGL and camlimages
Date: Wed, 20 Feb 2002 16:48:13 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.21.0202201645230.685-100000@home.oyster.ru> (raw)
In-Reply-To: <Pine.GSO.4.43L-024.0202200156580.14085-100000@unix1.andrew.cmu.edu>
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
prev parent reply other threads:[~2002-02-20 13:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-20 7:04 Bor-Yuh Evan Chang
2002-02-20 21:48 ` malc [this message]
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=Pine.LNX.4.21.0202201645230.685-100000@home.oyster.ru \
--to=malc@pulsesoft.com \
--cc=bechang@andrew.cmu.edu \
--cc=caml-list@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