From 5d4f7f16c41b43b18fcbca19466c3a86177f4e9f Mon Sep 17 00:00:00 2001 From: Marcin Jakubowski Date: Fri, 16 Nov 2012 13:34:31 +0100 Subject: [PATCH 1/4] Fixed Android bug with hardcoded asset path --- gameplay/src/PlatformAndroid.cpp | 33 +++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/gameplay/src/PlatformAndroid.cpp b/gameplay/src/PlatformAndroid.cpp index 0f63dcd65d..5af8feed5d 100644 --- a/gameplay/src/PlatformAndroid.cpp +++ b/gameplay/src/PlatformAndroid.cpp @@ -935,19 +935,38 @@ int Platform::enterMessagePump() // Get the package name for this app from Java. jclass clazz = env->GetObjectClass(activity->clazz); jmethodID methodID = env->GetMethodID(clazz, "getPackageName", "()Ljava/lang/String;"); - jobject result = env->CallObjectMethod(activity->clazz, methodID); - + jstring stringPackageName = static_cast(env->CallObjectMethod(activity->clazz, methodID)); + const char* packageName; jboolean isCopy; - packageName = env->GetStringUTFChars((jstring)result, &isCopy); - jvm->DetachCurrentThread(); - + packageName = env->GetStringUTFChars(stringPackageName, &isCopy); + + jmethodID methodGetExternalStorage = env->GetMethodID(clazz, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); + jclass clazzFile = env->FindClass("java/io/File"); + jmethoID methodGetPath = env->getMethodID(clazzFile, "getPath", "()Ljava/lang/String;"); + + // Now has java.io.File object pointing to directory + jobject objectFile = env->CallobjectMethod(activity->clazz, methodGetExternalStorage); + + // Now has String object containing path to directory + jstring stringExternalPath = static_cast(env->CallObjectMethod(objectFile, methodGetPath)); + + const char* externalPath = env->GetStringUTFChars(externalPath, &isCopy); + // Set the default path to store the resources. - std::string assetsPath = "/mnt/sdcard/android/data/"; + std::string assetsPath = externalPath; + if (externalPath[strlen(externalPath)-1] != '/') + assetsPath += "/"; + assetsPath += packageName; assetsPath += "/"; FileSystem::setResourcePath(assetsPath.c_str()); - + + // Release string data + env->ReleaseStringUTFChars(stringExternalPath, externalPath); + env->ReleaseStringUTFChars(stringPackageName, packageName); + jvm->DetachCurrentThread(); + // Get the asset manager to get the resources from the .apk file. __assetManager = activity->assetManager; From bdc4fa3e4e5f6a8839c27e2945fca4f959c86a4e Mon Sep 17 00:00:00 2001 From: Marcin Jakubowski Date: Fri, 25 Jan 2013 00:25:50 +0100 Subject: [PATCH 2/4] Fixes compile error with DebugMem on Linux --- gameplay/src/Ref.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gameplay/src/Ref.cpp b/gameplay/src/Ref.cpp index efccf3522e..a877b80217 100644 --- a/gameplay/src/Ref.cpp +++ b/gameplay/src/Ref.cpp @@ -1,3 +1,5 @@ +#include + #include "Base.h" #include "Ref.h" #include "Game.h" From f2037a2f4d90f6550a5628b61aa2721a376975d7 Mon Sep 17 00:00:00 2001 From: Marcin Jakubowski Date: Fri, 25 Jan 2013 01:36:54 +0100 Subject: [PATCH 3/4] Added multisampling support on Linux --- gameplay/src/PlatformLinux.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gameplay/src/PlatformLinux.cpp b/gameplay/src/PlatformLinux.cpp index c0cf9dba5e..30f61979e4 100644 --- a/gameplay/src/PlatformLinux.cpp +++ b/gameplay/src/PlatformLinux.cpp @@ -513,7 +513,7 @@ Platform* Platform::create(Game* game, void* attachToWindow) // Get the window configuration values const char *title = NULL; - int __x = 0, __y = 0, __width = 1280, __height = 800; + int __x = 0, __y = 0, __width = 1280, __height = 800, __samples = 0; bool fullscreen = false; if (game->getConfig()) { @@ -528,6 +528,7 @@ Platform* Platform::create(Game* game, void* attachToWindow) int y = config->getInt("y"); int width = config->getInt("width"); int height = config->getInt("height"); + int samples = config->getInt("samples"); fullscreen = config->getBool("fullscreen"); if (fullscreen && width == 0 && height == 0) @@ -541,6 +542,7 @@ Platform* Platform::create(Game* game, void* attachToWindow) if (y != 0) __y = y; if (width != 0) __width = width; if (height != 0) __height = height; + if (samples != 0) __samples = samples; } } @@ -578,6 +580,8 @@ Platform* Platform::create(Game* game, void* attachToWindow) GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_DOUBLEBUFFER, True, + GLX_SAMPLE_BUFFERS, __samples > 0 ? 1 : 0, + GLX_SAMPLES, __samples, 0 }; GLXFBConfig* configs; From 73dc8cc17b49ae75d0c9c637e712c9c365b3100d Mon Sep 17 00:00:00 2001 From: Marcin Jakubowski Date: Fri, 25 Jan 2013 20:15:06 +0100 Subject: [PATCH 4/4] Moved #include to Base.h --- gameplay/src/Base.h | 1 + gameplay/src/Ref.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gameplay/src/Base.h b/gameplay/src/Base.h index 3b57971e64..26655df38c 100644 --- a/gameplay/src/Base.h +++ b/gameplay/src/Base.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "Logger.h" // Bring common functions from C into global namespace diff --git a/gameplay/src/Ref.cpp b/gameplay/src/Ref.cpp index a877b80217..efccf3522e 100644 --- a/gameplay/src/Ref.cpp +++ b/gameplay/src/Ref.cpp @@ -1,5 +1,3 @@ -#include - #include "Base.h" #include "Ref.h" #include "Game.h"