To: luther at dpt-info.u-strasbg.fr Cc: lablgtk at kaba.or.jp Subject: Re: resize event? In-Reply-To: <20010109185300.A888 at lambda.u-strasbg.fr> References: <4.3.2.7.2.20010105002151.00baf5c0 at shell16.ba.best.com> <20010109185300.A888@lambda.u-strasbg.fr> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010110204647A.garrigue at kurims.kyoto-u.ac.jp> Date: Wed, 10 Jan 2001 20:46:47 +0900 From: Jacques Garrigue Lines: 88 From: Sven LUTHER > Now, i have also a question : > > i am using a GlArea widget to do OpenGL drawing into, i create it with : > > let area = GlGtk.area [`DOUBLEBUFFER;`RGBA;`DEPTH_SIZE 1] > ~width:600 ~height:400 () > > and do some matrix stuff in it like it is done in the GL examples : > > ignore (area#event#connect#after#configure ~callback: > begin function _ -> > GlMat.mode `projection; > GlMat.load_identity (); > GlMat.ortho ~x:(-1.0,1.0) ~y:(-1.0,1.0) ~z:(-1.0,1.0); > false > end); If you use GlGtk.area, then you should rather use #connect#display and #connect#reshape than #event#connect#configure. Those two special events do extra administrative work, so that they will work even you have several Gl areas in you program. > now, if i understood it well, (fst ~x, fst ~y) is the coordinate of the lower > left corner of the glArea and (snd ~x, snd ~y) is the coordinate of the upper > right corner of the GLArrea. This should be correct. > The problem with this is that : > > - the glarea being 600x400, this gives me an non-orthogonal view, which > don't have correct 90° angles. Seems logical. > - when i use the button_press callback, i get coordinates in the -1,1 range. > - when i resize window, i get a larger window, but the button_press event > still seem to be providing me the older values, not sure though. You should reconfigure when shape changes. > if i do : > > GlMat.ortho ~x:(-1.5,1.5) ~y:(-1.0,1.0) ~z:(-1.0,1.0); > > i think i will preserver the correct ratio, but nothing happens. Very strange. It works for me. There maybe some timing problems: everything should be done in the right order. I just modified scene.ml in lablgl, to have it work with lablgtk, and everything is OK. open GMain let main () = let w = GWindow.window ~title:"Scene" () in w#connect#destroy ~callback:(fun () -> Main.quit (); exit 0); let area = GlGtk.area [`RGBA;`DEPTH_SIZE 1] ~width:500 ~height:500 ~packing:w#add () in area#connect#realize ~callback:myinit; area#connect#reshape ~callback:my_reshape; area#connect#display ~callback:display; area#event#add [`BUTTON_PRESS]; area#event#connect#button_press ~callback: begin fun ev -> let p = (GdkEvent.Button.x ev, GdkEvent.Button.y ev, 0.) in area#make_current (); let (x, y, z) = GluMat.unproject p in Printf.printf "x=%f, y=%f, z=%f\n" x y z; flush stdout; true end; w#show (); Main.main () let _ = Printexc.print main () Note that you should use GluMat.unproject, to get your coordinates converted back. Cheers, Jacques