Improving Android support

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Improving Android support

Post by Wolfmanfx » Tue May 15, 2012 12:43 am

Hi,
Right now i am improving the ogre android support most of my work is available here (except the demo) -> https://bitbucket.org/wolfmanfx/ogre

here a screenshot from my acer a200 device (tegra 2) / GLES 2.0 with active RTSS
device-2012-05-15-012458.jpg
But what i have improved until now?
The situation until now was so that the complete application was Java centric so java code was use to create the context and passed to ogre. Also many users were confused why the resources inside a apk were renamed as mp3 or why the gamekit guys extracted the content to sdcard and read from there.

1) I do not use any java code everything is written in c++ via native_activity.
2) The GLContext is now created by ogre - i reworked the android support so that it conforms ogre's EGL structure but we need to pass the android window handle to ogre to make it happen :)

Code: Select all

				Ogre::NameValuePairList opt;
				opt["externalWindowHandle"] = Ogre::StringConverter::toString((int)app->window);
				Ogre::RenderWindow* pRenderWnd = engine->pRoot->createRenderWindow("OgreWindow", 1280, 800, false, &opt);
3) OgreStringSerialiser is removed - STL is better now in the current NDK (0.8) this helped me to cleanup the RTSS and remove the ugly macros
4) Add Android log listener into OgreRoot (so we have always log output)
5) Add OgreAPKFileSystemArchive to handle file access inside the apk using android asset manager
Add OgreAPKZipArchive so we can handle zip files inside the apk (apk is also compressed using zip)
I think this useful for everybody - we can access everything inside the apk file but we have to register this two archives manually

Code: Select all

				Ogre::ArchiveManager::getSingleton().addArchiveFactory( new Ogre::APKFileSystemArchiveFactory(app->activity->assetManager) );
				Ogre::ArchiveManager::getSingleton().addArchiveFactory( new Ogre::APKZipArchiveFactory(app->activity->assetManager) );
6) Update CMake using the openCV toolchain (so we can compile all ogre libs with cmake)
But i still use eclipse to create the apk - but maybe there will the possibility to create also the apk with cmake - we will see.
0 x

User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!

Re: Improving Android support

Post by Brocan » Tue May 15, 2012 7:51 am

Really great!

And now the one million question :lol: : what are the steps which are you doing to compile it? It would be great to have a step-by-step guide to compile ogre on android.

Thanks in advance! :D
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Tue May 15, 2012 8:00 am

Thats also something i am improving right now to make it easier to compile everything with CMake - atm everything compiles with CMake except the main application (apk) for that i am using eclipse.
Anyway when the sample browser is fully functional i will make a step by step guide (maybe we should also remove the old stuff from the wiki most of it is really outdated).
Hope you are not in hurry :) - hopefully end of this week the sample browser should work.
0 x

User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!

Re: Improving Android support

Post by Brocan » Tue May 15, 2012 8:06 am

No problems, i've no hurry at all. Take the time you need :D

Thanks! :P
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Tue May 15, 2012 8:28 am

the screenshot is just a test using the ninja mesh :)
0 x

ironsteel
Gnoblar
Posts: 5
Joined: Mon Feb 20, 2012 9:27 am

Re: Improving Android support

Post by ironsteel » Tue May 15, 2012 8:58 am

Great work :). Did you upload the cmake scripts for the dependencies ?
0 x

User avatar
liberator
Greenskin
Posts: 117
Joined: Mon Jan 24, 2005 2:27 pm
Location: Sillicon Valley, California
Contact:

Re: Improving Android support

Post by liberator » Tue May 15, 2012 8:14 pm

Just saw this, this is good work.
I generate the apk's using scripts myself, I don't use Eclipse so its certainly possible to integrate it
0 x

User avatar
Thoran
Halfling
Posts: 94
Joined: Mon Dec 01, 2008 2:04 pm
Location: Germany
Contact:

Re: Improving Android support

Post by Thoran » Wed May 16, 2012 1:46 pm

Highly appreciating your efforts and really excited about the guide to build on Android.

Cheers,
Thoran
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Wed May 16, 2012 4:26 pm

So here a shot showing the sample browser on my device input is still missing
device-2012-05-16-172229_sample_browser.png
0 x

Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 533
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 11

Re: Improving Android support

Post by Slicky » Wed May 16, 2012 6:18 pm

Is it possible to have it all working inside Visual Studio or is there a compelling reason to use Eclipse?
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Wed May 16, 2012 6:22 pm

Atm its easier to finish the demo with eclipse and move on to cmake to get rid of eclipse at all - i do not know the status os vs-android
0 x

Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 533
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 11

Re: Improving Android support

Post by Slicky » Wed May 16, 2012 6:31 pm

ok I don't know enough about it yet but it will be interesting to follow along. I do have Eclipse running also.
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Wed May 16, 2012 9:48 pm

Simple input handling
[youtube]auku9PVFYy0[/youtube]
0 x

User avatar
liberator
Greenskin
Posts: 117
Joined: Mon Jan 24, 2005 2:27 pm
Location: Sillicon Valley, California
Contact:

Re: Improving Android support

Post by liberator » Wed May 16, 2012 9:56 pm

Thats really cool man!
I'd love to see the source on your native input handling.
0 x

elkree
Gnoblar
Posts: 20
Joined: Wed Apr 21, 2010 9:08 pm

Re: Improving Android support

Post by elkree » Thu May 17, 2012 7:59 am

nice work!!!

doing an android version atm is really useful, if you successfully do a full documentation i will think to use ogre again to my applications :)

thx!!!
0 x

User avatar
SomeFusion
Gremlin
Posts: 191
Joined: Sun Dec 01, 2002 12:38 am

Re: Improving Android support

Post by SomeFusion » Thu May 17, 2012 11:46 am

Very cool!

For the next ADT version there's initial C++ support coming (depends on CDT).
http://tools.android.com/download/adt-20-preview
0 x
Summoning Wars is an open source role-playing game, featuring both a single-player and a multiplayer mode for about 2 to 8 players.
http://www.sumwars.org

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Fri May 18, 2012 11:04 pm

So guys,

I removed all eclipse projects from the source tree (under Samples/Browser/Android) and added a simple android project generator based on "ndk-build" and "ant" and now the CMake build system builds and creates the apk.

these commands are almost everything you need

Code: Select all

cmake .. -DCMAKE_TOOLCHAIN_FILE="`pwd`/../CMake/toolchain/android.toolchain.cmake" -DOGRE_DEPENDENCIES_DIR="`pwd`/../AndroidDependencies" -DTargetPlatform="Android" -DOGRE_BUILD_RENDERSYSTEM_GLES2=TRUE -DOGRE_STATIC=TRUE -DANDROID_NATIVE_API_LEVEL=14 -DOGRE_BUILD_COMPONENT_PAGING=FALSE -DOGRE_BUILD_COMPONENT_TERRAIN=FALSE -DOGRE_BUILD_COMPONENT_RTSHADERSYSTEM=TRUE -DOGRE_BUILD_PLUGIN_BSP=FALSE -DOGRE_BUILD_PLUGIN_PCZ=FALSE -DOGRE_BUILD_RENDERSYSTEM_GLES=FALSE -DOGRE_BUILD_TESTS=FALSE -DOGRE_BUILD_TOOLS=FALSE
make
ant debug
abt installd
0 x

User avatar
liberator
Greenskin
Posts: 117
Joined: Mon Jan 24, 2005 2:27 pm
Location: Sillicon Valley, California
Contact:

Re: Improving Android support

Post by liberator » Fri May 18, 2012 11:09 pm

Do you have the code already checked in somewhere? I'd love to take a look and maybe try it out this weekend.
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Fri May 18, 2012 11:22 pm

The code is in the fork repo (first post) and here a link to the pre compiled deps http://www.coderabbit.at/AndroidDependencies.zip

Also note that i am working under osx and did not test it under win32.
You must define ANDROID_NDK in your path (must point to the ndk dir) and ANDROID_SDK must point to the android sdk.

But i have to write a compile guide otherwise it could suck to setup the environment ;)
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Sat May 19, 2012 1:02 am

More samples enabled
device-2012-05-19-020137.png
0 x

User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!

Re: Improving Android support

Post by Brocan » Tue May 22, 2012 12:59 pm

Any body knows how to compile it in windows? i've tryied to execute the commands from Visual Studio command prompt, but CMAKE complains about not supported options in the initial testing :(
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: Improving Android support

Post by Wolfmanfx » Tue May 22, 2012 1:01 pm

Atm i doing everything under osx - i have to test/fix stuff so that it also builds under windows
0 x

User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!

Re: Improving Android support

Post by Brocan » Tue May 22, 2012 1:06 pm

Wolfmanfx wrote:Atm i doing everything under osx - i have to test/fix stuff so that it also builds under windows
Uhm, i've solved these errors, if i achieve the compilation i will post the steps and fixes :D

Uhm, its getting stuck while looking for ZLIB. It gets stuck for a while here:

Code: Select all

D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Packages/FindZLIB.cmake(34):  set(ZLIB_LIBRARY_NAMES z zlib zdll )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Packages/FindZLIB.cmake(35):  get_debug_names(ZLIB_LIBRARY_NAMES )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Utils/FindPkgMacros.cmake(90):  foreach(i ${ZLIB_LIBRARY_NAMES} )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Utils/FindPkgMacros.cmake(91):  set(ZLIB_LIBRARY_NAMES_DBG ${ZLIB_LIBRARY_NAMES_DBG} ${i}d ${
i}D ${i}_d ${i}_D ${i}_debug ${i} )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Utils/FindPkgMacros.cmake(91):  set(ZLIB_LIBRARY_NAMES_DBG ${ZLIB_LIBRARY_NAMES_DBG} ${i}d ${
i}D ${i}_d ${i}_D ${i}_debug ${i} )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Utils/FindPkgMacros.cmake(91):  set(ZLIB_LIBRARY_NAMES_DBG ${ZLIB_LIBRARY_NAMES_DBG} ${i}d ${
i}D ${i}_d ${i}_D ${i}_debug ${i} )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Packages/FindZLIB.cmake(37):  use_pkgconfig(ZLIB_PKGC zzip-zlib-config )
D:/Proyectos/Android/WolfmanOgreAndroid/OgreWolfmanSrc/CMake/Utils/FindPkgMacros.cmake(69):  find_package(PkgConfig )
C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPkgConfig.cmake(90):  set(PKG_CONFIG_VERSION 1 )
C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPkgConfig.cmake(92):  find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC pkg-config executable )
And the vars defined in FindZLIB are empty:
-- ZLIB_HOME ==
-- ENV_ZLIB_HOME ==
-- ZLIB_LIBRARY_NAMES == z;zlib;zdll
-- ZLIB_LIBRARY_NAMES_DBG == zd;zD;z_d;z_D;z_debug;z;zlibd;zlibD;zlib_d;zlib_D;zlib_debug;zlib;zdlld;zdllD;zdll_d;zdll_D;zdll_debug;zdll
-- ZLIB_INC_SEARCH_PATH ==
-- ZLIB_LIB_SEARCH_PATH ==
-- ZLIB_PKGC_INCLUDE_DIRS ==
0 x

Liu Xinya
Gnoblar
Posts: 8
Joined: Wed May 23, 2012 6:09 am

Re: Improving Android support

Post by Liu Xinya » Wed May 23, 2012 6:28 am

Hi Wolfmanfx,
:)
I'm programming on the platform of Android. I just to know this engine.But this make me excited,it is so great. :D Because the job needs, I need to transfer the PC game(environment is VS) to Mobile game (what I do is android) .So,I want to know how to build project on Android. I just build the OGRE's environment. I don't know how to use CMake to build the project. And what resources are I need? :( I 'm so distressed about this. Please help me.Thank you.
0 x

User avatar
Thoran
Halfling
Posts: 94
Joined: Mon Dec 01, 2008 2:04 pm
Location: Germany
Contact:

Re: Improving Android support

Post by Thoran » Wed May 23, 2012 9:36 am

Wolfmanfx wrote:The code is in the fork repo (first post) and here a link to the pre compiled deps http://www.coderabbit.at/AndroidDependencies.zip
Alone the precompiled dependencies are a big help. Thanks for that.
0 x

Locked