Relative path in Android resources (Ogre 1.11)

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Relative path in Android resources (Ogre 1.11)

Post by Darthigor »

Hi,

I'm trying to port my old Pig Shooter 3D game (written with Ogre 1.9RC) to some newer versions, to rerelease it into Android Play Store (as it was removed due to old LibPNG issues). I had some issues with compiling latest Ogre (1.12), so I'm using 1.11.5 right now. It was compiled successfully and works, and I've ported my old code with minimal changes to the new Ogre, and it also works, but there are issues with resource loading:

I have a complex folder with textures, something like this:
* Textures - some basic textures, like "logo.png"
* Textures/buttons - button control textures, like "config_button.png"
* Textures/windows - window control textures
and so on

previously I've loaded them like this:
1) resources.cfg:
[General]
APKFileSystem=/Textures
...
2) Some code to load it, like this:
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
where arch, type and sec are something like "/Textures", "APKFileSystem", "General" for this case

3) Later, I'm trying to use those textures, for instance like this:
material->getTechnique(0)->getPass(0)->createTextureUnitState("logo.png");
...
material->getTechnique(0)->getPass(0)->createTextureUnitState("buttons/config_button.png");

It worked in older Ogre (1.9, 1.10), but for some reason it stopped in 1.11.5 (or maybe earlier, I haven't tried other versions). "logo.png", which is in root Textures folder is still loading correctly and works, but images from subfolders (like "config_button.png") are not, throwing exception "FileNotFoundException: cannot locate resource".
Were there some changes to the resource loading procedures? I could try recursive loading, but those relative paths were very convenient, maybe I'm missing something to make them work again?
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Relative path in Android resources (Ogre 1.11)

Post by paroj »

set OGRE_RESOURCEMANAGER_STRICT=0
see https://github.com/OGRECave/ogre/blob/m ... trict-mode

basically it should always have been createTextureUnitState("config_button.png", "buttons");
createTextureUnitState("buttons/config_button.png") breaks indexing and results in filesystem based search.
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Re: Relative path in Android resources (Ogre 1.11)

Post by Darthigor »

Hi paroj.

Thanks, it helped.
Everything seems to work now on my devices, but when I upload app to Google Play, it fails to load on several test devices, mostly with the error
Crash java.lang.RuntimeException: Unable to start activity ComponentInfo{com.turbulent.pigshooter3d/com.turbulent.pigshooter3d.PigShooter3DActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app-lib/com.turbulent.pigshooter3d-1/libPigShooter3D.so

Not sure currently why is this happening, maybe someone had similar issues? I've attached a logcat from one of those devices, they mostly have Android version less then 7, maybe I should rise minSDKVersion (though previously it worked fine on old Androids)

Also it seems several more modern devices crash on this method:
/vendor/lib64/egl/libGLESv2_adreno.so (EsxTextureObject::GenerateMipmapArray(EsxContext*, EsxSamplerObject const*)+952)
though other ones seem to work fine (including my old adreno based Xiaomi Redmi 8A)
Attachments
logcat (2).txt.zip
(164.93 KiB) Downloaded 185 times
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Relative path in Android resources (Ogre 1.11)

Post by paroj »

do these devices support arm64?
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Re: Relative path in Android resources (Ogre 1.11)

Post by Darthigor »

I'm not sure, I guess they don't, but I've built Ogre and app for both arm64 and armeabi-v7, apk includes native libs for both . Maybe I should have split apk files, i'll try
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Re: Relative path in Android resources (Ogre 1.11)

Post by Darthigor »

Ok, I've managed to fix all the issues except this strange GenerateMipmapArray issue, which is still happening even on modern devices like Galaxy S9 or Pixel 3.
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Relative path in Android resources (Ogre 1.11)

Post by paroj »

you might work through this list:
https://github.com/OGRECave/ogre/issues/433

especially #6 sounds familiar
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Re: Relative path in Android resources (Ogre 1.11)

Post by Darthigor »

Yea, #6 looks familiar, I'll check if those changes affect the crash.
I've actually managed to track this call to generate mipmaps (that causes crash). It's happening during Ogre::Font::load method.
And I've tried removing font usage completely, and after that game is loading without a crash, with all other textures and models working correctly (though no text in overlays of course).
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Relative path in Android resources (Ogre 1.11)

Post by paroj »

if its just the font texture, it would be easier for you to implement this https://github.com/OGRECave/ogre/issues/1218
and store a the font atlas as dds with pre-generated mip-maps.

Alternatively you could try disabling mipmapping for fonts altogether and adapt the font resolution to roughly match the DPI instead.
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Re: Relative path in Android resources (Ogre 1.11)

Post by Darthigor »

Ok, I've made a quick fix, by just disabling mipmapping for fonts, maybe I'll refactor it later to use a dds texture. Also, it appears that not only font texture crashed mipmapping, but also some dummy 1x1 texture in game resources, so I've changed it to a bigger size (probably need to refactor it too later).
After that most of the google play test devices seem to work fine.
One test device, old Samsung S3 is still crashing, on SwapBuffers. I'm still investigating it, it seems similar to issue described here (though I'm not 100% sure): viewtopic.php?t=93692
But it seems it's a rare issue, and it is actually reproducible on my old game builds on Ogre 1.9, so I've decided to finally rerelease the game:
https://play.google.com/store/apps/deta ... gshooter3d
Thank you for all the help!
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
Post Reply