2licht

Pascal Eample Code

This is basically a ported version of the first Irrlicht Engine example code.

program Example01;

{$mode objfpc}{$H+}

{$linklib 2licht}
{$linklib stdc++}
{$linklib c}
{$linklib Irrlicht}


uses Types, Irrlicht;


var Mesh: TAnimatedMesh;
    Node: TAnimatedMeshSceneNode;
    

begin
    with TIrrlichtDevice.Create do try 
    
        WindowCaption := 'Hello World! - Irrlicht Engine Demo';
        
        GUIEnvironment.AddStaticText('Hello World! This is the Irrlicht Software Renderer!',
                                     Rect(10, 10, 260, 22), True);
        
        Mesh := SceneManager.GetMesh('../../../media/sydney.md2');
        if Mesh = nil then exit;
        
        Node := SceneManager.AddAnimatedMeshSceneNode(Mesh);
        
        if Node <> nil then with Node do begin
            SetMaterialFlag(mfLighting, false);
            SetMD2Animation(maStand);
            SetMaterialTexture(0, VideoDriver.GetTexture('../../../media/sydney.bmp'));
        end;
        
        SceneManager.AddCameraSceneNode(nil, Vector3D(0, 30, -40), Vector3D(0, 5, 0));
        
        while Run do if IsWindowActive then begin 
            VideoDriver.BeginScene(true, true, ARGBColor(255, 100, 101, 140));
            SceneManager.DrawAll;
            GUIEnvironment.DrawAll;
            VideoDriver.EndScene;
        end;
        
    finally
        Free;
    end;
    
end.

Thanks to Oleg Parashchenko for his Syntax Highlighter.