Menu

Subscribe

Announcing linc: SDL & more with Haxe only

Menu

It's a good time to be using Haxe for native C++ related things, but there were some features released with Haxe 3.2.0 that really tipped a specific iceberg for me.

I've been working toward easy to use native libraries with Haxe for some time now, and Hugh, maintainer of the Haxe cpp target and author of the long lived NME framework - has always been open to hearing my crazy ideas, and even landed a couple of features in hxcpp for the benefit of what I am announcing today.

This announcement has largely been made possible by the work done by Hugh on the hxcpp backend with the native features, the Haxe compiler team giving hxcpp the space to grow, and a few hours of dedicated work on my part. Onward!

What is linc then?

linc is collection of libraries for the Haxe c++ target.

“Low-level Interfaces Native Collection”

Haxe and hxcpp give us direct, truly native access to c++.

Using extern class, we can use native libraries from Haxe code, without significant overhead, without boxing, just pure c++ - all while enjoying the Haxe language features as well.

The purpose of linc as an initiative and a collection is to build and maintain a repository of quality, reliable tools that are agnostic, low friction, and help further the existing usefulness of the Haxe programming language in the wild.

Example: Using SDL directly from Haxe

Let's take a simple haxe HXML build file:

#build.hxml
-main Example
-cpp cpp/
-lib linc_sdl

Throw in some Haxe, using the linc SDL library:

And run haxe build.hxml on the command line.

How does it work?

By using the Haxe extern class features and the @:native meta information hxcpp allows us to make Haxe API's that are replaced in the generated c++ code with the real calls to native code.

This means that the SDL calls or bindings end up in the output - simple.

Details, libraries, and more

Currently the following libraries are already available as of now:

SDL

OpenAL

Ogg vorbis decoding

Native file Open, Save and Folder dialogs

stb Image and Image Write

There are more in the works and nearing completion, and community contributed libraries are in the works too. Feel free to contribute your own.

You can find much more information about the native externs, see what the generated output looks like in action, read about the guidelines for submitting a library and much more on the linc home page.

In the mean time - Please keep discussions related to linc directly on the linc discussions page only so they are localized and easily found and addressed.