I've recently implemented some improvements centered on bindbc-sdl.

== New Loader Function

I've added a function to bindbc-loader (on Windows only) to allow adding a single path to the default DLL search path. This is to solve the problem that some of the SDL satellite libraries would fail to load when placed in a directory outside of the search path, such as a ./libs subdirectory.

The problem is that SDL loads its dependencies dynamically. So when a bindbc user would load a lib with a custom path, e.g., `loadSDLImage("libs\\SDL2_image.dll")`, the system loader would find that DLL just fine, but then when it in turn attempted to load a dependency like libpng, the system loader would search the DLL search path and *not* the libs subdirectory, thereby causing a failure.

Now you can do this:

```
version(Windows) setCustomLoaderSearchPath("libs");

if(loadSDL() < sdlSupport) { /* handle error */ }
if(loadSDL_Image() < sdlImageSupport) { /* handle error */ }

// Give SDL_image a chance to load libpng and libjpeg (it loads them lazily
// when the corresponding flags are passed to IMG_Init.
auto flags = IMG_INIT_PNG | IMG_INIT_JPEG;
if(IMG_Init(flags) != flags) { /* handle error */ }

// Now reset the default loader search path
version(Windows) setCustomLoaderSearchPath(null);
```

It's up to the caller to ensure the path is valid. For example, if the executable is run from a different directory, then "libs" will not be relative to the current working directory. `SDL_GetBasePath` can help there:

https://wiki.libsdl.org/SDL_GetBasePath?highlight=%28%5CbCategoryFilesystem%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

I'm unaware of any issues with other libraries BindBC binds to, but if they do arise, this will solve those, too.

== SDL_net

I didn't initially port SDL_net over because I didn't think anyone was using it. I was waiting for someone to request it. Someone did. It's a small API, so it took a matter of minutes to complete.

== Streamlined SDL_* version identifiers

Previously, the SDL satellite library bindings could be enabled with e.g., `BindSDL_Image`, `BindSDL_TTF`, etc. That would enable the lowest supported version of the library. To enable a more recent version, an additional identifier was required (`SDL_Image_205`, `SDL_TTF_2014`). That's just dumb. Now, only one identifier is required, e.g., `SDL_Image_205` will do the trick by itself now. `SDL_Image` is equivalent to the `SDL_Image_200`. The old approach is still supported, though, so current build configs should continue to work without change.

See the loader documentation for details on the new function:

https://github.com/BindBC/bindbc-loader

There's also a bit about it in the bindbc-sdl documentation, along with the details about the approach to version identifiers.

https://github.com/BindBC/bindbc-sdl/blob/master/README.md

I've got some bigger packages to port over from Derelict yet (the OpenCL binding, for example). I've also had a request to include support for SDL's thread/mutex API so folks using DasBetterC can have access to it. That's all in the pipeline. Going forward, I plan to devote a handful of hours one day a week to bindbc until I've implemented everything on my task list, so it will get done sooner rather than later.

Reply via email to