Thread overview
Programming on OSX
Dec 30, 2011
Joel Christensen
Dec 31, 2011
Jacob Carlborg
Jan 01, 2012
Joel Christensen
Jan 01, 2012
Mike Parker
Jan 01, 2012
Jakob Ovrum
Jan 01, 2012
Joel Christensen
Jan 02, 2012
Mike Parker
Jan 02, 2012
Joel
Jan 02, 2012
Joel
December 30, 2011
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.
2. The readln (etc) isn't much good, same problem as Linux. It can only add characters and remove characters from the end.
December 31, 2011
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.

> 2. The readln (etc) isn't much good, same problem as Linux. It can only
> add characters and remove characters from the end.


-- 
/Jacob Carlborg
January 01, 2012
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.

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

>> 2. The readln (etc) isn't much good, same problem as Linux. It can only
>> add characters and remove characters from the end.
>
>

January 01, 2012
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.

January 01, 2012
On Sunday, 1 January 2012 at 11:54:46 UTC, Mike Parker wrote:
> Personally, I think wrappers are a waste of time, but some people prefer them to using a C API directly.

I agree for wrappers that mindlessly provide a different syntax for the same functionality, but wrappers can take advantage of more advanced language features to provide better safety, genericity or brevity than the original. These are the wrappers that are worth writing and worth using.
January 01, 2012
Thanks very much Mike. I guess I've got a bit of a wrapper over a binding.

I'll look more into Derelict for Mac OSX.
January 02, 2012
On 1/2/2012 6:10 AM, Joel Christensen wrote:
> Thanks very much Mike. I guess I've got a bit of a wrapper over a binding.
>
> I'll look more into Derelict for Mac OSX.

If it's DerelictAllegro you're using, then you need to know this. Derelict loads libraries manually (via dlopen on Posix systems). This means you have to do this in your code for each binding you want to use:

DerelictAllegro.load();

This will use preconfigured paths to load the libraries. Currently, DerelictAllegro is only configured to load on Windows. I need to figure out how it is typically installed on OSX so I can pass the correct paths to the loader. It should just be a matter of a quick Google, but it might be a few hours yet before I can get to it.

In the meantime, the load method accepts a string parameter if you want to load a specific library. So you can do this for now:

DerelictAllegro.load("path");

... where path is the framework/dylib/so, whatever the case may be. Aside from that, the rest should just work.
January 02, 2012
On Sunday, 1 January 2012 at 11:54:46 UTC, Mike Parker wrote:
> 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.
>

I seem to get SDL to work, but not OpenGL. I copied it's frame work from system some where to another frameworks place. I've got XCode installed.

P.S. I wont have OSX for a while soon, (getting a new computer). Also lost my previous login password, so I've started a new one.

[snip]

January 02, 2012
[snip]

> I seem to get SDL to work, but not OpenGL. I copied it's frame work from system some where to another frameworks place. I've got XCode installed.

Hmm. I had a go at another test program I found and got it working.

Graphics with D on OSX, so now that's Windows, Ubuntu, and now OSX. Just one solid colour, mind.

[snip]