# HG changeset patch # User Wuzzy # Date 1448394673 0 # Node ID cc2971fe7264437d8d0bd00444e23e395092f779 # Parent ce0819a5ec57faf0ca8dfdfc647d48586bd232bc Copy-editing diff -r ce0819a5ec57 -r cc2971fe7264 Hedgeroid_explained.wiki --- a/Hedgeroid_explained.wiki Tue Nov 24 19:37:29 2015 +0000 +++ b/Hedgeroid_explained.wiki Tue Nov 24 19:51:13 2015 +0000 @@ -4,8 +4,9 @@ ==The normal way== -The 'normal' way of writing applications in Android is by using the Java language which runs in the Dalivk Virtual Machine. However there's an API which goes under the name of Java Native Interface(JNI), this basically gives a method of calling exported function from a library compile to native code, this C/C++/FreePascal -Originally JNI in Android was meant to be used for performance critical operation like calculating psysics, because the overhead to make a call to some native code is very expensive and unless using native code really gives a huge benefit it isn't worth it. All of this is usable for developers using the 'Native Development Kit' (NDK) In newer versions of Android more functionality has been added to the NDK such as opengl 1.x/2.0 and with Gingerbread you can use almost all Android APIs. However there are a few reasons why I can not use this functionality. +The “normal” way of writing applications in Android is by using the Java language which runs in the Dalivk Virtual Machine. However there's an API which goes under the name of Java Native Interface (JNI), this basically gives a method of calling exported function from a library compile to native code, this C/C++/FreePascal. + +Originally JNI in Android was meant to be used for performance critical operation like calculating psysics, because the overhead to make a call to some native code is very expensive and unless using native code really gives a huge benefit it isn't worth it. All of this is usable for developers using the Native Development Kit (NDK) In newer versions of Android more functionality has been added to the NDK such as OpenGL 1.x/2.0 and with Gingerbread you can use almost all Android APIs. However there are a few reasons why I can not use this functionality. ==Problems with the NDK== @@ -13,31 +14,29 @@ So we're stuck to using the older NDK, which is just fine as shown later on we can forward Java specific functionalities forward to the native side manually, how ever the NDK only supports C and C++ but the Hedgewars engine is written in FreePascal. Which comes down to the following: -Where with C/C++ you write your code, run 'ndk-build' and after a few moments a working Android app pops out freepascal needed some more work. We need a crosscompiler, some utilities which link various, and figure out what libraries we can or cannot use. +Where with C/C++ you write your code, run `ndk-build` and after a few moments a working Android app pops out FreePascal needed some more work. We need a crosscompiler, some utilities which link various, and figure out what libraries we can or cannot use. ==So what did we end up with?== -We ended up with a fairly simple way of compiling the engine but we cannot use pthreads, because we rely on SDL we can use SDL Threads which helps.. A working LUA Library no problems there +We ended up with a fairly simple way of compiling the engine but we cannot use pthreads, because we rely on SDL we can use SDL Threads which helps. A working Lua library, no problems there. -We also got an Official SDL port, however this one is still pretty rough, it hasn't been completed just yet however sound/visuals are working, which is the important bit. Altough one part of SDL wasn't ported yet, pelya the auther of the unofficial port has provided it for us, yey for him! +We also got an Official SDL port, however this one is still pretty rough, it hasn't been completed just yet however sound/visuals are working, which is the important bit. Altough one part of SDL wasn't ported yet, pelya the author of the unofficial port has provided it for us, yay for him! All in all everything seems to work oke right now. -This picture tries to describe how information flows through the three levels (Android, C/C++ wrapper, hedgewars engine) +This picture tries to describe how information flows through the three levels (Android, C/C++ wrapper, hedgewars engine): http://www.xelification.com/tmp/hedgewarsflow.png ==Short list on what gets handled where== -Android + * Android * Opengl context creation * Touch/key events generation * Audio playback * Front end - -SDL + * SDL * Touch/key events normalisation * Wrapper for audio playback - -Hedgewars Engine + * Hedgewars engine * Touch/key events converted to hedgewars actions \ No newline at end of file