On 1/1/2012 7:38 PM, Joel Christensen wrote:
On 01-Jan-12 3:27 AM, Jacob Carlborg wrote:
On 2011-12-31 00:50, Joel Christensen wrote:
I've got an Mac with OSX. But I have a few problems with using it
with D.

1. I haven't got any media programming going.

Could you please elaborate. Derelict is a library that contains bindings
for OpenGL, OpenAL, SDL and DevIL among others.

Thanks for replying Jacob.

I looked up Derelict and it seem to say Derelict's SDL didn't work with
OSX yet. I haven't done much digging though. I'm more interested in
Allegro5 working with OSX, there's one Allegro library that works with
Windows and Linux, but not OSX.

DerelictSDL works fine on Mac. The Derelict 2 branch also has a binding for Allegro 5 which should work on Mac after a minor update. I'm using the DerelictAllegro binding for a couple of projects right now.



On a bit different note. What's the differences with a library, a
wrapper, and a binding?


A /library/ is a collection of resuable code. SDL and Allegro5 are libraries.

A /binding/ is a kind of library that provides a bridge to use a library written in a language different from what it was written with.The details of how that happens depends entirely on the language the binding is written for. For example, in Java, bindings to C or C++ libraries are effectively wrappers, because of the way the bindings must be written. But in D, because it is compatible with the C ABI, bindings can be one-to-one. Meaning, as long as a C function or type has a declaration in D, it can be used in D. Derelict is an example of a binding (well, several bindings).

A /wrapper/ is a kind of library that encloses an existing library in a different interface. Usually, it's a free function interface being wrapped in an object-oriented interface. For example, Allegro is written in C. A D (or C++) wrapper might be written to give it an object-oriented interface, as long as it had a binding to work with. In other words, it allows you to do this (:

Bitmap bmp = new Bitmap();

instead of this:

ALLEGRO_BITMAP* bmp = al_create_bmp(...);

So to use a wrapper of a C library in D, you would have this setup:

C Library -> D binding library (allows C functions to be called in D) -> D Wrapper library (giving an object oriented interface) -> application

Of course, the wrapper could also be the binding.

Personally, I think wrappers are a waste of time, but some people prefer them to using a C API directly.

Reply via email to