Cosmetics
[llpp.git] / glutils.ml
blob0f3d2650dd92597a55358b2f46598adbf4c84c30
1 let traw = Raw.create_static `float ~len:8;;
2 let vraw = Raw.create_static `float ~len:8;;
4 let filledrect2 x0 y0 x1 y1 x2 y2 x3 y3 =
5 Raw.sets_float vraw ~pos:0 [| x0; y0; x1; y1; x2; y2; x3; y3 |];
6 GlArray.vertex `two vraw;
7 GlArray.draw_arrays `triangle_strip ~first:0 ~count:4;
8 ;;
10 let filledrect1 x0 y0 x1 y1 = filledrect2 x0 y0 x0 y1 x1 y0 x1 y1;;
12 let filledrect x0 y0 x1 y1 =
13 GlArray.disable `texture_coord;
14 filledrect1 x0 y0 x1 y1;
15 GlArray.enable `texture_coord;
18 let linerect x0 y0 x1 y1 =
19 GlArray.disable `texture_coord;
20 Raw.sets_float vraw ~pos:0 [| x0; y0; x0; y1; x1; y1; x1; y0 |];
21 GlArray.vertex `two vraw;
22 GlArray.draw_arrays `line_loop ~first:0 ~count:4;
23 GlArray.enable `texture_coord;
26 let drawstring size x y s =
27 Gl.enable `blend;
28 Gl.enable `texture_2d;
29 GlFunc.blend_func ~src:`src_alpha ~dst:`one_minus_src_alpha;
30 ignore (Ffi.drawstr size x y s);
31 Gl.disable `blend;
32 Gl.disable `texture_2d;
35 let drawstring1 size x y s = Ffi.drawstr size x y s;;
36 let drawstring2 size x y fmt =
37 Printf.kprintf (drawstring size (x+1) (y+size+1)) fmt
40 let makecheckers () =
41 (* Based on lablGL-1.04/LablGlut/examples/lablGL/checker.ml which had
42 following to say:
43 converted by Issac Trotts. July 25, 2002 *)
44 let image = GlPix.create `ubyte ~format:`luminance ~width:2 ~height:2 in
45 Raw.sets_string (GlPix.to_raw image) ~pos:0 "\255\200\200\255";
46 let id = GlTex.gen_texture () in
47 GlTex.bind_texture ~target:`texture_2d id;
48 GlPix.store (`unpack_alignment 1);
49 GlTex.image2d image;
50 List.iter (GlTex.parameter ~target:`texture_2d)
51 [ `mag_filter `nearest; `min_filter `nearest ];
52 id;
55 let redisplay = ref false;;
56 let postRedisplay who =
57 Utils.vlog "redisplay for [%S]" who;
58 redisplay := true;