Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] writing images with lablgl
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien <Damien.Pous@e...>
Subject: Re: [Caml-list] writing images with lablgl
> 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 ( 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)
	close_out o

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


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: