Native Android port

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.

Re: Native Android port

Postby mchiasson » Mon Apr 08, 2013 1:22 am

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: viewtopic.php?f=2&t=48080&p=277056#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 :-)
User avatar
mchiasson
 
Posts: 12
Joined: Wed Feb 01, 2012 12:29 pm
Location: Ottawa, Ontario, Canada

Re: Native Android port

Postby mchiasson » Mon Apr 08, 2013 1:50 am

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

cpp 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:
User avatar
mchiasson
 
Posts: 12
Joined: Wed Feb 01, 2012 12:29 pm
Location: Ottawa, Ontario, Canada

Re: Native Android port

Postby hendu » Mon Apr 08, 2013 10:10 am

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.
hendu
 
Posts: 2587
Joined: Sat Dec 18, 2010 12:53 pm

Re: Native Android port

Postby hybrid » Mon Apr 08, 2013 11:36 am

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)
hybrid
Admin
 
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: Native Android port

Postby mchiasson » Mon Apr 08, 2013 1:36 pm

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.
User avatar
mchiasson
 
Posts: 12
Joined: Wed Feb 01, 2012 12:29 pm
Location: Ottawa, Ontario, Canada

Re: Native Android port

Postby Nadro » Tue Apr 16, 2013 9:27 pm

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).
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby id3210 » Wed Apr 17, 2013 12:23 pm

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

cant find it...
id3210
 
Posts: 1
Joined: Wed Apr 17, 2013 12:08 pm

Re: Native Android port

Postby darren » Tue Apr 30, 2013 6:19 am

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.
darren
 
Posts: 1
Joined: Tue Apr 30, 2013 2:54 am

Re: Native Android port

Postby Nadro » Tue Apr 30, 2013 8:49 am

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.
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby Nadro » Sat May 18, 2013 6:36 pm

Android example is ready to use (tested with Sony Xperia Sola). You can find an short tutorial in commit log.
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby Darktib » Tue May 21, 2013 4:43 pm

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()
cpp 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:

cpp Code: Select all
 
        long Size = FPVSFile->getSize(); /// BOOM, segfault if file failed to load
 
        if (Size) // ...
 


should be changed to:

cpp 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.
User avatar
Darktib
 
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Re: Native Android port

Postby Nadro » Tue May 21, 2013 5:20 pm

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).
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby Darktib » Tue May 21, 2013 6:18 pm

Ok, good to know!
User avatar
Darktib
 
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Re: Native Android port

Postby Nadro » Tue May 21, 2013 9:29 pm

Anyway if you will find some Android bugs please report it. This port is in alpha stage, so reports will be useful.
Nadro
 
Posts: 1647
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Native Android port

Postby Darktib » Sat May 25, 2013 7:50 pm

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:
cpp Code: Select all
 
- assets
    - data
        - player
            - player.b3d
            - player.bmp
    - media
        - Shaders
            - ...
 

Irrlicht logs (approx):
cpp 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 ?
User avatar
Darktib
 
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

PreviousNext

Return to Open Discussion and Dev Announcements

Who is online

Users browsing this forum: No registered users and 1 guest