White Shining Rock Logo
White Shining Rock Logo

OSX Progress

November 10, 2015 | Dukus | 40 Comments

This was a pretty good week of coding. After implementing some core platform specific code and moving the Windows OpenGL code to Mac OSX, the game rendered on the screen without any issue.


Banished on OSX

Well, I shouldn't say without any issue. It runs at less than 1 frame per second and water isn't rendering correctly. There's still no sound and no input, no Steam integration and it lacks the ability to resize the window and shut down. But I'm getting there. It's good progress.

Working on Mac and doing this port has been a good experience. This week I hope to head back and spend time on the current Beta version a bit to work out some issues, then get back to the Mac version.

In the mean time here's some thoughts on working on Mac. I've been using Windows exclusively (except for console programming) for a long time, and OSX is a new system to me, so don't be offended if I'm getting things wrong. 🙂

Using a Mac

I don't know anything about OSX. When I started I could open the web browser, and that's about it. I stumbled with the user interface for a bit, couldn't figure out how an 'All Files' category was useful when browsing finder windows, but then realized I could open a term window and that I was really using a unix-like system with a user interface that wasn't X Windows. Good deal, I can do that.

So after that, file organization and using the machine was easy, and I was comfortably editing files using vi. Apparently my vi command muscle memory hasn't totally faded.

Development Environment: Xcode

Xcode isn't too bad. It was fairly intuitive to bring the Banished source into it, setup the required compiler settings and get to work. I mostly turned off it's auto formatting since it does things that don't go with my code style, and the intellesense is a bit overdone, but overall it's an IDE that gets the job done.

Languages: Objective-C

When I look at Objective-C and the general Cocoa libraries, I feel like I'm looking at a foreign language I haven't used in 20 years. I bought a book on it to help out. I mostly get it, but I just feel like I'm missing a fundamental knowledge base. Luckily there's not that much of it I have to write or use before it jumps straight into the C++ code that's common to all platforms.

I just need to spend more time with it. And read the book.

Code portability

I had the best intentions of writing my game engine using portable C++. I didn't do anything crazy with the language, and any platform specific chuncks were tucked away in their own files to be replaced per platform.

While that was a good start, I don't think it's possible to actually write cross platform code until you're compiling the code with multiple compilers. Even before I could get to writing the OSX specifics, I had many errors and warnings that clang presented that the Microsoft compiler just overlooked.

Most of these had to do with templates that expected the code inside them not to be compiled until they were instantiated. The Microsoft compiler has that behavior, while clang does not. There's command line flags for a compatibility mode, but I'd rather just fix the issues so that other compilers won't treat the errors the same way.

Once the common code was compiling cleanly, I started writing things specific to OSX. Memory management, file I/O, timers, date handling, threading, etc. What is nice, is being a unixy environment, a ton of the platform specific code will also work on Linux and Steam Box. When I get to working on Linux more fully it should go quickly.

I did have a few issues that required changes to both the Windows and Mac code bases to make sharing more code possible, but it was an easy refactor.

I'm glad I spent the time to write a common shader language, switch to UTF8, and make other changes to the engine to make porting easier. I could have just ported as the code was, but it would have been a lot more labor intensive and bug prone.

Currently the toolset for Banished only works on Windows - so it's really just the engine and game code that are being written for OSX. This is a little annoying, as all the data has to be compiled on the PC, and then the Mac just reads it. I should convert everything to work on all platforms, so that I don't have to flipflop machines, but this would take a lot of additional effort.


The OpenGL code I wrote for Windows came over smoothly, without any compile errors. Although I did have to write the platform specific startup code to create pixel formats and OpenGL contexts. I'm not using SDL or any other library to hide those platform differences.

I unfortunately have two different sets of the same GL code now. The Windows code is nearly identical, but since Windows supports multiple renderers (DX9/DX11/GL/etc) there's some abstractions and separation of data that doesn't exist on Mac.

Copy-pasted-slightly-edited code like this annoys me a bit but at the moment I don't have a good way to abstract away the differences. It's not terrible, but a little frustrating to have to update two sets of the same code when bug fixes are made. At least the Linux build should share the code 100%.

If nothing else, it was satisfying to actually see the title screen come up on the first try after bringing over the OpenGL code. If I was writing for a console (or other graphics API) it'd probably take an entire week just getting the first triangle on the screen.

The fact that it's running at 1 FPS is a little disheartening - I know the GPU is fast enough. I've got a Windows machine with an Intel Iris Pro 5000 that runs Banished just fine, which is the same graphics hardware in my MacBook Pro. I've got my suspicions as to whats going on but I have a bunch of testing ahead of me to make sure I fix the issue properly.

More Coding

I've got a bit more coding and learning about Mac to do before the port is done. I don't expect the remaining tasks to be too arduous - playing sounds, reading input, and compiling the Steam library should be easy. ish. Maybe.

Leave a Reply

Your email address will not be published.

40 comments on “OSX Progress”

  1. THANK YOU !!!

    I've been a long-time player of Banished on Mac OSX via Crossover Office/Wine and Banished crashes so often I can no longer play it. I have an old Windows box but it can't handle the game's graphics; even with a newer graphics card.

    I just wanted to let you know that I can't wait for the finished product and look forward to many more hours of B, but in my native OS!

    Thank you again for your hard work and as a paid Windows Banished user from GOG, I'd be happy to purchase the Mac OS version.

    Feel free to email me if/when you need Mac OSX beta testers.


  2. Yes, Apple rewrote the entire Mac OS in Unix a few years ago (well, OS X came out in 2002 - that's only a few years to me!) I very much enjoy Banished and look forward to playing it on my Mac. Love my PC, but love my Mac a lot more, it never crashes. It must be that legendary Unix stability. Cheers, and thanks for creating Banished.

  3. Hey, I'm so excited that you are making a Mac version of the game! I loved it on Windows, but just got a new MacBook and they sell them with tiny hard drives now so I don't have enough room to dual boot. I will be counting down the days until the Mac release, hopefully it's soon. Keep up the good work!

  4. Thank you for continuing to work on porting. I can't wait to get off Wine and play Banish natively!

  5. Sounds like a big amount of work, but you also seem to be very clear about what you have to do for it.
    Good luck Luke, your work is inspiring!

  6. my game keeps crashing with fatal errors. it's not even close to playable. hopefully this issue gets fixed. i love this game! getting close to the most time i've spent with any game in my whole life (40yrs)
    tried the beta and the fatal errors got even worse. any solutions?

  7. Drivers aren't that bad to cause 1FPS, so you know it's code. Retina resolution? Could be, that's a lot of pixels to push!

    Are your textures getting replaced every frame or something like that? I would run through a few frames in the debugger and see what it is doing.

  8. Thank you for sharing your porting experience and thank you for writing such a beatiful game in the first place!

  9. Hey awesome to hear that my favourite game is finally coming to Mac!

    Btw if you get spare time check out Metal APIs for MacOS - its the new high performance graphics apis that is far superior to OpenGL implementation on OSX.

  10. An enlightening post.

    As a long-time Mac user, I'd like to comment on one thing:

    > couldn’t figure out how an ‘All Files’ category was useful

    It's not just you - no-one can, it's horrible.

    Luckily, if you go to Finder > Preferences > Sidebar you can turn it off.

    Good luck!

  11. You mentioned that you have problems maintaining little differences in your code. Obviously the first level is C-preprocessor. Then comes M4 macro processor in the Unix world. However the usage is too difficult for me, so I use my own solution.

    Mucgly performs code generation in template style. Most of the file content is the exact/literal C/C++ code and the differentiated parts are hooks. The hooks contain Ruby code that generates the differentiated code. You can make the hook look like a comment if you want, etc.

  12. What surprises me is that your OpenGL code appears to compile at all. OS X does not have a compatibility mode and you need to make sure everything is in an OpenGL core profile 3.2 if you want any 3.x functionality at all. But maybe you are using OpenGL 2 specifications?

  13. Hey if you need some testers for mac version I'd be happy to spend some time on it, haven't tried the game before but I really like the concept, would be happy to help making a mac version come about (I don't have a PC 🙂

    I'm a developer (android / backend) so hopefully I could provide relevant feedback.

  14. Be glad to help test with the linux version when it's ready. I've already got a key ready to redeem on Steam, too. 🙂

  15. I’ve got the same question like Trond Klakken. Why are you using Objective C instead of Swift. I’m programing for OS X an iOS an I’m learning Swift at the moment. I think it’s a really powerful language with some features I really miss in other languages, even now. Objective C will be marked as deprecated in the next view years, Apple don’s accepts new apps for the App Store written in Objective C already.
    In my opinion it would be better to learn / use the new language Swift than the outdated (and soonly deprecated) Objective C.

  16. You can install Windows on a VM on your Mac if you want to use your tools without switching computers. Both Parallel and VMWare are good. They both create a shared desktop that allows to work seamlessly with both systems.

    For those suggesting Swift: for the small amount of glue code necessary to bootstrap into the C++ code, you're much better with the language that interoperate the best with it. I even suggest you use the mm extension for your files, which make them in the bastard Objective-C++ language and allow you to mix Objective-C and C++ constructs.

    Finally, a +1 for learning Metal. The OpenGL implementation on OS X has always been slow and out of date. With their own API now, I guess it will just get worse. You already have a completely separated graphic pipeline for OS X 🙂

    -Alex, retired Mac game port developer 🙂

  17. I to have experience working on cross platform projects (using a C++ code base), and for all you folks asking why he doesn't use Swift for the OS X specific code: it's because the Swift to native interface is just harder to work with. Objective-C makes it much easier to go from the OS X code to the platform agnostic stuff.

    Also +1 for Metal. If what they claim is true, it should be a much more performant API than OpenGL could ever hope to be.

  18. Interesting post - great to hear and hope you enjoy the journey to shipping on OSX.

    Out of my own curiosity, was there a reason you didn't go with SDL? Were there platform specific calls / API you needed to use?

  19. If you haven't seen it yet, XCode has a built-in profiler called Instruments. It's just a few clicks away and is a really easy way to start doing some basic sample-based profiling of your code.

  20. Thank you for still working on OSX! I'm excited to see your progress. It's always great to read your blog posts. Your dedication is incredible~

  21. Nice to hear you are back on track! Love seeing the Mac version. Currently an owner of the windows version.

  22. So far, I managed to go though only some of the posts you have here, but I find them very interesting and informative. Just want say thank you for the information you have shared.
    If you love gaming for unity games kindly visit….
    Unity game templates

  23. Hi Luke,

    nice to hear something is still going on. It was a bit quite regarding the ports of the game. Hopefully they might be finished soon, even if you still pause the port atm.

    PS: Under *NIX systems it might be a good idea to try vim instead of vi. Vim = viimproved ... you got plenty of nice plugins. It's very nice to develope with that one - you don't even need an IDE.

    Btw: Why didn't you use SDL? That does make life much more easier!

  24. Well done on this! I cant wait for an OSX version, have been playing through boot camp for months and a native version will be great. My favourite chill out game (on easy mode...)

  25. Great new ! We are in Mac computer till some years and i've expecting that game will arrive on that plateforme to finaly discover it !

    Hardly wainting !

  26. Great to hear that you are still working on Banished, been enjoying building my 1st village so far.

    And great to know that you're exploring OSX as well! Starting to like it and things make much more sense than Windows. Bash is a clear win.

  27. This is the exact reason I came to the website today. I use a mac, and have to go into parallels to play Banished, which works - sort of. Keep going! Banished is the perfect game for the mac.

  28. Hello. I bought this game last week. Can't wait for it to be availabile on Linux :D.
    Good luck with porting it to Mac, I hope it won't be yet another struggle porting it to Linux as well, since they share quite a lot of simmilarities.
    Also... learning a new OS is just like learning a new language IRL 😀 it's great

More Posts

Code Rot

April 17, 2022
1 2 3 47
Back to devlog
Back to devlog
© Copyright 2021 Shining Rock Software
Website Design & Branding by Carrboro Creative
menu-circlecross-circle linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram