How feasible is using the NDK?

Started by
14 comments, last by JoeJ 11 years, 1 month ago

Hey, sorry to piggy back on this thread, but I'm also just doing an introductory look into android, but I'm looking to use the NDK. How feasible is using the NDK? How easy is it to integrate an already made C++ engine to work with Android? I know there is some unavoidable Java code that I'll have to write to query platform features and such, but how intrusive is that code?

I'm an experienced C++ programmer and would really like to target the platform if it doesn't require a whole rewrite of my engine.

Perception is when one imagination clashes with another
Advertisement
Spitting this off to its own thread. Please start a new thread for a new question.
Exactly how easy or difficult it would be depends entirely on the code base.

There is no way to know with the information you provided.

If you have a small code base or an extremely simple code base it could be a relatively simple matter.

If you have a large code base or an extremely complex code base it could be a relatively complex matter.

Hah fair enough, sorry to intrude on the other thread.

I have an engine that is primarily just rendering tech with some additional functionality like cameras, file IO, the like. It's a completely cross platform engine though, and I render using OpenGL, DirectX 9, and DirectX 11. I should be able to fold OpenGL ES into my engine well enough, but I'm worried about rendering not being a clean break from Java. Like how much Java code would I have to write to just get my engine spinning under the hood?

I'm sorry, I know it's a very vague question.

Perception is when one imagination clashes with another
I don't understand what you are trying to get at with the question.

We cannot give an answer that makes sense. "It takes 3 units of work". Or maybe more. Or less. We don't know your engine.


Is it possible? Yes, it is possible.

I guess my question is, how intrusive is the Java code necessary to properly initialize an engine and run with it?

Perception is when one imagination clashes with another

You can use native-activity, then you don't need to mess with Java. And example is in samples folder.

Awesome, thank you. I haven't dug into the samples yet, I'm just probing around a bit.

Perception is when one imagination clashes with another

I wish you luck but sharing a bit of my experience its not pretty but I do hope it keeps getting better.

Pros

1. Ease of conversion only real issue was pthread_cancel in my case

2. Excellent performance must faster than java in some heavy cpu encryption cases

Cons

1. With much research I still cannot get a gl context without java

2. Targeting multiple devices is a pain I must be doing something wrong but that leads to 3. Out of the 4 devices in my home apparently there are 3 different types of arm cores which makes sense being some are old and 1 is a media player but I still havent been able to get all of them to work.

3. Horrible docs alot of things are not documented

4. pthread_cancel is non existent and probably more but thats just something my project was using that it cant anymore.

I hope this is just me and not the ndk itself this has just been my experience and I have never compiled for arm devices before maybe someone knowing more can put tell if the cons are just me or not I would be interested to know.

One note about my findings so far I have not done audio so thats a bit scary as the library we were using is not capable and were looking for low level audio im not sure how well it will come out.

I've found using the NDK fairly simple and had very little trouble with it. I'm not using Native Activity but still the amount of Java I have in my codebase is around 20 ~ 30 lines.
There are also several open source engines available that you can look at for inspiration too. Cocos2d-X, gameplay3D and this one:
http://www.wrox.com/WileyCDA/WroxTitle/productCd-1119975913,descCd-DOWNLOAD.html
which comes with the programming games and graphicsfor Android. amd iOS book.

I think there is also a cross platform quake port floating around somewhere too.

This topic is closed to new replies.

Advertisement