Date: Tue, 09 Jan 2001 13:04:39 -0800 From: Chris Hecker Subject: ortho viewing (was Re: resize event?) In-reply-to: <20010109185300.A888 at lambda.u-strasbg.fr> To: Sven LUTHER Cc: lablgtk at kaba.or.jp Message-id: <4.3.2.7.2.20010109125548.00bb5a90 at shell16.ba.best.com> MIME-version: 1.0 Content-type: text/plain; charset="iso-8859-1" Content-transfer-encoding: quoted-printable References: <4.3.2.7.2.20010105002151.00baf5c0 at shell16.ba.best.com> <4.3.2.7.2.20010105002151.00baf5c0@shell16.ba.best.com> > - the glarea being 600x400, this gives me an non-orthogonal view, which > don't have correct 90=B0 angles. You need to work the aspect ratio into your orthographic projection. I've= attached a simple sample app that works with labltk and lablgl so you can= see how it works. It draws a unit triangle that should look isoceles on= the screen. Chris (* a simple 2D OCaml LablGL example application *) open Tk let reshape togl =3D let w =3D Togl.width togl and h =3D Togl.height togl and desired_height =3D 2. in let aspect =3D float w /. float h in let w' =3D desired_height *. aspect and h' =3D desired_height in GlDraw.viewport ~x:0 ~y:0 ~w ~h; GlMat.mode `projection; GlMat.load_identity(); let split f =3D (-.f/.2.,f/.2.) in GluMat.ortho2d ~x:(split w') ~y:(split h'); GlMat.mode `modelview; GlMat.load_identity() let display togl =3D GlClear.clear [`color;`depth]; GlDraw.begins `triangles; GlDraw.color (1.,1.,1.); GlDraw.vertex2 (0.,0.); GlDraw.vertex2 (1.,0.); GlDraw.vertex2 (0.,1.); GlDraw.ends (); Togl.swap_buffers togl let _ =3D let top =3D openTk () in let togl =3D Togl.create top ~width:400 ~height:300 ~double:true= ~rgba:true ~depth:true in Wm.title_set top "Simple OCaml LablGL example"; Togl.display_func togl ~cb:(fun () -> display togl); Togl.reshape_func togl ~cb:(fun () -> reshape togl); reshape togl; bind togl ~events:[`KeyPress] ~fields:[`KeySymString] ~action:(fun ev -> match ev.ev_KeySymString with | "Escape" -> destroy top | _ -> () ); pack [togl] ~expand:true ~fill:`Both; Focus.set togl; mainLoop ()