To use irrlicht version 1.9 in JNI for Android(Android NDK)

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Karthik Sivam
Posts: 6
Joined: Mon Apr 21, 2014 6:54 am

To use irrlicht version 1.9 in JNI for Android(Android NDK)

Post by Karthik Sivam »

I'm currently working on an Android project in which I have used
Irrlicht Engine version 1.9
 in NativeActivity to create a scene. Now I'm in need of creating the same scene in Java activity, So I preferred JNI for this, but the problem I'm facing now is how can I get the value of

Code: Select all

android_app*
(which I get as an argument in anroid_main() function in Native Activity) so that I can assign it to

Code: Select all

param.privateData
. Is there any other way to create irrlicht scene within a Java Activity or is there a way to intent(switch) between NativeActivity and Java Activity?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: To use irrlicht version 1.9 in JNI for Android(Android N

Post by CuteAlien »

We get android_app* from Android - it's part of the official NDK interface (meaning every native app starts like this). Not sure if Android offers other ways to pass this (google around...).

Also there might be another problem (but as I never tried this stuff myself I'm entering pure-guess-territory here and the following might be all wrong): I think the surface we take is always full-screen. So using Irrlicht inside another app on Android might mean you would have to figure out a way to pass through the surface to render on as well (the way it's done for Windows in Irrlicht example 14). I don't think that's supported on Android so far. Not even sure if it's possible, thought I suppose it might be. Which means you'll likely have to dig into the sources in this case and figure it out yourself. The good news is - that part that does set-up the surface is nicely wrapped and not too large - so if you are an experienced coder you might be able to figure it out.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Karthik Sivam
Posts: 6
Joined: Mon Apr 21, 2014 6:54 am

Re: To use irrlicht version 1.9 in JNI for Android(Android N

Post by Karthik Sivam »

Thank you, I'll look around whether I can find anything.
bmiller
Posts: 4
Joined: Fri Jul 01, 2016 6:50 pm

Re: To use irrlicht version 1.9 in JNI for Android(Android N

Post by bmiller »

Karthik Sivam : did you ever solve this ?

If I have a Java Android Activity as the main and only Activity of my Android app,
and use JNI to call C++ code (including OpenCV calls), is it possible to initialize
Irrlicht device / driver / scene ?

The CIrrDeviceAndroid constructor code includes this:

Code: Select all

 
        // Get the interface to the native Android activity.
        Android = (android_app*)(param.PrivateData);
 
        // Set the private data so we can use it in any static callbacks.
        Android->userData = this;
 
        // Set the default command handler. This is a callback function that the Android
        // OS invokes to send the native activity messages.
        Android->onAppCmd = handleAndroidCommand;
 
How can I set the PrivateData if I don't have a Native Activity ?

Brian Miller
Post Reply