[MLton] Support for link options in ML Basis files

Chris Clearwater chris@detriment.org
Thu, 20 Jan 2005 16:57:30 -0800

Anoq of the Sun wrote:

> Chris Clearwater wrote:
>> I have only wrapped enough in my SDL bindings to be of use in 
>> conjunction with OpenGL. Basicaly I am just replacing GLUT. At the 
>> moment I am in the middle of writing a tool to help access C 
>> structures from SML so I dont need to use callbacks like I currently 
>> do to access with the SDL_Event structure. When I finish that I plan 
>> on rewriting the bindings more simply. While I am only interesting in 
>> a very limited subset of SDL, I would be interested in collaborating 
>> with you on a single binding should you ever find the time.
> Now that I have completed my exams, I might be able to finish
> my bindings and release them. I am actually looking into
> which of my projects to jump onto now, and this might be a
> good one to get done with :-)
>> As for SDLmain troubles, I did not have any :) On my linux machine 
>> the main symbol is kept in /usr/lib/libSDLmain.a and `sdl-config 
>> --libs` does not include -lSDLmain. I once compiled on cygwin with a 
>> mingw32 compiled SDL.dll and ran into troubles because `sdl-config 
>> --libs` _did_ include -lSDLmain. I filtered it from the flags and all 
>> was fine. I suspect that the MSVC compiled SDL.dll does contain the 
>> main symbol as libsdl.org only distributes a single SDL.dll and no 
>> SDLmain.dll. I don't find this to be a problem as I would certainly 
>> distribute my own SDL.dll with any application I release.
> Does all the above include compiling with MLton or is that just for
> stand-alone C-programs? I had to include SDL.h in the MLton runtime,
> but maybe I just didn't work hard enough on the SDL-linker flags :-)
> It would surely be cool if what I did can be avoided! :-)
Yeah, see my other message.

>> If you are interested I have put my bindings up at 
>> http://www.detriment.org/~chris/mlgame.tar.gz . It also contains my 
>> GL/GLU bindings which consisted of me sitting down yesterday morning 
>> and translating everything in my gl.h/glu.h headers which did not 
>> contain a pointer :)
> I just looked at it briefly. It seems that you have done a fair
> amount of the event handling but that you are making some call-back
> system. I just supply the more native SDL commands for that.

I made a tool awhile back that generated structures that could be used
to access MLton.Pointer.t s to defined structures, I am going to rewrite
the bindings to use that.

> Another difference I noticed is that you generally have
> your structures as SDLVideo, SDLEvent etc.
> I have packed mine fairly thoroughly into e.g.
> SDL.Event, SDL.Event.Mod, SDL.Event.Key, SDL.Surface etc.
> Also, many of my constants are not "hardcoded" into
> the ML-code - I use functions to read them from the C-defines
> in SDL. I didn't bother to do this for all the keycodes
> though :-) I have attached my latest signatures if
> you want to check them out :-)
> I haven't messed with the OpenGL stuff though, but
> it would be cool if our bindings could be merged. 
> Weren't there someone else doing OpenGL bindings as
> well? Or maybe that was you? I just seem to remember
> that someone was working on this...
> Cheers

The MLton CVS repository contains some incomplete GL/GLU/GLUT bindings.
Unfortunately, they are written in a non-idiomatic SML style. They have
curried wrappers around them and also have the same names as C where
there is no namespace management. For example, "GL.glVertex3d: real ->
real -> real -> unit" in CVS vs "GL.vertex3D: real * real * real ->
unit" in my bindings. It was easier to sit down and convert the headers
from scratch than it was to convert the existing bindings. Also, i am
not interested in GLUT as SDL does a much better job.