だから、OpenGLな実装を覚えておけば、いつでもどんな言語でも画像を表示できるハズ。
let reshape ~w ~h =
let w = max 1 w and h = max 1 h in
dim := (w, h);
GlDraw.viewport 0 0 w h;
GlMat.mode `projection;
GlMat.load_identity ();
GlMat.ortho ~x:(-1., 1.) ~y:(-1., 1.) ~z:(0., 1.);
GlMat.mode `modelview;;
let display () =
let w, h = !dim in
GlDraw.begins `points;
for a = 0 to w - 1 do
for b = 0 to h - 1 do
let idx_x = int_of_float((float a /. float w) *. float (fst !dim)) in
let idx_y = int_of_float((float b /. float h) *. float (snd !dim)) in
GlDraw.color (imgBuf.(0).(idx_x).(idx_y), imgBuf.(1).(idx_x).(idx_y), imgBuf.(2).(idx_x).(idx_y));
let x = 2. *. float a /. float w -. 1. in
let y = 2. *. float b /. float h -. 1. in
GlDraw.vertex ~x ~y ()
done;
done;
GlDraw.ends ();
Gl.flush ();;
let () =
let argv' = Glut.init Sys.argv in
Glut.initWindowSize ~w:(fst !dim) ~h:(snd !dim);
ignore (Glut.createWindow ~title:"タイトル");
Glut.reshapeFunc ~cb:reshape;
Glut.displayFunc ~cb:display;
Glut.keyboardFunc ~cb:(fun ~key ~x ~y -> if key=27 then exit 0);
Glut.mainLoop ();;