From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 2D9F1BC69 for ; Thu, 8 Mar 2007 22:28:47 +0100 (CET) Received: from amazone2.ujf-grenoble.fr (amazone2.ujf-grenoble.fr [152.77.2.202]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l28LSkYO012024 for ; Thu, 8 Mar 2007 22:28:47 +0100 Received: from tana2.ujf-grenoble.fr (tana2.ujf-grenoble.fr [152.77.24.22]) by amazone2.ujf-grenoble.fr (8.13.7/8.13.7/Configured by JE 21 07 2006) with ESMTP id l28LShg0078990; Thu, 8 Mar 2007 22:28:43 +0100 (CET) Received: from localhost (unknown [127.0.0.1]) by tana2.ujf-grenoble.fr (Postfix) with ESMTP id 3F3D0250421; Thu, 8 Mar 2007 22:28:43 +0100 (CET) X-Virus-Scanned: Scanned on tana2.ujf-grenoble.fr Received: from tana2.ujf-grenoble.fr ([127.0.0.1]) by localhost (tana2.ujf-grenoble.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hayFkqU+lErp; Thu, 8 Mar 2007 22:28:43 +0100 (CET) Received: from tibre1.ujf-grenoble.fr (tibre1.ujf-grenoble.fr [152.77.18.86]) by tana2.ujf-grenoble.fr (Postfix) with ESMTP id 0FAFA25041C; Thu, 8 Mar 2007 22:28:43 +0100 (CET) Received: from bruch.ujf-grenoble.fr (bruch.ujf-grenoble.fr [193.54.241.15]) by tibre1.ujf-grenoble.fr (8.13.3/8.13.3) with ESMTP id l28LShhE090205; Thu, 8 Mar 2007 22:28:43 +0100 (CET) (envelope-from san.vu-ngoc@ujf-grenoble.fr) Received: from localhost (localhost [127.0.0.1]) by bruch.ujf-grenoble.fr (Postfix) with ESMTP id D9F344F961; Thu, 8 Mar 2007 22:28:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at fourier.ujf-grenoble.fr Received: from bruch.ujf-grenoble.fr ([127.0.0.1]) by localhost (bruch.ujf-grenoble.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xe80xyJeBPwR; Thu, 8 Mar 2007 22:28:42 +0100 (CET) Received: from [127.0.0.1] (malherbe.ujf-grenoble.fr [193.54.241.13]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by bruch.ujf-grenoble.fr (Postfix) with ESMTP id DDBDD4F907; Thu, 8 Mar 2007 22:28:41 +0100 (CET) Message-ID: <45F08008.8050800@ujf-grenoble.fr> Date: Thu, 08 Mar 2007 22:28:40 +0100 From: Vu Ngoc San User-Agent: IceDove 1.5.0.10 (X11/20070306) MIME-Version: 1.0 To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Interactive technical computing References: <200703080113.22721.jon@ffconsultancy.com> <45EFFABC.1020509@ujf-grenoble.fr> <200703081243.35432.jon@ffconsultancy.com> In-Reply-To: <200703081243.35432.jon@ffconsultancy.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 45F0800E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lablgtk:01 toplevel:01 mainloop:01 toplevel:01 mainloop:01 sdlvideo:01 ocaml:01 lib:01 xfig:01 lablgtk:01 gtk:01 threads:01 ocaml:01 height:98 .....:98 Jon Harrop a écrit : > How exactly do you do that? Can you post a complete working example? > > Looks great... :-) > Thanks :-) The idea is that sdl (contrary to glut or lablgtk2), does not have a "main loop": so you can write your own. This allows you to open an opengl window from the toplevel, and when you quit your mainloop, you get back nicely to the toplevel. You can even let the window open when you are back to toplevel, but then the graphics are not updated anymore. Nice enough: you can later update the sdl window (no need to close it and open another one !). If you really need interaction in the window and in the toplevel at the same time, you can launch the sdl mainloop in a separate thread. It really works. But I wouldn't try to open two sdl windows at the same time (??). I don't have the courage -- and time -- to give you a "working example" (see below) but the initialisation is like this: Sdl.init [ `VIDEO ]; Sdlvideo.set_video_mode !window_width !window_height [ `DOUBLEBUF ; `OPENGL ; `RESIZABLE]); Sdlwm.set_caption "Oplot - SDL Window" ""; Then you can issue any openGL command you wish. Even from the toplevel ! You can also use Sdlttf to handle any ttf font. ..... Now, since you sort of asked for it, here it is: I have written a small graphics library that does all of this. But this is my first ocaml program, first use of openGL etc.. so I'm not particularly proud of it. It is quite messy, and in a state of perpetual development. You can find a (not so recent) version at http://www-fourier.ujf-grenoble.fr/~svungoc/prog/oplot/index.html This lib is actually useful (to me) because you can insert LaTeX formulas and export directly to xfig (or postscript). It produces postscript of better quality than maple :-) There is a (very recent) GUI for this at http://www-fourier.ujf-grenoble.fr/~svungoc/prog/goplot/index.html which uses lablgtk2 and launches sdl in a separate thread... (yep. my first use of GTK and of threads.. don't be too harsh if you read my code... -:) ). However, and even though I'm not a programmer (I do this for learning ocaml during my spare time), I'd be happy to have some feedback. There is a package with precompiled binaries that works on at least three linux machines :-) San