Quellcode durchsuchen

Merge pull request #804 from marcinjakubowski/next

Android asset path fix + debug mem Ref include fix for gcc + Linux multisampling support
Sean Paul Taylor vor 13 Jahren
Ursprung
Commit
47a07772af
3 geänderte Dateien mit 31 neuen und 13 gelöschten Zeilen
  1. 1 0
      gameplay/src/Base.h
  2. 25 12
      gameplay/src/PlatformAndroid.cpp
  3. 5 1
      gameplay/src/PlatformLinux.cpp

+ 1 - 0
gameplay/src/Base.h

@@ -27,6 +27,7 @@
 #include <limits>
 #include <functional>
 #include <bitset>
+#include <typeinfo>
 #include "Logger.h"
 
 // Bring common functions from C into global namespace

+ 25 - 12
gameplay/src/PlatformAndroid.cpp

@@ -974,22 +974,35 @@ int Platform::enterMessagePump()
     }
     GP_ASSERT(env);
 
-    // 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);
-    
-    const char* packageName;
+    /* Get external files directory on Android; this will result in a directory where all app files
+     * should be stored, like /mnt/sdcard/android/<package-name>/files/
+     */
     jboolean isCopy;
-    packageName = env->GetStringUTFChars((jstring)result, &isCopy);
-    jvm->DetachCurrentThread();
+
+    jclass clazz = env->GetObjectClass(activity->clazz);
+    jmethodID methodGetExternalStorage = env->GetMethodID(clazz, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;");
+
+    jclass clazzFile = env->FindClass("java/io/File");
+    jmethodID methodGetPath = env->GetMethodID(clazzFile, "getPath", "()Ljava/lang/String;");
+
+    // Now has java.io.File object pointing to directory
+    jobject objectFile  = env->CallObjectMethod(activity->clazz, methodGetExternalStorage, NULL);
     
+    // Now has String object containing path to directory
+    jstring stringExternalPath = static_cast<jstring>(env->CallObjectMethod(objectFile, methodGetPath));
+    const char* externalPath = env->GetStringUTFChars(stringExternalPath, &isCopy);
+
     // Set the default path to store the resources.
-    std::string assetsPath = "/mnt/sdcard/android/data/";
-    assetsPath += packageName;
-    assetsPath += "/";
+    std::string assetsPath(externalPath);
+    if (externalPath[strlen(externalPath)-1] != '/')
+        assetsPath += "/";
+
     FileSystem::setResourcePath(assetsPath.c_str());    
-        
+
+    // Release string data
+    env->ReleaseStringUTFChars(stringExternalPath, externalPath);
+    jvm->DetachCurrentThread();
+    
     // Get the asset manager to get the resources from the .apk file.
     __assetManager = activity->assetManager; 
     

+ 5 - 1
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;