Irrlicht with haxe

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki

Irrlicht with haxe

Postby djoker » Wed Aug 19, 2015 1:56 pm

i folks,
with the new haxe its now possible to code c++ in to haxe .
so i try to bind irrlicht directly and this is the result.

https://github.com/akadjoker/hxIrr

Image

cpp Code: Select all
 
import irr.Driver;
import irr.Device;
import irr.SceneManager;
 
 
 
class Test {
    static function main() {
        trace("INIT");
        try {
            start();
        } catch( e : Dynamic ) {
        }
        trace("DONE");
    }
 
    static function start()
    {
   
var device:Device = new Device(800, 600);
var driver:Driver = device.getVideoDriver();
var smgr:SceneManager = device.getSceneManager();
 
var cube = smgr.addCubeSceneNode();
cube.setPosition(0, 0, 2);
 
cube.setMaterialTexture(0,driver.getTexture("hxlogo.png"));
 
//var camera = smgr.addCameraSceneNodeFPS();
var camera = smgr.addCameraSceneNode();
 
    device.setWindowCaption("Irrlicht with HAXE");
   
 
       
        while (device.run())
        {
            driver.beginScene(0x0000ffff);
            smgr.drawAll();
            driver.endScene();
            device.setWindowCaption("Irrlicht with HAXE - FPS["+ driver.getFps()+"]");
        }
       
           
           
           
    }
 
}
 


cpp Code: Select all
 
package irr;
import cpp.ConstCharStar;
import haxe.NativeWrapper;
 
/**
 * ...
 * @author Luis Santos AKA DJOKER
 */

class Driver  implements NativeWrapper
{
 
    @cpp var driver : PTR<IVideoDriver>;
   
    public function new( )  
    {
     untyped __cpp__('driver = 0;');
    }
   
    public function getTexture(filename:String):Texture
    {
        var t = new Texture();
       
        var fnm:ConstCharStar = ConstCharStar.fromString(filename);
       
       
         untyped __cpp__('
         
         t->ptr = driver->getTexture(fnm);
         
         '
);
         return t;
    }
   
   
    public function beginScene(color:Int, backBuffer:Bool = true, zBuffer:Bool = true):Bool
    {
         untyped __cpp__('
         
         driver->beginScene(backBuffer, zBuffer, SColor(color));
         
         '
);
         return true;
    }
   
    public function endScene():Bool
    {
         untyped __cpp__('
         
         driver->endScene();
         
         
         '
);
         return true;
    }
   
    public function getFps():Int
    {
        var fps:Int = 0;
         untyped __cpp__('
         
         fps=driver->getFPS();
         
         
         '
);
         return fps;
    }
}
 
Never underestimate the power of Delphi....Ignorance is bliss, but knowledge is power...
User avatar
djoker
 
Posts: 39
Joined: Thu Dec 22, 2005 10:25 pm
Location: Portugal

Return to Project Announcements

Who is online

Users browsing this forum: No registered users and 1 guest