Working on Linux and Mac port

Hi there,

Currently I’m trying to create Grimind builds for Linux and Mac and it’s nightmare.


Basically, I moved my code form Visual C++ to Eclipse under Linux and most of my code worked correctly right away.  It’s because I used cross platform libraries like: GLFW, SDL,  SDL_mixer, OpenGL – that’s cool. But when I run Grimind for first time it looked ridiculous. Particles were spawning only at one place and there was many graphical glitches.  This is why it happened:

  • On windows I used to use abs(…) function for float numbers and it worked correctly so abs(-1.2f) was changed into 1.2f so it worked for floats. On Linux there is no abs function for floats, so the same code on Linux produced bad return value. In this case -1.2f was converted first into integer value -1 and then the return value was 1 not 1.2f. The solution to that problem was to replace all abs functions to fabs 
  • I was mixing two values RAND_MAX and 32767 which on windows these was the same.  On Linux RAND_MAX is 2147483647 so it is much larger number than 32767. In addition I was dividing random number from range 0..32767 by RAND_MAX. On windows this was correct and division result was from 0 to 1 that’s OK but on Linux this range was from 0 to 0.00001525832 not 1 and that’s why particles was spawning just in small area

I was able to create 32 bit build and it’s working but I still can’t make 64 bit to work correctly everywhere (it’s working for me)


I used xcode 4.6 to create build and it’s working fine but I cant set deployment target to 10.6 (Snow Leopard) because I use c++11 features in my code. That could mean that I will be able to create Grimind Mac build only for 10.7 and later (Lion and Mountain Lion) but I will look at this once again.

4 thoughts on “Working on Linux and Mac port

  1. According to the C++ standard the float and double overloads for the std::abs() function are defined in the “cmath” header. Looks like you either forgot to include cmath or to use the std namespace — otherwise abs() should have worked as expected.

    Anyway, if those two examples were your worst portability issues you did an incredible job writing portable code in the first place! The game runs flawlessly on my 64-bit Fedora 18 machine.

    • Thanks for tip with cmath and kind words. Glad to know that the game is working.
      There was also some minor issues with like changing std::function to std::tr1::function and using bit different code for listing files in directory (dirent.h on Linux)

  2. Porting was fairly easy, wasnt it? Good job from you. Grimind is an interesting game, I liked the physics/controlling the character, but you need to work on audiovisuals (or consider collaboration with some kind of artist).

    • Yes, it was quite easy because of great multi-platform libraries I use.
      In my next games I will definitely work more on polishing graphics and everything else (Grimind is my first time in making games). Thanks for feedback

Leave a Reply

Your email address will not be published. Required fields are marked *