GLFWwwfWFffwf god these names you guys

GLFWwwfWFffwf god these names you guys

by Sunjammer

Week 3: GLFW migration

Short one this week. Wound up having much less time for personal projects than anticipated, but still got a significant step done: Migrating from the Haxe SDL2 bindings to my own GLFW bindings. I have to say, across the board I'm happy to have made the move, as I feel GLFW is better aligned with my actual needs. Build times are also absolutely flat now, making for quicker iteration and More Fun™. Every problem I had with the SDL2 bindings were trivial in GLFW, though I imagine a fair bit of that comes from my level of familiarity with the weirdness in either.

The biggest difference was in the event loop. While GLFW has polling mechanisms for inputs it doesn't compare well with SDL's unified message pump architecture (which is nice). This is a minute difference in C++, but in Haxe it makes for roundtripping callback functions with the native code, which is something I hadn't done before. As with many hxcpp mysteries, the difficulty wasn't in the actual solution, but in figuring out the puzzles needed to get somewhere stable. In this case the quandary was understanding how hxcpp GC interops with static pointers in c++. Turns out as long as you work with cpp::Pointers instead of shoving references around, things behave predictably. The thing with hxcpp that I keep running into is that the header comes with a fair set of structures with which to wrap C++ primitives to ensure the interop doesn't seg11 all over the place, but I just don't know about all of them.

Another thing is that haxe functions are wrapped in cpp::Function, which don't conform to C++ function signatures, meaning I had to wrap callback calls in proxy functions. Ugh.

For future reference, if you're passing a Haxe function pointer (via, say, a cpp.Callable) into a C++ function, actually make it a pointer: untyped __cpp__("linc::glfw::setErrorCb({0})", cpp.Pointer.addressOf(GLFWErrorHandler.callable));

Next week is ultra busytimes for me, so I'll likely have to miss the post. It'll be worth it though ;)

Relevant hot jams

Imminent & Synapscape - Xylo Renewal

Apoptygma Berzerk - Backdraft

Synth Sense - Corrosion