caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] writing images with lablgl
@ 2003-04-30  8:29 Damien
  2003-04-30  8:32 ` Nickolay Kolchin-Semyonov
  0 siblings, 1 reply; 4+ messages in thread
From: Damien @ 2003-04-30  8:29 UTC (permalink / raw)
  To: caml-list

Hi,

Is there an easy way to save a "labgl(ut) picture" to a file ?
Is there a way of doing it without displaying the picture ?

(I have got a list of polygons to render into a file)

Thanks,
damien


<http://www.ens-lyon.fr/~dpous/>

-------------------
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] 4+ messages in thread

* Re: [Caml-list] writing images with lablgl
  2003-04-30  8:29 [Caml-list] writing images with lablgl Damien
@ 2003-04-30  8:32 ` Nickolay Kolchin-Semyonov
  2003-05-01  8:53   ` Damien
  0 siblings, 1 reply; 4+ messages in thread
From: Nickolay Kolchin-Semyonov @ 2003-04-30  8:32 UTC (permalink / raw)
  To: Damien, caml-list

On Wednesday 30 April 2003 12:29, Damien wrote:
> Hi,
>
> Is there an easy way to save a "labgl(ut) picture" to a file ?
> Is there a way of doing it without displaying the picture ?
>
> (I have got a list of polygons to render into a file)
>

You can use glReadPixels and glReadBuffer save BACK image from OpenGL to 
memory. Converting pixel data to image format is your task. I'am not sure 
that this functions are supported by lablgl. If not, you can use camlgl 
(http://www.sf.net/projects/camlgl)

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


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

* Re: [Caml-list] writing images with lablgl
  2003-04-30  8:32 ` Nickolay Kolchin-Semyonov
@ 2003-05-01  8:53   ` Damien
  2003-05-01  8:55     ` Nickolay Kolchin-Semyonov
  0 siblings, 1 reply; 4+ messages in thread
From: Damien @ 2003-05-01  8:53 UTC (permalink / raw)
  To: caml-list

> You can use glReadPixels and glReadBuffer save BACK image from OpenGL
> to memory. Converting pixel data to image format is your task. 

I have done it for PPM : 

  let save_ppm s = 
    let o = open_out s in
    let w = Glut.get Glut.WINDOW_WIDTH  in
    let h = Glut.get Glut.WINDOW_HEIGHT in
      Printf.fprintf o "P6\n%d %d\n%d\n" w h 255;
      let w3 = 3*w in
      let r = GlPix.to_raw (GlPix.read 0 0 w (3*h) `rgb `ubyte) in
	for j = h-1 downto 0 do
	  output_string o (Raw.gets_string r (w3*j) w3)
	done;
	close_out o

why not to include this kind of boring function into lablgl(ut) ?
(or at least somewhere in the examples...)

damien

-------------------
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] 4+ messages in thread

* Re: [Caml-list] writing images with lablgl
  2003-05-01  8:53   ` Damien
@ 2003-05-01  8:55     ` Nickolay Kolchin-Semyonov
  0 siblings, 0 replies; 4+ messages in thread
From: Nickolay Kolchin-Semyonov @ 2003-05-01  8:55 UTC (permalink / raw)
  To: caml-list

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


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

end of thread, other threads:[~2003-05-01  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-30  8:29 [Caml-list] writing images with lablgl Damien
2003-04-30  8:32 ` Nickolay Kolchin-Semyonov
2003-05-01  8:53   ` Damien
2003-05-01  8:55     ` Nickolay Kolchin-Semyonov

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