Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Ive been reteaching myself opengl so I can make a game on android. However Ive been struggling with how to build objects and scenes in opengl using c/c++ and passing them through the jni to the virtual machine where android can use them. Can some one point me towards some tutorials that actually show the use of natively built objects being created and passed through to the jni. Im fine using c++ or java I just dont have much experience using the jni. Ive built some sample projects where I pass primitives like floats and perform operations on them on the native side and then passed them back but I cant figure out how to create a scene in opengl in c++ and then pass it to java. Ive been looking at writing everything using java but Im not sure if the java bindings make for some performance loss.

Any help would be much appreciated

share|improve this question
    
If JNI is anything like P/Invoke (.Net) you won't be able to pass 'objects'. While it's technically possible if you can mimic the name mangling etc. I have never seen anyone write a tool to do this - you might need to use clean C. –  Jonathan Dickinson Jan 1 '12 at 22:56
    
Hmmmm.....yeah I tried using just loading evertying into jObjects but that didnt work so well lol....I didnt expect it to but I had to try. I fine with programming in c/c++ in fact I would rather but how can I run whole scenes and ui interfaces from the native side. I know that you cant run a whole app natively so Im stuck on how to use c/c++ for more than just math operations at the moment. –  James andresakis Jan 1 '12 at 23:16
    
With Android 2.3+ there's NativeActivity which lets you write a full activity in C++, it depends on whether you want to support 2.2 and below. –  Robert Rouhani Jan 1 '12 at 23:36
    
Im currently building everything for 2.2 but I might just jump up to 2.3 being that every new phone and tablet capable of running what I want to build is going to have at the minimum 2.3. Ill take a look at the google/android docs on that but do you know of any tutorials on whole native activities being built in c/c++ and using the NativeActivity method? Im just struggling with how to create my "main" so to speak so that it will run in android. For example, so far everything Ive created in the ndk is basically just native methods/functions I call through jni. –  James andresakis Jan 1 '12 at 23:41
1  
Here's some documentation (and a full OpenGL ES example) of using NativeActivity: developer.android.com/reference/android/app/NativeActivity.html –  Robert Rouhani Jan 2 '12 at 1:03
show 4 more comments

1 Answer

up vote 0 down vote accepted

Well it looks like for the time being I will go with Java to use the opengl. I have noticed a definite increase in performance so I cant say how much more I would see rewriting my code all in c++ although I just got a new book on the developing apps all in the ndk and I might take it up some time soon. If anyones interested the book is called Android NDK Beginner's Guide and so far its helped me quite a bit.

share|improve this answer
add comment

Your Answer

 
discard

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.