F Sharp Irrlict
Last changed: -213.199.128.153

.
Summary

Just thought I'd share this, in case someone is interested. Irrlicht is a 3D engine that happens to have a .NET layer available, and I was curious how it would interact with F#. It seems to work pretty well, although I haven't done anything except translate one sample in the Irrlicht.NET documentation from C# to F#.

Compilation was simply "fsc -r Irrlicht.NET.dll sample.fs" and I just copied Irrlicht.dll and Irrlicht.NET.dll to the directory I was working in, as well as sydney.bmp and sydney.md2 from the media directory.

Irrlicht is available at http://irrlicht.sourceforge.net/ and Irrlicht.NET is part of the main distribution

 open System
 open Irrlicht
 open Irrlicht.Video
 open Irrlicht.Core
 open Irrlicht.Scene


 [<STAThread>]
 let _ =
  let device = new IrrlichtDevice(DriverType.OPENGL) in
    device.WindowCaption <- "Irrlicht.NET F# Example 01 - Hello World";
    let texSydney = device.VideoDriver.GetTexture("sydney.bmp") in
    let mesh = device.SceneManager.GetMesh("sydney.md2") in
    let cam = device.SceneManager.AddCameraSceneNodeFPS((null : ISceneNode), 100.0f, 100.0f, -1) in
    cam.Position <- new Vector3D(20.0f, 0.0f, -50.0f);
    let node = device.SceneManager.AddAnimatedMeshSceneNode(mesh,(null : ISceneNode), -1) in
    let fps = ref 0 in


    node.SetMaterialTexture(0, texSydney);
    node.SetMaterialFlag(MaterialFlag.LIGHTING, false);
    device.CursorControl.Visible <- false;


    while device.Run() do
      if device.WindowActive then
        begin
          ignore(device.VideoDriver.BeginScene(true, true, new Color(0, 100, 100, 100)));
          device.SceneManager.DrawAll();
          ignore(device.VideoDriver.EndScene());


          if !fps <> device.VideoDriver.FPS then
            begin
              fps := device.VideoDriver.FPS;
              device.WindowCaption <- "Irrlicht.NET F# Example 01 - Hello World [" +
                device.VideoDriver.Name + "]  fps:" + (string_of_int !fps)
            end
        end
    done