Browse thread
[Caml-list] writing images with lablgl
-
Damien
-
Nickolay Kolchin-Semyonov
-
Damien
- Nickolay Kolchin-Semyonov
-
Damien
-
Nickolay Kolchin-Semyonov
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Nickolay Kolchin-Semyonov <snob@m...> |
| Subject: | Re: [Caml-list] writing images with lablgl |
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