OSX Port and matrices

Now I’ve got a working source control solution up and running it’s made it much easier to port my code base around to different operating systems as I can pull it down and play with it without having to copy the entire thing around.

So after having imported my sources on windows, I got everything running under 64 bit ubuntu (no problems there really, just hacked my makefiles to detect the os/host type rather than editing it by hand everytime). After that though the challenge I’d set myself was to port onto OSX. Now I’m not to familiar with OSX (yet) so this was probably more of a challenge than it should be.

I struggled with simple keyboard shortcuts not working as expected and the idea of the application menu bar always being at the top of the screen (wasn’t the Amiga OS like that though, I’m too old perhaps to remember). I also found it odd that I could close all the open windows of an application but it would remain be open.

My first problem was finding a nice text editing program for hacking around on text files. Under windows I use and would recommend notepad++ for this purpose. However it took me a while to find a suitable replacement for OSX. In the end I plumped for jEdit which Java based and so in theory I can actually use across all my environments if I want. Whilst jEdit worked fine I also wanted to be able to launch it from within the bash terminal shell, for example by typing jEdit ~/.bashrc and it launching the editor pointed at the correct place. This turned out not to be as easy as I’d have liked because of the way apps work. I’ve written an article about launching OSX apps from the command line if anyone is interested.

After getting all this working I played around with XCode and managed to import my code base and after a little struggling got it all to compile. As my library wraps SDL for it’s OpenGL, window management and input code it wasn’t even too hard to get my PlaneGame” up and running on OSX too. Next step is an iPhone port of the library!

In the meantime though I also have another little project I’m working on. This one requires full 3D rather than the 2D (built on top of 3D) approach that PlaneGame is currently using. In what should be a simple process of setting up a camera I ran into some matrix maths problems that I just couldn’t seem to figure out. I finally cracked it – I’m used to DirectX’s row major matrices whereas OpenGL uses column major matrices. However because GL’s vectors are column vectors and DirectX’s are row major the linear representation in memory is the same. Once I start multiplying those vectors together though all bets are off though as they result in transformations being applied in different orders. Now my matrix library is far more robust – I can request matrices and vectors to be row/column major and still have everything work as expected.

Leave a Reply

You must be logged in to post a comment.