[Tutorial] Irrlicht on Android and IOS Mobile

A forum to store posts deemed exceptionally wise and useful

[Tutorial] Irrlicht on Android and IOS Mobile

Postby Neirdan » Sat Apr 05, 2014 9:03 am

I'm not an expert, there are things that I don't know, but here is my experience gathered.
Right now it's focused on Android / Windows because that's the only thing I know but feel free to add your own stuff.

Download links

Irrlicht:

OGL-ES branch of Irrlicht project
Nightly builds provided by ent1ty

Glut required to compile Irrlicht library on Windows

Android:

Android SDK bundle
Android NDK
JDK (AND NOT JRE)
Apache Ant

Common problems

- Meshes with over 65535 triangles:
CuteAlien wrote:2 problems responsible for that. First in COGLESDriver.cpp (also in ES2 driver). There getMaximalPrimitiveCount() returns always 65535 - that's the check where it fails in your case (and which probably isn't quite correct, but I won't modify it for now as I'm not familiar enough with the code). You should get an error for that in the error.log in debug (with: adb logcat Irrlicht:V *:S).

But even when trying to increase that constant it won't work here because my device doesn't have the GL_OES_element_index_uint extension which is needed to support 32-bit drawElements calls (https://www.khronos.org/registry/gles/e ... x_uint.txt). And given that I have a rather new device (moto g) it's probably a better idea to split your models into smaller blocks than expecting devices to have support for it.


- Textures with width or height different than a power of 2 don't work on some mobiles.

Setting up your Windows environment for Android

First of all, you need to set up your environment variables.

1) Opening the window: (Windows + R) and type "Environment variables"

2) SYSTEM VARIABLES

inside "PATH" Variable - You should put everything in the same variable, each path separated by a ;
Nota: disregard the comments in (parenthesis)

cpp Code: Select all
 
D:\adt-bundle-windows-x86_64-20131030\sdk\platform-tools; (Platform tools - you'll mostly use "adb")
D:\adt-bundle-windows-x86_64-20131030\sdk; (the SDK)
D:\apache-ant-1.9.3\bin; (Apache Ant binaries)
D:\android-ndk-r9c; (the NDK)


3) USER VARIABLES

Add:
Nota: disregard the comments in (parenthesis)

cpp Code: Select all
 
JAVA_HOME C:\Program Files\Java\jdk1.7.0_45 (it should point to your JDK, obviously)
ANDROID_HOME D:\adt-bundle-windows-x86_64-20131030\sdk (it should point to the SDK)
 


Compiling and testing your project

1) Open command tool (Windows +R) and type cmd
2) Go in your project root directory
3)
cpp Code: Select all
ndk-build
(compiles the source of the project based on jni/Android.mk & jni/Application.mk)
4)
cpp Code: Select all
ant debug
(Creates the .apk file in the bin/ folder using AndroidManifest.xml and build.xml)
5)
cpp Code: Select all
cd bin
(Go in the subdirectory where the .apk was created)
6)
cpp Code: Select all
adb -d install HelloWorld-debug.apk
(use -e if you want to use an emulator)
7) It's done.

Tips & Tricks

Explanation on .mk files

Removing the "three vertical dot" button

Stack overflow question about removing the three dot indicator*
Basically, either you overload the java, either you modify your minimal SDK version to 14 (which means Android 4.0)

Change the minimal SDK version

Android SDK versions history
Official android statistics (API version distribution, device sizes, OGL version distribution)

cpp Code: Select all
AndroidManifest.xml <uses-sdk android:minSdkVersion="10"/>
project.properties target = android-10
jni/Application.mk APP_PLATFORM := android-10


Change the project name

cpp Code: Select all
 
jni/Android.mk LOCAL_MODULE := YourAppName
jni/Application.mk APP_MODULES := YourAppName
AndroidManifest.xml android:label="YourAppName" (2 places, one for the shortcut and one for the activity name) android:value="YourAppName" (library name)
build.xml <project name="YourAppName" default="help">
 


Adding Standard Library (std::)

Inside jni/Application.mk, add:
cpp Code: Select all
 
APP_STL := stlport_static
 


I realized that I'm only compiling main.cpp - what should I do?

Either you add each one manually, either you use a regular expression.

Adding manually .cpp files

Open jni/Android.mk - Add them one by one (separated with a space)
cpp Code: Select all
LOCAL_SRC_FILES := main.cpp android_tools.cpp game.cpp


Adding manually .h directories

Open jni/Android.mk - Add the directories
cpp Code: Select all
LOCAL_C_INCLUDES := ../../include ../../../bullet-2.82-r2704/src


Using a regexp for .cpp files

cpp Code: Select all
 
#must be placed at the beginning of the .mk
LOCAL_PATH := $(call my-dir)/..
 
LOCAL_SRC_FILES := $(addprefix $(LOCAL_PATH)/, $(notdir $(wildcard $(LOCAL_PATH)/*.cpp)))
Last edited by Neirdan on Mon Jun 30, 2014 4:08 pm, edited 3 times in total.
Neirdan
 
Posts: 39
Joined: Tue Aug 14, 2012 10:29 pm

Re: [Tutorial] Irrlicht on Mobile

Postby CuteAlien » Sat Apr 05, 2014 10:22 am

Two more hints.
First - do read the readme.txt in example 27 HelloWorld_Android in the Irrlicht ogl-es branch. It explains for example the folder structure.

The other is something I run into recently. When you try to add your own shared libraries on Android you will run into problems because those won't be loaded on application start.The only way I found to get them loading was from Java as described here: http://stackoverflow.com/questions/8828 ... e-activity
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby sabotage3d » Sun Aug 17, 2014 2:06 pm

Hi I am getting problems with the IOS example: ../source/Irrlicht/iOS
When I run the example it complains that these shaders are missing.
COGLES2FixedPipeline.fsh
COGLES2FixedPipeline.vsh
I added them from another revision but when I run the app the model is black it seems that the shader is not picking the texture properly.

Any ideas ?

Thanks,

Alex
sabotage3d
 
Posts: 13
Joined: Sat Aug 16, 2014 3:40 pm

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby FloatyBoaty » Fri Aug 22, 2014 12:06 am

I'm having a problem with the Android sample app.

Here is the log output:

08-21 16:39:25.303: E/AndroidRuntime(26742): FATAL EXCEPTION: main
08-21 16:39:25.303: E/AndroidRuntime(26742): Process: com.irrlicht.example, PID: 26742
08-21 16:39:25.303: E/AndroidRuntime(26742): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.irrlicht.example/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app-lib/com.irrlicht.example-1/libHelloWorldMobile.so
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.ActivityThread.access$800(ActivityThread.java:135)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.os.Handler.dispatchMessage(Handler.java:102)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.os.Looper.loop(Looper.java:136)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.ActivityThread.main(ActivityThread.java:5001)
08-21 16:39:25.303: E/AndroidRuntime(26742): at java.lang.reflect.Method.invokeNative(Native Method)
08-21 16:39:25.303: E/AndroidRuntime(26742): at java.lang.reflect.Method.invoke(Method.java:515)
08-21 16:39:25.303: E/AndroidRuntime(26742): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-21 16:39:25.303: E/AndroidRuntime(26742): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-21 16:39:25.303: E/AndroidRuntime(26742): at dalvik.system.NativeStart.main(Native Method)
08-21 16:39:25.303: E/AndroidRuntime(26742): Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/app-lib/com.irrlicht.example-1/libHelloWorldMobile.so
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.NativeActivity.onCreate(NativeActivity.java:183)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.Activity.performCreate(Activity.java:5231)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-21 16:39:25.303: E/AndroidRuntime(26742): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
08-21 16:39:25.303: E/AndroidRuntime(26742): ... 11 more

I've tried everything I could find or think of. Any help would be appreciated.

Nexus 5, Android 4.4.4
FloatyBoaty
 
Posts: 32
Joined: Thu Aug 21, 2014 11:39 pm

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby Nadro » Fri Aug 22, 2014 3:29 pm

libHelloWorldMobile.so is missing - probably some problems with NDK environment paths.
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby FloatyBoaty » Fri Aug 22, 2014 4:33 pm

Thanks for the response.

Problem: using android-ndk64-r10
Solution: use android-ndk32-r10
FloatyBoaty
 
Posts: 32
Joined: Thu Aug 21, 2014 11:39 pm

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby FloatyBoaty » Wed Sep 10, 2014 10:08 pm

stlport isn't necessary if the app uses the templates provided by Irrlicht.
FloatyBoaty
 
Posts: 32
Joined: Thu Aug 21, 2014 11:39 pm

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby FloatyBoaty » Thu Sep 11, 2014 4:34 pm

I would like to request that the OGLES1&2 drivers be added to the SDL device - for simpler cross-platform building.
FloatyBoaty
 
Posts: 32
Joined: Thu Aug 21, 2014 11:39 pm

Re: [Tutorial] Irrlicht on Android and IOS Mobile

Postby Neirdan » Sun Oct 05, 2014 6:43 pm

A bit late, I'm busy doing something else, but please keep in mind this is a tutorial thread.
There are other threads for problems encountered, thanks for your comprehension.
Neirdan
 
Posts: 39
Joined: Tue Aug 14, 2012 10:29 pm


Return to FAQs, Tutorials, Howtos, and external tool lists

Who is online

Users browsing this forum: No registered users and 1 guest