Do not hardcode xclip
[llpp.git] / lablGL / glMisc.ml
blob5723babb8c3a1b96ea087d74df9ea43ff787760a
1 (* $Id: glMisc.ml,v 1.8 2008-10-25 02:22:58 garrigue Exp $ *)
3 open StdLabels
5 external get_string : [`vendor|`renderer|`version|`extensions] -> string
6 = "ml_glGetString"
8 let rec check_substring ~sep ~start ~buf s =
9 let len = String.length s in
10 if String.length buf < len + start then false else
11 if String.sub buf ~pos:start ~len = s &&
12 (String.length buf = len + start || buf.[len+start] = sep) then true
13 else
14 match String.index_from buf start sep with
15 | exception _ -> false
16 | n -> check_substring ~sep ~start:(n+1) ~buf s
18 let check_extension s =
19 check_substring ~sep:' ' ~start:0 ~buf:(get_string `extensions) s
21 type equation = float * float * float * float
22 external clip_plane : plane:int -> equation -> unit
23 = "ml_glClipPlane"
24 let clip_plane ~plane equation =
25 if plane < 0 || plane > 5 then invalid_arg "Gl.clip_plane";
26 clip_plane ~plane equation
28 type hint_target =
29 [`fog|`line_smooth|`perspective_correction|`point_smooth|`polygon_smooth]
30 external hint : hint_target -> [`fastest|`nicest|`dont_care] -> unit
31 = "ml_glHint"
33 external init_names : unit -> unit = "ml_glInitNames"
34 external load_name : int -> unit = "ml_glLoadName"
35 external pop_name : unit -> unit = "ml_glPopName"
36 external push_name : int -> unit = "ml_glPushName"
38 external pop_attrib : unit -> unit = "ml_glPopAttrib"
39 type attrib =
40 [ `accum_buffer|`color_buffer|`current|`depth_buffer|`enable|`eval|`fog
41 | `hint|`lighting|`line|`list|`pixel_mode|`point|`polygon|`polygon_stipple
42 | `scissor|`stencil_buffer|`texture|`transform|`viewport ]
43 external push_attrib : attrib list -> unit = "ml_glPushAttrib"
45 external pass_through : float -> unit = "ml_glPassThrough"
46 external render_mode : [`render|`select|`feedback] -> int = "ml_glRenderMode"
47 external select_buffer : int -> [`uint] Raw.t -> unit = "ml_glSelectBuffer"
48 let select_buffer raw =
49 if not (Raw.static raw) then
50 invalid_arg "GlMisc.select_buffer : buffer must be static";
51 select_buffer (Raw.length raw) raw
52 type feedback_mode =
53 [`_2d |`_3d |`_3d_color |`_3d_color_texture |`_4d_color_texture]
54 external feedback_buffer : int -> feedback_mode -> [`float] Raw.t -> unit
55 = "ml_glFeedbackBuffer"
56 let feedback_buffer ~mode buf =
57 if not (Raw.static buf) then
58 invalid_arg "GlMisc.feedback_buffer : buffer must be static";
59 feedback_buffer (Raw.length buf) mode buf
61 external scissor : x:int -> y:int -> width:int -> height:int -> unit
62 = "ml_glScissor"