Version française
Home     About     Download     Resources     Contact us    
Browse thread
Interactive technical computing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Vu Ngoc San <san.vu-ngoc@u...>
Subject: Re: [Caml-list] Interactive technical computing
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