6 type visual_options = [
19 | `STENCIL_SIZE of int
20 | `ACCUM_GREEN_SIZE of int
21 | `ACCUM_ALPHA_SIZE of int
24 type gl_area = [`widget|`drawing|`glarea]
28 visual_options list -> share:[>`glarea] optobj -> gl_area obj
29 = "ml_gtk_gl_area_new"
31 external swap_buffers : [>`glarea] obj -> unit
32 = "ml_gtk_gl_area_swapbuffers"
34 external make_current : [>`glarea] obj -> bool
35 = "ml_gtk_gl_area_make_current"
38 class area_signals obj =
40 inherit GObj.widget_signals obj
41 method display ~callback =
42 (new GObj.event_signals ~after obj)#expose ~callback:
44 if GdkEvent.Expose.count ev = 0 then
45 if Raw.make_current obj then callback ()
46 else prerr_endline "GlGtk-WARNING **: could not make current";
49 method reshape ~callback =
50 (new GObj.event_signals ~after obj)#configure ~callback:
52 if Raw.make_current obj then begin
53 callback ~width:(GdkEvent.Configure.width ev)
54 ~height:(GdkEvent.Configure.height ev)
56 else prerr_endline "GlGtk-WARNING **: could not make current";
59 method realize ~callback =
60 let connect = new GObj.misc_signals ~after (GtkBase.Widget.coerce obj) in
61 connect#realize ~callback:
63 if Raw.make_current obj then callback ()
64 else prerr_endline "GlGtk-WARNING **: could not make current"
68 class area obj = object (self)
69 inherit GObj.widget (obj : gl_area obj)
71 method event = new GObj.event_ops obj
72 method connect = new area_signals obj
73 method set_size = GtkMisc.DrawingArea.size obj
74 method swap_buffers () = Raw.swap_buffers obj
75 method make_current () =
76 if not (Raw.make_current obj) then
77 raise (Gl.GLerror "make_current")
80 let area options ?share ?(width=0) ?(height=0) ?packing ?show () =
82 match share with Some (x : area) -> Some x#as_area | None -> None in
83 let w = Raw.create options ~share:(Gpointer.optboxed share) in
84 if width <> 0 || height <> 0 then GtkMisc.DrawingArea.size w ~width ~height;
85 GtkBase.Widget.add_events w [`EXPOSURE];
86 GObj.pack_return (new area w) ~packing ~show