Fix corner case
[llpp.git] / lablGL / glDraw.ml
blob87ffeedb929e3dd9821427dd0be1e2ee3612941f
1 (* $Id: glDraw.ml,v 1.6 2007-04-13 01:17:50 garrigue Exp $ *)
3 open Gl
5 external color :
6 red:float -> green:float -> blue:float -> alpha:float -> unit
7 = "ml_glColor4d"
8 let color ?(alpha=1.) (red, green, blue : rgb) =
9 color ~red ~green ~blue ~alpha
11 external index : float -> unit = "ml_glIndexd"
13 external cull_face : face -> unit = "ml_glCullFace"
14 external edge_flag : bool -> unit = "ml_glEdgeFlag"
15 external front_face : [`cw|`ccw] -> unit = "ml_glFrontFace"
17 external line_width : float -> unit = "ml_glLineWidth"
18 external line_stipple : factor:int -> pattern:short -> unit
19 = "ml_glLineStipple"
20 let line_stipple ?(factor=1) pattern =
21 line_stipple ~factor ~pattern
22 external point_size : float -> unit = "ml_glPointSize"
24 external polygon_offset : factor:float -> units:float -> unit
25 = "ml_glPolygonOffset"
26 external polygon_mode : face:face -> [`point|`line|`fill] -> unit
27 = "ml_glPolygonMode"
28 external polygon_stipple : [`bitmap] Raw.t -> unit = "ml_glPolygonStipple"
29 let polygon_stipple (img : GlPix.bitmap) =
30 if GlPix.height img <> 32 || GlPix.width img <> 32
31 then invalid_arg "GlDraw.polygon_stipple";
32 polygon_stipple (GlPix.to_raw img)
34 external shade_model : [`flat|`smooth] -> unit = "ml_glShadeModel"
36 type shape =
37 [ `points | `lines | `polygon | `triangles | `quads | `line_strip
38 | `line_loop | `triangle_strip | `triangle_fan | `quad_strip ]
39 external begins : shape -> unit = "ml_glBegin"
40 external ends : unit -> unit = "ml_glEnd"
42 external normal : x:float -> y:float -> z:float -> unit
43 = "ml_glNormal3d"
44 let normal ?(x=0.) ?(y=0.) ?(z=0.) () = normal ~x ~y ~z
45 and normal3 (x,y,z) = normal ~x ~y ~z
47 external rect : point2 -> point2 -> unit = "ml_glRectd"
49 external vertex : x:float -> y:float -> ?z:float -> ?w:float -> unit -> unit
50 = "ml_glVertex"
51 let vertex2 (x,y : point2) = vertex ~x ~y ()
52 and vertex3 (x,y,z : point3) = vertex ~x ~y ~z ()
53 and vertex4 (x,y,z,w : point4) = vertex ~x ~y ~z ~w ()
55 external viewport : x:int -> y:int -> w:int -> h:int -> unit
56 = "ml_glViewport"