Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently planning to implement a little painting app using OpenGL ES 1.1. I believe this question applies to any OpenGL ES project. I am starting development on Android and I would like to know if you would recommend writing the drawing logic (using OpenGL) in C++ with the NDK so it will easier to port to iOS, or to use the Java API and being locked on Android.

The reason I am asking that is because I have seen mixed opinions on the Web about using the NDK (some people say it is an added level of complexity). From what I have already seen, I believe that I should go with the Java API since I am starting on Android and then, if I decide to go on iOS, to rewrite the OpenGL logic in Objective-C or C++. This should be pretty straightforward since the calls appear to be the same in both languages. What do you think? Am I right?

share|improve this question

Yes, NDK will add a layer of complexity. But it will probably be worth it.

If your drawing is done in c++, then you better implement your model in C++ too. That gives you less code to rewrite for iOS and less code to maintain.

Luckily (in this case) OpenGL is state machine, so it is fairly simple to set up the rendering context in java (being close to the GUI code) and then pass control to C++ for the actual OpenGL drawing calls.

Implementing an NDK (JNI) interface is quite repetitive. It might feel ugly to set up your first three classes or so. After that you'll get the hang of it and it is just interface desig and typing code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.