How is cross platform done

Started by
12 comments, last by jwezorek 8 years, 9 months ago

This question is a little hard to word, but I was wondering how do people make things cross platform? How do people create one engine (EG libGDX, GameMaker, cocas2d, etc) and then are able to deploy onto different systems / architecture? Especially when considering mobile systems using Android and IOS

Advertisement
That's about as hard to answer as "how do people cook."

There are many ways, many tools, and many considerations to take into account, particularly depending on the platform set you wish to target.

Most of it boils down to using building blocks that are commonly available on multiple platforms. For example, the C language is pretty much everywhere. Java supports many platforms natively. And so on.

It also highly depends on what you're building. A low-level library that does math is a totally different beast to get cross-platform than, say, a game based on 2D sprites.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

One good way is to build a common interface for doing a certain task, such as handling files. You then implement that interface for each platform you want to target. You can then write your code around the common interface and swap out the implementation when you build for each platform.

My current game project Platform RPG

In the general case, nothing is cross platform.

What actually happens is the bit you care about is cross platform, but under the hood there is a platform dependent layer.

So in Java you have the JVM (Java Virtual Machine) which is platform specific, the Java code you write runs in any JVM, so is cross platform.

In languages that don't rely on some sort of virtual machine, then the have a platform independency layer. Everything above this layer is cross platform, anything below it is platform dependent.

How you implement the PIL is up to you. As HappyCoder says, it is very common to use a simple interface for everything and just swap out the dependent code at build time.

The approach I used when I had to work in assembler was basically this. I had a set of macros for each platform (I am sad to say these were platforms like Sinclair spectrum, MSX, C64, C16, .... blink.png ) which defined things like LOADA VALUE which would then map to lda #value on the 6502 or Ld a,value on the Z80.

Later on we got more advanced thanks to ideas from guys like Chris Hinsley. We would compile the code into device independent byte code and convert them into native machine code at load time. So we didn't have the overhead of the virtual machine.

LLVM is the same idea. Clang can compile to LLVM byte code which executes on most platforms, but you still need the calls into the system OS to be platform dependent.

And if you are set on Java (as the topic tags imply), then the unfortunate answer is that Java and iOS don't play nice.

There are a few 3rd-party toolkits that either deploy a stripped-down JVM to the iPhone, or attempt to translate java code into Objective-C, but neither of these options is a terribly effective way of writing code for iOS.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

That's about as hard to answer as "how do people cook."

Most of it boils down to [...]

I see what you did there

"I would try to find halo source code by bungie best fps engine ever created, u see why call of duty loses speed due to its detail." -- GettingNifty

And if you are set on Java (as the topic tags imply), then the unfortunate answer is that Java and iOS don't play nice.

There are a few 3rd-party toolkits that either deploy a stripped-down JVM to the iPhone, or attempt to translate java code into Objective-C, but neither of these options is a terribly effective way of writing code for iOS.

Originally I was going to ask, how is it possible to take an android app and get it over to IOS. But I already knew the answer to that question kind of and you are right there is no real good way

In my situation, I have my own little game engine made in Android Studio. And I can create whatever game I want, but if I ever wanted that game to be on IOS I think I'm completely SOL

Quick solutions that come to mind are to port the engine over to IOS. Then code my game in java and use a tool like J2ObjC to make the IOS conversion. Fix up whatever tat can't be converted.

Are there better ways?

That's about as hard to answer as "how do people cook."

Most of it boils down to [...]

I see what you did there

hehehe :)

Are there better ways?
RoboVM might work.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

If you've got the cash, Xamarin might be an option

Eric Richards

SlimDX tutorials - http://www.richardssoftware.net/

Twitter - @EricRichards22

If you've got the cash, Xamarin might be an option

With the caveat that Xamarin is C#, not Java.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement