SiegeLord / DAllegro5

D binding to the Allegro5 game development library
Other
42 stars 15 forks source link

Add platform-specific support: Windows and X #55

Open SimonN opened 5 months ago

SimonN commented 5 months ago

This adds bindings for Allegro 5's platform-specific functions for Windows and the X Window System to DAllegro5.

(This does not add any Mac OS X bindings nor Iphone bindings, and it does not touch the Android bindings. DAllegro5 binds 4 of the 6 Android-specific A5 functions.)

So far, I've thought about where to place these new files and how to name them as D modules. I've also chosen parameter types and return types as sensible as I could. E.g., for that lone X-specific function that wants the X-specific type XID, I researched what XID can ever be in C, and I use D's uint instead of requiring a dedicated X header bindings.

This code is UNTESTED. Don't merge yet! Windows is only partly tested: Forward-declaring HWND al_get_win_window_handle(ALLEGRO_DISPLAY*); works with my import core.sys.windows.windows, but I haven't tested any other functions. For X, I haven't tested anything yet. I'll see when I find time to test all of these functions.

SiegeLord commented 5 months ago

This looks pretty good, thanks! Tell me if you need help testing this.

SimonN commented 4 weeks ago

For the Windows functions, I should replace the uint with UINT. That's more honest.

Certainly, D's Windows bindings alias UINT to mean uint, i.e., the 32-bit unsigned integer with two's complement, so it's the same in practice. The reason is that this responsibility should remain in the Windows D bindings, not in DAllegro5. The Allegro 5 functions wants UINT (without coming forward as an authority on what that must mean), therefore DAllegro5 should specify UINT (again without saying what it means).

I should double-check that bool is correct (instead of, e.g., BOOL or char or some integer).

Other than that, I haven't found problems yet. But I haven't thoroughly tested yet, either. (I've tested partially in March 2024.)