Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Nickolay Kolchin-Semyonov <snob@metalinkltd.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] writing images with lablgl
Date: Thu, 1 May 2003 12:55:52 +0400	[thread overview]
Message-ID: <200305011255.52398.snob@metalinkltd.com> (raw)
In-Reply-To: <20030501105345.67637c53.Damien.Pous@ens-lyon.fr>

On Thursday 01 May 2003 12:53, Damien wrote:
> > You can use glReadPixels and glReadBuffer save BACK image from OpenGL
> > to memory. Converting pixel data to image format is your task.

Just for completness, PPM saving function for camlgl:

   let dump_screen name =
        try
            let f = open_out_bin name in
            let (x1,y1,x2,y2) =
                let a = Hgl.ba_int 4 in
                glGetIntegerv cgl_viewport a;
                a.{0},a.{1},a.{2},a.{3}
            in
            let w = x2 - x1 and h = y2 - y1 in
            let b = Hgl.ba_byte (w * h * 3) in
            glReadPixels x1 y1 x2 y2 cgl_rgb cgl_unsigned_byte b;
            Printf.fprintf f "P6\n%i %i\n255\n" w h; flush f;
            for y = 1 to h do
                let sy = (h-y)*w*3 in
                for x = 0 to w*3 - 1 do
                    output_byte f b.{sy+x}
                done
            done;
            close_out f
        with _ -> Printf.printf "dumping failed\n"; flush stdout

Nickolay

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


      reply	other threads:[~2003-05-01  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-30  8:29 Damien
2003-04-30  8:32 ` Nickolay Kolchin-Semyonov
2003-05-01  8:53   ` Damien
2003-05-01  8:55     ` Nickolay Kolchin-Semyonov [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=200305011255.52398.snob@metalinkltd.com \
    --to=snob@metalinkltd.com \
    --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