Haxe and Emscripten

Hi, maybe you can try to use something like this:

@:cppFileCode('
#include <emscripten/bind.h>
using namespace emscripten;

EMSCRIPTEN_BINDINGS(my_module) {
	class_<hxcpp::Main>("MyWrapper")
	.class_function("decompress", &hxcpp::Main_obj::DecompressI);
}
')
class Main
{
	static var SP:ScreenPressor;

	static function main()
	{
		
	}

	public static function DecompressI(width:Int, height:Int, src:haxe.io.UInt8Array, dst:haxe.io.Int32Array):Void {
		SP = (SP == null) ? new ScreenPressor(width, height) : SP;
		SP.DecompressI(src, dst);
	}
}

At least it is compiles and I’ve got Main.html and Main.js files in build folder.

Not sure what do you want to do next, but I hope it will help you.

1 Like