Page 3 of 5
Re: Native Android port
Posted: Mon Apr 08, 2013 1:22 am
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

Re: Native Android port
Posted: Mon Apr 08, 2013 1:50 am
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.

Re: Native Android port
Posted: Mon Apr 08, 2013 10:10 am
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.
Re: Native Android port
Posted: Mon Apr 08, 2013 11:36 am
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)
Re: Native Android port
Posted: Mon Apr 08, 2013 1:36 pm
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.
Re: Native Android port
Posted: Tue Apr 16, 2013 9:27 pm
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).
Re: Native Android port
Posted: Wed Apr 17, 2013 12:23 pm
by id3210
Hi all,
can you point me to android native app(sample), that use irrlicht?
cant find it...
Re: Native Android port
Posted: Tue Apr 30, 2013 6:19 am
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.
Re: Native Android port
Posted: Tue Apr 30, 2013 8:49 am
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.
Re: Native Android port
Posted: Sat May 18, 2013 6:36 pm
by Nadro
Android example is ready to use (tested with Sony Xperia Sola). You can find an short tutorial in commit log.
Re: Native Android port
Posted: Tue May 21, 2013 4:43 pm
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.
Re: Native Android port
Posted: Tue May 21, 2013 5:20 pm
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).
Re: Native Android port
Posted: Tue May 21, 2013 6:18 pm
by Darktib
Ok, good to know!
Re: Native Android port
Posted: Tue May 21, 2013 9:29 pm
by Nadro
Anyway if you will find some Android bugs please report it. This port is in alpha stage, so reports will be useful.
Re: Native Android port
Posted: Sat May 25, 2013 7:50 pm
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 ?