Reputation: 213
I can't seem to find a simple, concise answer to this question.
I'm porting one of my games to Android. This is my very first attempt at doing this, and the system is foreign enough to diminish my capacity to react to a new system.
I have maintained a cross platform codebase that looks something like this:
Windows_Core/
Mac_Core/
iOS_Core/
Linux_Core/
Android_Core/
Game_Code/
The game itself resides in Game_Code, and each project for each system either sets an include path to the system's own "core" code, or in the case of XCode, simply adds the core code to the project.
How do I mimic this in Android Studio 2.2 with Gradle? Anything I try to add to the gradle scripts either gets ignored or causes an actual error.
If I generate a new NDK project with Gradle, what the HECK do I do to add my existing Game_Code/*.cpp/h to make them a part of the project, and set up a proper include path so that code like
#include "graphics_core.h"
will pull from Android_Core/ ?
Upvotes: 0
Views: 193
Reputation: 2380
Use CMakelists to include and build your code into a shared library. https://developer.android.com/studio/projects/add-native-code.html
Specifically, use CMakeLists in your GameCode/ and Android_Core/ directories, and a CMakeList in your root that calls 'add_subdirectory' for those two dirs.
That's the easy part. Really, what you want is a native_activity example that draws to the screen using OpenGL ES 2+ : https://github.com/googlesamples/android-ndk/tree/master/hello-gl2
I would even go as far as recommending using the nVidia tools: https://github.com/PolygonTek/BlueshiftEngine/tree/master/Engine/Source/Dependencies/nvidia , escpecially the nv_file and nv_egl utilities.
Upvotes: 1