Page 1 of 6

Improving Android support

Posted: Tue May 15, 2012 12:43 am
by Wolfmanfx
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.

Re: Improving Android support

Posted: Tue May 15, 2012 7:51 am
by Brocan
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

Re: Improving Android support

Posted: Tue May 15, 2012 8:00 am
by Wolfmanfx
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.

Re: Improving Android support

Posted: Tue May 15, 2012 8:06 am
by Brocan
No problems, i've no hurry at all. Take the time you need :D

Thanks! :P

Re: Improving Android support

Posted: Tue May 15, 2012 8:28 am
by Wolfmanfx
the screenshot is just a test using the ninja mesh :)

Re: Improving Android support

Posted: Tue May 15, 2012 8:58 am
by ironsteel
Great work :). Did you upload the cmake scripts for the dependencies ?

Re: Improving Android support

Posted: Tue May 15, 2012 8:14 pm
by liberator
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

Re: Improving Android support

Posted: Wed May 16, 2012 1:46 pm
by Thoran
Highly appreciating your efforts and really excited about the guide to build on Android.

Cheers,
Thoran

Re: Improving Android support

Posted: Wed May 16, 2012 4:26 pm
by Wolfmanfx
So here a shot showing the sample browser on my device input is still missing
device-2012-05-16-172229_sample_browser.png

Re: Improving Android support

Posted: Wed May 16, 2012 6:18 pm
by Slicky
Is it possible to have it all working inside Visual Studio or is there a compelling reason to use Eclipse?

Re: Improving Android support

Posted: Wed May 16, 2012 6:22 pm
by Wolfmanfx
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

Re: Improving Android support

Posted: Wed May 16, 2012 6:31 pm
by Slicky
ok I don't know enough about it yet but it will be interesting to follow along. I do have Eclipse running also.

Re: Improving Android support

Posted: Wed May 16, 2012 9:48 pm
by Wolfmanfx
Simple input handling
[youtube]auku9PVFYy0[/youtube]

Re: Improving Android support

Posted: Wed May 16, 2012 9:56 pm
by liberator
Thats really cool man!
I'd love to see the source on your native input handling.

Re: Improving Android support

Posted: Thu May 17, 2012 7:59 am
by elkree
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!!!

Re: Improving Android support

Posted: Thu May 17, 2012 11:46 am
by SomeFusion
Very cool!

For the next ADT version there's initial C++ support coming (depends on CDT).
http://tools.android.com/download/adt-20-preview

Re: Improving Android support

Posted: Fri May 18, 2012 11:04 pm
by Wolfmanfx
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

Re: Improving Android support

Posted: Fri May 18, 2012 11:09 pm
by liberator
Do you have the code already checked in somewhere? I'd love to take a look and maybe try it out this weekend.

Re: Improving Android support

Posted: Fri May 18, 2012 11:22 pm
by Wolfmanfx
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 ;)

Re: Improving Android support

Posted: Sat May 19, 2012 1:02 am
by Wolfmanfx
More samples enabled
device-2012-05-19-020137.png

Re: Improving Android support

Posted: Tue May 22, 2012 12:59 pm
by Brocan
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 :(

Re: Improving Android support

Posted: Tue May 22, 2012 1:01 pm
by Wolfmanfx
Atm i doing everything under osx - i have to test/fix stuff so that it also builds under windows

Re: Improving Android support

Posted: Tue May 22, 2012 1:06 pm
by Brocan
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 ==

Re: Improving Android support

Posted: Wed May 23, 2012 6:28 am
by Liu Xinya
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.

Re: Improving Android support

Posted: Wed May 23, 2012 9:36 am
by Thoran
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.