Creating a cross-platform C++ engine, incl. android and IOS

Started by
5 comments, last by frob 11 years, 2 months ago

Hello all,

forgive me for posting about a topic that has probably been discussed several times; I do feel that my question has a few extra points though and I have done a couple of days of reading on the matter.

I started writing a game engine in C++ with Ogre3D, SDL and Bullet physics. I have got 70% of a game done with it but it was just not written very well with some fundamental issues so I am starting again with those lessons learned. One of the reasons I am so keen on using C++ is that I am trying to better myself in C++ (since that is what my career is based around).

This time I also want to consider how I can code the engine in the best way possible to be able to 'port' it to android and IOS (as well as supporting Windows/linux/mac) since I realised the current engine I have it would be near impossible to do. I have done a lot of reading about the android NDK and Objective-C but I'm still not really sure.

I do understand that on any platform there will always be specifics that will need to be written for that platform regardless (I think I read that I'd have to code the UI myself for android at least) but I'd like to avoid rewriting code as much as possible.

Ideally I would like to avoid tools like Unity as that is C# and costs a fair bit of money for licensing extra platforms which I just don't have at the moment. I also want the experience of writing more of the engine than a tool like Unity will allow (even if it is just piecing a few pieces of middleware together).

Will it just be easier to write 3 separate engines? One for PC/Mac/Linux and one for each mobile platform? Should I try and brush up on plain old OpenGL and OpenGL ES 2.0 for phones.

Am I trying to do too much for a one man job?

I'd be glad of any thoughts any of you have on this matter.

Thanks for reading,

Nixius

Advertisement
Being a systems programmer for one platform is hard. Doing it for multiple platforms would be a good learning experience but it would be improbable to become expert at all of them at once without many years of experience.

You will likely come up with a set of multi-platform common code using per-device abstractions.

If that is your passion then go for it. I don't know too many people who have that passion once they understand what it really means.

Thanks for your reply.

Hmmm... you are probably right there, maybe I am biting off far more than I can chew at my current level and for a project on my own.

Perhaps then, I will initially concentrate on a PC/Mac/Linux engine and get proficient at that, populating the engine's functionality with a few games and then try my hand at a mobile platform completely separately.

Once I feel I have mastered those, perhaps then I may be in a better position to tackle something like I initially proposed.

Do you think that sounds like a more plausible approach?

It just irks me that I will be starting something I know I will probably have to rewrite, perhaps that is just something I will have to swallow; at least for now.

Nixius

You dont want to write 3 separate engines. Write a single engine and put as much functionality as you can into platform-independent code. Current mobile platforms are similar enough to the others (PC/Mac/Linux) that this should be a doable objective if you're writing in C++.

With each platform the parts that will mostly have to be platform-dependent will be the setup code, UI, and graphics. If you're using OpenGL then you can get most of the graphics code to work on all those platforms. Just make sure you still make the wrapper layer platform-independent so you can easily add new platforms later (like DirectX for Xbox, etc).

As far as the setup code, just make sure you only do as little as needed to get the app up and running, then hand off the updating, rendering, input handling to the platform-independent code.

For UI, if you have your own UI system, then it's not a problem. If you use each platforms native solution (Interface Builder in iOS, etc), then you do need to rewrite that for each one.

Hello, you will need a platform abstraction that will allow you to code your game without worrying about the environment (PC/Mac/Android/etc...) ; then you will need to implement your platform abstraction for any supported environment.

If I'm not wrong, iOS does not support C++, so you will not be able to get a "write once, run every where" system (at least, it will not run on iOS).

Space Zig-Zag, a casual game of skill for Android by Sporniket-Studio.com

Hello, you will need a platform abstraction that will allow you to code your game without worrying about the environment (PC/Mac/Android/etc...) ; then you will need to implement your platform abstraction for any supported environment.

If I'm not wrong, iOS does not support C++, so you will not be able to get a "write once, run every where" system (at least, it will not run on iOS).

You're wrong. You do need an Objective C layer, though.

Please don't revive old threads. The OP had his questions answered months ago.

This topic is closed to new replies.

Advertisement