/usr/share/doc/liblablgl-ocaml-dev/examples/checker.ml is in liblablgl-ocaml-dev 1:1.05-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | (* $Id: checker.ml,v 1.8 2001-05-08 01:58:25 garrigue Exp $ *)
let image_height = 64
and image_width = 64
let make_image () =
let image =
GlPix.create `ubyte ~format:`rgb ~width:image_width ~height:image_height in
for i = 0 to image_width - 1 do
for j = 0 to image_height - 1 do
Raw.sets (GlPix.to_raw image) ~pos:(3*(i*image_height+j))
(if (i land 8 ) lxor (j land 8) = 0
then [|255;255;255|]
else [|0;0;0|])
done
done;
image
let myinit () =
GlClear.color (0.0, 0.0, 0.0);
Gl.enable `depth_test;
GlFunc.depth_func `less;
let image = make_image () in
GlPix.store (`unpack_alignment 1);
GlTex.image2d image;
List.iter (GlTex.parameter ~target:`texture_2d)
[ `wrap_s `clamp;
`wrap_t `clamp;
`mag_filter `nearest;
`min_filter `nearest ];
GlTex.env (`mode `decal);
Gl.enable `texture_2d;
GlDraw.shade_model `flat
let display () =
GlClear.clear [`color;`depth];
GlDraw.begins `quads;
GlTex.coord2(0.0, 0.0); GlDraw.vertex3(-2.0, -1.0, 0.0);
GlTex.coord2(0.0, 1.0); GlDraw.vertex3(-2.0, 1.0, 0.0);
GlTex.coord2(1.0, 1.0); GlDraw.vertex3(0.0, 1.0, 0.0);
GlTex.coord2(1.0, 0.0); GlDraw.vertex3(0.0, -1.0, 0.0);
GlTex.coord2(0.0, 0.0); GlDraw.vertex3(1.0, -1.0, 0.0);
GlTex.coord2(0.0, 1.0); GlDraw.vertex3(1.0, 1.0, 0.0);
GlTex.coord2(1.0, 1.0); GlDraw.vertex3(2.41421, 1.0, -1.41421);
GlTex.coord2(1.0, 0.0); GlDraw.vertex3(2.41421, -1.0, -1.41421);
GlDraw.ends ();
Gl.flush ()
let reshape togl =
let w = Togl.width togl and h = Togl.height togl in
GlDraw.viewport ~x:0 ~y:0 ~w ~h;
GlMat.mode `projection;
GlMat.load_identity ();
GluMat.perspective ~fovy:60.0 ~aspect:(1.0 *. float w /. float h) ~z:(1.0,30.0);
GlMat.mode `modelview;
GlMat.load_identity ();
GlMat.translate ~z:(-3.6) ()
open Tk
let main () =
let top = openTk () in
let togl =
Togl.create ~width:500 ~height:500 ~rgba:true ~depth:true top in
myinit ();
Togl.display_func togl ~cb:display;
Togl.reshape_func togl ~cb:(fun () -> reshape togl);
pack ~expand:true ~fill:`Both [togl];
mainLoop ()
let _ = main ()
|