Native Android port

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
mchiasson
Posts: 12
Joined: Wed Feb 01, 2012 12:29 pm
Location: Ottawa, Ontario, Canada

Re: Native Android port

Post by mchiasson »

mazataza, the reason why it crashes if you leave the AndroidAssetFileArchive there is simply because it wasn't done in the correct location.

see my post here: http://irrlicht.sourceforge.net/forum/v ... 56#p277040

All you have to do is move the crashing code block before createDriver(). That's it.

I made a patch for Nadro, but I think he has forgotten about it :-)
mchiasson
Posts: 12
Joined: Wed Feb 01, 2012 12:29 pm
Location: Ottawa, Ontario, Canada

Re: Native Android port

Post by mchiasson »

Looks like I fixed the compile error by simply adding the following function CIrrDeviceAndroid.cpp/h

Code: Select all

 
core::position2di CIrrDeviceAndroid::getWindowPosition()
{
    return core::position2di(-1, -1);
}
 
I don't think we need this function on Android. There are no 'windows'. I ran it and it seems to work in OpenGL ES 1. I haven't tried OpenGL ES 2 because I cannot find my shaders. :lol:
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Native Android port

Post by hendu »

I thought they were adding windows to the tablet interface in recent Android versions? Seems such a waste to have a 12" screen that only displays one app.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Native Android port

Post by hybrid »

mchiasson wrote:I made a patch for Nadro, but I think he has forgotten about it :-)
We are in a major rework of the ogl-es2 driver. After that, the iPhone and Android devices will be updated. So might take a little longer. Maybe better put the patches to our tracker if you haven't done so. This will ensure they are not lost somehow (http://sourceforge.net/tracker/?group_i ... tid=540678)
mchiasson
Posts: 12
Joined: Wed Feb 01, 2012 12:29 pm
Location: Ottawa, Ontario, Canada

Re: Native Android port

Post by mchiasson »

I don't care that much for the patch. If it helps others to get by, then I am happy. If you guys need it to fix the segfault in Android with the Ogles2 driver, then that's solved for you. If you guys want to do a complete rewrite, then that's fine too.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Post by Nadro »

I'm sorry that it took so long. Tomorrow when I'll back from my work I'll apply patches for Android (+patch from Hiker).
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
id3210
Posts: 1
Joined: Wed Apr 17, 2013 12:08 pm

Re: Native Android port

Post by id3210 »

Hi all,
can you point me to android native app(sample), that use irrlicht?

cant find it...
darren
Posts: 1
Joined: Tue Apr 30, 2013 2:54 am

Re: Native Android port

Post by darren »

mazataza, thank you for your post. It is tremendously helpful. I was able to piece together enough from your code snippets and other forums to get irrlicht "running" on the emulator but I only have it to the black screen you mentioned. Are you willing to post your code for us?

I'm currently building for OpenGL ES 1.0? After working on this for the last week, I would be so happy to see a box like you got even if it is @ 7 FPS.

Thanks again.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Post by Nadro »

Did you try example no. 10 from ogl-es branch? It works under Android. Anyway android.mk is missing, so you have to add this file. Currently I'm working on official example for both iOS and Android, but I need some more time to finish it. Please be patient, it'll be available soon, many users request it, so at now it's my priority in tasks related to Irrlicht.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Post by Nadro »

Android example is ready to use (tested with Sony Xperia Sola). You can find an short tutorial in commit log.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Re: Native Android port

Post by Darktib »

Hello,

I think I found a bug in the driver, which causes a crash at app startup (I was wondering why the example HelloWorldMobile was working without problems and my app crashed, and digged into the source code).

AFAIK, createAndOpenFile(...) returns 0 if the file failed to load. In this function, it is assumed the file is loaded successfully...

File: COGLES2Driver.cpp
In function: createMaterialRenderers()

Code: Select all

 
        // Those 2 files can fail to load (for example, there is no "asset/media/Shaders/*.*" files)
        // In this case, 0 is returned
        io::IReadFile* FPVSFile = FileSystem->createAndOpenFile(FPVSPath);
        io::IReadFile* FPFSFile = FileSystem->createAndOpenFile(FPFSPath);
 
        c8* FPVSData = 0;
        c8* FPFSData = 0;
 
        long Size = FPVSFile->getSize(); /// BOOM, segfault if file failed to load
 
        if (Size)
        {
            FPVSData = new c8[Size+1];
            FPVSFile->read(FPVSData, Size);
            FPVSData[Size] = 0;
        }
 
        Size = FPFSFile->getSize(); /// BOOM again, if the other file was not loaded
 
        if (Size)
        {
            // if both handles are the same we must reset the file
            if (FPFSFile == FPVSFile)
                FPFSFile->seek(0);
 
            FPFSData = new c8[Size+1];
            FPFSFile->read(FPFSData, Size);
            FPFSData[Size] = 0;
        }
 
        if (FPVSFile)
            FPVSFile->drop();
        if (FPFSFile)
            FPFSFile->drop();
 
The function is rather large, and such code is repeated throughout it. I think these lines:

Code: Select all

 
        long Size = FPVSFile->getSize(); /// BOOM, segfault if file failed to load
 
        if (Size) // ...
 
should be changed to:

Code: Select all

 
        long Size = (FPVSFile != 0 ? FPVSFile->getSize() : 0);
 
        if (Size) // ...
 
Also, if a file fails to load, maybe the engine can output a debug log string for it. And if Irrlicht cannot work without those shaders, either they should be included in the source or a big red notice should be put in the doc (I prefer the first one ;) )

Apart from that , the driver seems to work well.

PS: I can make a patch if you want, but that will have to wait until the end of the week.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Post by Nadro »

In final release all shaders from media/Shaders will be included in Irrlicht code. Current solution is just temporary for easier shaders developing process. Any patches aren't required in this case, because this code will be removed soon (without shaders OGl ES2.0 doesn't work, so simple 'if(File)' doesn't help too much).
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Re: Native Android port

Post by Darktib »

Ok, good to know!
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Post by Nadro »

Anyway if you will find some Android bugs please report it. This port is in alpha stage, so reports will be useful.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Re: Native Android port

Post by Darktib »

Hi again,

I have a little problem with textures; I load a b3d model which have a texture; when executing the pc version, everything is loaded fine, but on Android (with OGLES2) the texture is not loaded (while mesh + animations are perfectly loaded). The only difference between the android and the pc version is the main function (for android it's android_main, for pc it is main).
My "assets" directory is looking like:

Code: Select all

 
- assets
    - data
        - player
            - player.b3d
            - player.bmp
    - media
        - Shaders
            - ...
 
Irrlicht logs (approx):

Code: Select all

 
Using texture: player.bmp
[...]
Could not open file of texture: player.bmp
 
After looking in the sources, the b3d loader checks for "<b3d-path>/<texture>", but here the <b3d-path> is made absolute by getMesh(). I think that may be the problem on Android, since the files are in the apk... Do you have ideas / workaround for this ?
Post Reply