IDE setup for Heaps Toolkit targeting DirectX | OpenGL applications based on Hashlink.
This guide is rely on Nicolas Cannasse’s demo in Amsterdam Haxe Summit on his own Heaps Toolkit.

This tutorial probably helps you if you are not yet familiar or just simply lost how to start with Haxe and Heaps Toolkit but you are eager to start some game development targeting either directX or openGL.
Please note this IDE settings for Windows users only. I will guide you through on the necessary settings to the point where you have a running application with a rotating cube on the screen.


Let’s start targeting directX first!
Make sure you have the following programs installed on your PC:

HaxeLib installer install NekoVM for you. However if you miss it you can download NekoVM from here. Get the Windows Binaries version and unpack it. After unpack copy the content of the folder to here: c:\HaxeToolkit\neko\ or wherever your HaxeToolkit installation is.

When you have the necessary programs installed run Windows Command Prompt:
type:haxe and make sure Haxe Compiler is 4.0.0 or above.

Run the following cmd command to install the necessary libraries:
haxelib install hldx
haxelib install heaps

Download the binary release of HashLink ( currently 1.2 )
Unpack the file to the following path: c:\HaxeToolkit\  or wherever your HaxeToolkit installation is.
After unpack, your url should look like this: c:\HaxeToolkit\hl-1.2-win32\

Now start HaxeDevelop and create a new C++ project.
Just to keep things clean but you can change it as you like:
In your project folder next to your bin and src folders create a hlout folder for your hashlink file.
Select Project-Properties-Output and set to the following:

Select Edit and add the following custom command: c:\HaxeToolkit\hl-1.2-win32\hl hlout/output.hl
( or wherever your HaxeToolkit installation is. )

This way we can send our hashlink output directly to the compiler.
Please note this just a “way” to run your hashlink output. You might find an easier or better way.

Select Build Tab and add the following to the Pre-Build Command Line section:
haxe -hl hlout/output.hl -main Main -cp src -lib hldx -lib heaps

Here we use hashlink to build our output.hl file in the previously created hlout folder with the usage of the Main.hx class what can be found in the src folder with the following haxelib libraries: hldx ( for directX ) and heaps ( 2d/3d Toolkit ).

Select Compiler Options Tab then select Libraries and add the heaps library to the project: -lib heaps

Open Main.hx file modify like this:

import hxd.App;
import h2d.Tile;
import h2d.Bitmap;

class Main extends hxd.App
	var obj:h3d.scene.Mesh;
	var bmp:h2d.Bitmap;
	override function init()
		var cube = new h3d.prim.Cube();
		obj = new h3d.scene.Mesh(cube, s3d);
		obj.material.mainPass.enableLights = true;
		var light = new h3d.scene.DirLight( new h3d.Vector( -0.1, -0.2, -1 ), s3d );
		trace("Cube should rotate on your screen...:)");
	override function update(dt:Float)
		obj.rotate(0.02, 0, 0.02);
	static function main() 
		new Main();

If you run the project you should see a rotating cube on your screen:

Targeting OpenGL

To target openGL you have to install hlsdl library:
Run cmd and run the following command: haxelib install hlsdl 1.2.0
You find more details here!

When installation is done, go to HaxeDevelop and modify your project properties Pre-Build Command line like this:
haxe -hl hlout/output.hl -main Main -cp src -lib hlsdl -lib heaps

Run the application and you should see the same result but instead of directX now you are targeting openGL.

Where from now?

I highly recommend you to check the following links: