summaryrefslogtreecommitdiffstats
path: root/unityplugin
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2017-11-17 03:49:58 +0000
committerEgor Yusov <egor.yusov@gmail.com>2017-11-17 03:49:58 +0000
commit26af70588daca8ca16159a49fcd795bafb1cee7d (patch)
treecdae3700a42e6146df2640f574660f6fd1f89acc /unityplugin
parentUpdated submodule (diff)
downloadDiligentEngine-26af70588daca8ca16159a49fcd795bafb1cee7d.tar.gz
DiligentEngine-26af70588daca8ca16159a49fcd795bafb1cee7d.zip
Fixed Android build
Diffstat (limited to 'unityplugin')
-rw-r--r--unityplugin/GhostCubeScene/build/Win32/AndroidManifest.xml6
-rw-r--r--unityplugin/GhostCubeScene/build/Win32/GhostCubeScene.vcxproj3
-rw-r--r--unityplugin/GhostCubeScene/build/Win32/android_build.bat13
-rw-r--r--unityplugin/GhostCubeScene/build/Win32/build.xml6
-rw-r--r--unityplugin/GhostCubeScene/build/Win32/jni/Android.mk9
-rw-r--r--unityplugin/GhostCubeScene/build/Win32/run.bat9
-rw-r--r--unityplugin/GhostCubeScene/src/Android/AndroidMain.cpp1
-rw-r--r--unityplugin/UnityEmulator/build/Win32/jni/Android.mk3
-rw-r--r--unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorApplication.java2
-rw-r--r--unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorNativeActivity.java2
-rw-r--r--unityplugin/UnityEmulator/src/Android/Java/helper/NDKHelper.java286
-rw-r--r--unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h2
-rw-r--r--unityplugin/build/Win32/UnityPlugin.sln11
13 files changed, 271 insertions, 82 deletions
diff --git a/unityplugin/GhostCubeScene/build/Win32/AndroidManifest.xml b/unityplugin/GhostCubeScene/build/Win32/AndroidManifest.xml
index e6a7d0f..f5f99f3 100644
--- a/unityplugin/GhostCubeScene/build/Win32/AndroidManifest.xml
+++ b/unityplugin/GhostCubeScene/build/Win32/AndroidManifest.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.DiligentGrpahics.UnityEmulator" android:versionCode="1" android:versionName="1.0">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.DiligentGraphics.UnityEmulator" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
<uses-feature android:glEsVersion="0x00030000" android:required="true">
</uses-feature>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
</uses-permission>
- <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" android:hasCode="true" android:name="com.DiligentGrpahics.UnityEmulator.UnityEmulatorApplication" android:debuggable="true">
+ <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" android:hasCode="true" android:name="com.DiligentGraphics.UnityEmulator.UnityEmulatorApplication" android:debuggable="true">
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
- <activity android:name="com.DiligentGrpahics.UnityEmulator.UnityEmulatorNativeActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
+ <activity android:name="com.DiligentGraphics.UnityEmulator.UnityEmulatorNativeActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name" android:value="GhostCubeSceneEmulator" />
<intent-filter>
diff --git a/unityplugin/GhostCubeScene/build/Win32/GhostCubeScene.vcxproj b/unityplugin/GhostCubeScene/build/Win32/GhostCubeScene.vcxproj
index 68dc552..aa7ad7d 100644
--- a/unityplugin/GhostCubeScene/build/Win32/GhostCubeScene.vcxproj
+++ b/unityplugin/GhostCubeScene/build/Win32/GhostCubeScene.vcxproj
@@ -228,6 +228,9 @@ copy "%(RelativeDir)%(Filename).pdb" "$(TargetDir)"</Command>
<ProjectReference Include="..\..\..\..\diligentcore\Common\build\Win32\Common.vcxproj">
<Project>{7380f7e6-315f-4b4e-92eb-e6aeee865298}</Project>
</ProjectReference>
+ <ProjectReference Include="..\..\..\..\diligentcore\External\Android\ndk_helper\build\NdkHelper.vcxproj">
+ <Project>{22ba09ae-e0b5-49f1-8403-2a824762376e}</Project>
+ </ProjectReference>
<ProjectReference Include="..\..\..\..\diligentcore\External\glew\build\Win32\glew_static.vcxproj">
<Project>{664e6f0d-6784-4760-9565-d54f8eb1edf4}</Project>
</ProjectReference>
diff --git a/unityplugin/GhostCubeScene/build/Win32/android_build.bat b/unityplugin/GhostCubeScene/build/Win32/android_build.bat
new file mode 100644
index 0000000..444e545
--- /dev/null
+++ b/unityplugin/GhostCubeScene/build/Win32/android_build.bat
@@ -0,0 +1,13 @@
+@echo off
+SET LOCAL_PATH=%~dp0
+
+SET ENGINE_ROOT=%LOCAL_PATH%/../../../..
+chdir /d "%ENGINE_ROOT%/build/Android"
+call build_all.bat
+
+chdir /d %LOCAL_PATH%
+
+call android update project -p . --target android-19
+call ant debug
+call adb install -r ./bin/UnityEmulatorNativeActivity-debug.apk
+call adb shell am start -a android.intent.action.MAIN -n com.DiligentGraphics.UnityEmulator/com.DiligentGraphics.UnityEmulator.UnityEmulatorNativeActivity
diff --git a/unityplugin/GhostCubeScene/build/Win32/build.xml b/unityplugin/GhostCubeScene/build/Win32/build.xml
index b2dcec5..d45250f 100644
--- a/unityplugin/GhostCubeScene/build/Win32/build.xml
+++ b/unityplugin/GhostCubeScene/build/Win32/build.xml
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="UnityEmulatorNativeActivity" default="help">
- <!-- The local.properties file is created and updated by the 'android' tool.
+ <!-- compilation options -->
+ <property name="java.target" value="1.7" />
+ <property name="java.source" value="1.7" />
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
diff --git a/unityplugin/GhostCubeScene/build/Win32/jni/Android.mk b/unityplugin/GhostCubeScene/build/Win32/jni/Android.mk
index f3ec778..47e4822 100644
--- a/unityplugin/GhostCubeScene/build/Win32/jni/Android.mk
+++ b/unityplugin/GhostCubeScene/build/Win32/jni/Android.mk
@@ -14,7 +14,7 @@ LOCAL_LDLIBS := -lGLESv3 -lEGL -llog -landroid
# methods/functions required to resolve CURRENTLY OUTSTANDING dependencies and ignores the rest.
# If a subsequent library then uses methods/functions that were not originally required by the objects, you will
# have missing dependencies.
-LOCAL_STATIC_LIBRARIES := UnityEmulator-prebuilt GraphicsEngine-prebuilt GraphicsTools-prebuilt cpufeatures android_native_app_glue ndk_helper
+LOCAL_STATIC_LIBRARIES := UnityEmulator-prebuilt GraphicsEngine-prebuilt GraphicsTools-prebuilt cpufeatures android_native_app_glue NdkHelper-prebuilt
# These libraries depend on each other
LOCAL_WHOLE_STATIC_LIBRARIES := AndroidPlatform-prebuilt BasicPlatform-prebuilt Common-prebuilt
LOCAL_SHARED_LIBRARIES := GhostCubePlugin-prebuilt GraphicsEngineOpenGL-prebuilt
@@ -110,8 +110,13 @@ LOCAL_MODULE := GhostCubePlugin-prebuilt
LOCAL_SRC_FILES := $(PROJECT_ROOT)/../GhostCubePlugin/PluginSource/build/Win32/libs/$(TARGET_ARCH_ABI)/libGhostCubePlugin.so
include $(PREBUILT_SHARED_LIBRARY)
+include $(CLEAR_VARS)
+LOCAL_MODULE := NdkHelper-prebuilt
+LOCAL_SRC_FILES := $(CORE_ROOT)/External/Android/ndk_helper/build/obj/local/$(TARGET_ARCH_ABI)/libNdkHelper.a
+LOCAL_EXPORT_C_INCLUDES := $(CORE_ROOT)/External/Android/ndk_helper/include
+include $(PREBUILT_STATIC_LIBRARY)
+
-$(call import-module,android/ndk_helper)
$(call import-module,android/native_app_glue)
$(call import-module,android/cpufeatures)
diff --git a/unityplugin/GhostCubeScene/build/Win32/run.bat b/unityplugin/GhostCubeScene/build/Win32/run.bat
index 043e72e..1b67bc1 100644
--- a/unityplugin/GhostCubeScene/build/Win32/run.bat
+++ b/unityplugin/GhostCubeScene/build/Win32/run.bat
@@ -1,11 +1,6 @@
@echo off
-cd ..\.
-SET SAMPLE_PATH="..\..\..\..\build\Win32\bin\%~1\GhostCubeScene\GhostCubeScene.exe"
-
-if not exist %SAMPLE_PATH% (
- rem echo Executable not found in the diligentsamples\build\Win32 directory. Checking parent directory.
- SET SAMPLE_PATH="..\"%SAMPLE_PATH%
-)
+cd ..\assets
+SET SAMPLE_PATH="..\..\..\build\Win32\bin\%~1\GhostCubeScene\GhostCubeScene.exe"
if not exist %SAMPLE_PATH% (
echo Executable not found. Please build the solution for the selected configuration.
diff --git a/unityplugin/GhostCubeScene/src/Android/AndroidMain.cpp b/unityplugin/GhostCubeScene/src/Android/AndroidMain.cpp
index e2e659c..6a8f541 100644
--- a/unityplugin/GhostCubeScene/src/Android/AndroidMain.cpp
+++ b/unityplugin/GhostCubeScene/src/Android/AndroidMain.cpp
@@ -23,6 +23,7 @@
// This header must be included, otherwise the linker will somehow fail to find android_main()
#include <unordered_map>
+#include <string>
#include <android_native_app_glue.h>
#include "IUnityInterface.h"
diff --git a/unityplugin/UnityEmulator/build/Win32/jni/Android.mk b/unityplugin/UnityEmulator/build/Win32/jni/Android.mk
index 45466e4..44ece36 100644
--- a/unityplugin/UnityEmulator/build/Win32/jni/Android.mk
+++ b/unityplugin/UnityEmulator/build/Win32/jni/Android.mk
@@ -8,7 +8,7 @@ LOCAL_MODULE := UnityEmulator
LOCAL_CFLAGS := -std=c++11 -DENGINE_DLL
LOCAL_CPP_FEATURES := exceptions
-LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue ndk_helper
+LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue
# Include paths
PROJECT_ROOT := $(LOCAL_PATH)/../../..
@@ -27,6 +27,7 @@ LOCAL_C_INCLUDES += $(CORE_ROOT)/Graphics/GraphicsEngine/include
LOCAL_C_INCLUDES += $(CORE_ROOT)/Graphics/GraphicsEngineD3DBase/include
LOCAL_C_INCLUDES += $(CORE_ROOT)/Graphics/GraphicsEngineOpenGL/interface
LOCAL_C_INCLUDES += $(CORE_ROOT)/Graphics/HLSL2GLSLConverterLib/interface
+LOCAL_C_INCLUDES += $(CORE_ROOT)/External/Android/ndk_helper/include
LOCAL_C_INCLUDES += $(TOOLS_ROOT)/Graphics/GraphicsTools/include
# Source files
diff --git a/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorApplication.java b/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorApplication.java
index 249f291..b393e51 100644
--- a/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorApplication.java
+++ b/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorApplication.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.DiligentGrpahics.UnityEmulator;
+package com.DiligentGraphics.UnityEmulator;
import javax.microedition.khronos.opengles.GL10;
diff --git a/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorNativeActivity.java b/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorNativeActivity.java
index e30e106..f49a282 100644
--- a/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorNativeActivity.java
+++ b/unityplugin/UnityEmulator/src/Android/Java/UnityEmulator/UnityEmulatorNativeActivity.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.DiligentGrpahics.UnityEmulator;
+package com.DiligentGraphics.UnityEmulator;
import android.app.NativeActivity;
import android.os.Bundle;
diff --git a/unityplugin/UnityEmulator/src/Android/Java/helper/NDKHelper.java b/unityplugin/UnityEmulator/src/Android/Java/helper/NDKHelper.java
index 3385a5d..b7f3a06 100644
--- a/unityplugin/UnityEmulator/src/Android/Java/helper/NDKHelper.java
+++ b/unityplugin/UnityEmulator/src/Android/Java/helper/NDKHelper.java
@@ -16,46 +16,80 @@
package com.sample.helper;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.nio.ByteBuffer;
import javax.microedition.khronos.opengles.GL10;
+import android.R.bool;
+import android.opengl.GLES30;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.NativeActivity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.opengl.GLUtils;
+import android.os.Build;
import android.util.Log;
+import android.view.View;
+import android.view.View.MeasureSpec;
-public class NDKHelper
-{
- private static Context context;
+@TargetApi(Build.VERSION_CODES.GINGERBREAD)
+public class NDKHelper {
- public static void setContext(Context c)
- {
- Log.i("NDKHelper", "setContext:" + c);
- context = c;
+ public NDKHelper(NativeActivity act) {
+ activity = act;
+ }
+
+ public void loadLibrary(String soname) {
+ if (soname.isEmpty() == false) {
+ System.loadLibrary(soname);
+ loadedSO = true;
+ }
+ }
+
+ public static Boolean checkSOLoaded() {
+ if (loadedSO == false) {
+ Log.e("NDKHelper",
+ "--------------------------------------------\n"
+ + ".so has not been loaded. To use JUI helper, please initialize with \n"
+ + "NDKHelper::Init( ANativeActivity* activity, const char* helper_class_name, const char* native_soname);\n"
+ + "--------------------------------------------\n");
+ return false;
+ } else
+ return true;
}
+ private static boolean loadedSO = false;
+ NativeActivity activity;
+
+
+
//
// Load Bitmap
// Java helper is useful decoding PNG, TIFF etc rather than linking libPng
// etc separately
//
- private int nextPOT(int i)
- {
+ private int nextPOT(int i) {
int pot = 1;
while (pot < i)
pot <<= 1;
return pot;
}
- private Bitmap scaleBitmap(Bitmap bitmapToScale, float newWidth, float newHeight)
- {
+ private Bitmap scaleBitmap(Bitmap bitmapToScale, float newWidth,
+ float newHeight) {
if (bitmapToScale == null)
return null;
// get the original width and height
@@ -68,29 +102,34 @@ public class NDKHelper
matrix.postScale(newWidth / width, newHeight / height);
// recreate the new Bitmap and set it back
- return Bitmap.createBitmap(bitmapToScale, 0, 0, bitmapToScale.getWidth(),
- bitmapToScale.getHeight(), matrix, true);
+ return Bitmap.createBitmap(bitmapToScale, 0, 0,
+ bitmapToScale.getWidth(), bitmapToScale.getHeight(), matrix,
+ true);
}
- public boolean loadTexture(String path)
- {
+ public class TextureInformation {
+ boolean ret;
+ boolean alphaChannel;
+ int originalWidth;
+ int originalHeight;
+ Object image;
+ }
+
+ public Object loadTexture(String path) {
Bitmap bitmap = null;
- try
- {
+ TextureInformation info = new TextureInformation();
+ try {
String str = path;
- if (!path.startsWith("/"))
- {
+ if (!path.startsWith("/")) {
str = "/" + path;
}
- File file = new File(context.getExternalFilesDir(null), str);
- if (file.canRead())
- {
+ File file = new File(activity.getExternalFilesDir(null), str);
+ if (file.canRead()) {
bitmap = BitmapFactory.decodeStream(new FileInputStream(file));
- } else
- {
- bitmap = BitmapFactory.decodeStream(context.getResources().getAssets()
- .open(path));
+ } else {
+ bitmap = BitmapFactory.decodeStream(activity.getResources()
+ .getAssets().open(path));
}
// Matrix matrix = new Matrix();
// // resize the bit map
@@ -100,104 +139,221 @@ public class NDKHelper
// bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
// bitmap.getHeight(), matrix, true);
- } catch (Exception e)
- {
+ } catch (Exception e) {
Log.w("NDKHelper", "Coundn't load a file:" + path);
- return false;
+ info.ret = false;
+ return info;
}
- if (bitmap != null)
- {
+ if (bitmap != null) {
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
}
- return true;
+ info.ret = true;
+ info.alphaChannel = bitmap.hasAlpha();
+ info.originalWidth = getBitmapWidth(bitmap);
+ info.originalHeight = getBitmapHeight(bitmap);
+ return info;
}
- public Bitmap openBitmap(String path, boolean iScalePOT)
- {
+ public Object loadCubemapTexture(String path, int face, int miplevel, boolean sRGB) {
Bitmap bitmap = null;
- try
- {
- bitmap = BitmapFactory.decodeStream(context.getResources().getAssets()
- .open(path));
- if (iScalePOT)
+ TextureInformation info = new TextureInformation();
+ try {
+ String str = path;
+ if (!path.startsWith("/")) {
+ str = "/" + path;
+ }
+
+ File file = new File(activity.getExternalFilesDir(null), str);
+ if (file.canRead()) {
+ bitmap = BitmapFactory.decodeStream(new FileInputStream(file));
+ } else {
+ bitmap = BitmapFactory.decodeStream(activity.getResources()
+ .getAssets().open(path));
+ }
+ } catch (Exception e) {
+ Log.w("NDKHelper", "Coundn't load a file:" + path);
+ info.ret = false;
+ return info;
+ }
+
+ if (bitmap != null) {
+ if (sRGB)
{
+// GLUtils.texImage2D(face, miplevel, bitmap, 0);
+// GLUtils.texImage2D(face, miplevel,
+// GLUtils.getInternalFormat(bitmap), bitmap, 0);
+// int i = GLUtils.getInternalFormat(bitmap);
+// if( i == GL10.GL_RGBA)
+// {
+// GLUtils.texImage2D(face, miplevel,
+// GLES30.GL_SRGB, bitmap, 0);
+// }
+ //Leave them for now
+ GLUtils.texImage2D(face, miplevel, bitmap, 0);
+ }
+ else
+ GLUtils.texImage2D(face, miplevel, bitmap, 0);
+ }
+ info.ret = true;
+ info.alphaChannel = bitmap.hasAlpha();
+ info.originalWidth = getBitmapWidth(bitmap);
+ info.originalHeight = getBitmapHeight(bitmap);
+
+ return info;
+
+ }
+
+ public Object loadImage(String path) {
+ Bitmap bitmap = null;
+ TextureInformation info = new TextureInformation();
+ try {
+ String str = path;
+ if (!path.startsWith("/")) {
+ str = "/" + path;
+ }
+
+ File file = new File(activity.getExternalFilesDir(null), str);
+ if (file.canRead()) {
+ bitmap = BitmapFactory.decodeStream(new FileInputStream(file));
+ } else {
+ bitmap = BitmapFactory.decodeStream(activity.getResources()
+ .getAssets().open(path));
+ }
+ } catch (Exception e) {
+ Log.w("NDKHelper", "Coundn't load a file:" + path);
+ info.ret = false;
+ return info;
+ }
+
+ if (bitmap != null) {
+ GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
+ }
+ info.ret = true;
+ info.alphaChannel = bitmap.hasAlpha();
+ info.originalWidth = getBitmapWidth(bitmap);
+ info.originalHeight = getBitmapHeight(bitmap);
+
+ int iBytes = bitmap.getWidth() * bitmap.getHeight() * 4;
+ ByteBuffer buffer = ByteBuffer.allocateDirect(iBytes);
+
+ bitmap.copyPixelsToBuffer(buffer);
+ info.image = buffer;
+ return info;
+ }
+
+ public Bitmap openBitmap(String path, boolean iScalePOT) {
+ Bitmap bitmap = null;
+ try {
+ bitmap = BitmapFactory.decodeStream(activity.getResources()
+ .getAssets().open(path));
+ if (iScalePOT) {
int originalWidth = getBitmapWidth(bitmap);
int originalHeight = getBitmapHeight(bitmap);
int width = nextPOT(originalWidth);
int height = nextPOT(originalHeight);
- if (originalWidth != width || originalHeight != height)
- {
+ if (originalWidth != width || originalHeight != height) {
// Scale it
bitmap = scaleBitmap(bitmap, width, height);
}
}
- } catch (Exception e)
- {
+ } catch (Exception e) {
Log.w("NDKHelper", "Coundn't load a file:" + path);
}
return bitmap;
}
- public int getBitmapWidth(Bitmap bmp)
- {
+ public int getBitmapWidth(Bitmap bmp) {
return bmp.getWidth();
}
- public int getBitmapHeight(Bitmap bmp)
- {
+ public int getBitmapHeight(Bitmap bmp) {
return bmp.getHeight();
}
- public void getBitmapPixels(Bitmap bmp, int[] pixels)
- {
+ public void getBitmapPixels(Bitmap bmp, int[] pixels) {
int w = bmp.getWidth();
int h = bmp.getHeight();
bmp.getPixels(pixels, 0, w, 0, 0, w, h);
}
- public void closeBitmap(Bitmap bmp)
- {
+ public void closeBitmap(Bitmap bmp) {
bmp.recycle();
}
- public static String getNativeLibraryDirectory(Context appContext)
- {
- ApplicationInfo ai = context.getApplicationInfo();
+ public String getNativeLibraryDirectory(Context appContext) {
+ ApplicationInfo ai = activity.getApplicationInfo();
Log.w("NDKHelper", "ai.nativeLibraryDir:" + ai.nativeLibraryDir);
if ((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0
- || (ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0)
- {
+ || (ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
return ai.nativeLibraryDir;
}
return "/system/lib/";
}
- public int getNativeAudioBufferSize()
+ public String getApplicationName() {
+ final PackageManager pm = activity.getPackageManager();
+ ApplicationInfo ai;
+ try {
+ ai = pm.getApplicationInfo(activity.getPackageName(), 0);
+ } catch (final NameNotFoundException e) {
+ ai = null;
+ }
+ String applicationName = (String) (ai != null ? pm
+ .getApplicationLabel(ai) : "(unknown)");
+ return applicationName;
+ }
+
+ public String getStringResource(String resourceName)
{
+ int id = activity.getResources().getIdentifier(resourceName, "string", activity.getPackageName());
+ String value = id == 0 ? "" : (String)activity.getResources().getText(id);
+ return value;
+ }
+
+ //
+ // Audio related helpers
+ //
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
+ public int getNativeAudioBufferSize() {
int SDK_INT = android.os.Build.VERSION.SDK_INT;
- if (SDK_INT >= 17)
- {
- AudioManager am = (AudioManager) context
+ if (SDK_INT >= 17) {
+ AudioManager am = (AudioManager) activity
.getSystemService(Context.AUDIO_SERVICE);
String framesPerBuffer = am
.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
return Integer.parseInt(framesPerBuffer);
- } else
- {
+ } else {
return 0;
}
}
- public int getNativeAudioSampleRate()
- {
+ public int getNativeAudioSampleRate() {
return AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM);
+ }
+ /*
+ * Helper to execute function in UIThread
+ */
+ public void runOnUIThread(final long p) {
+ if (checkSOLoaded()) {
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ RunOnUiThreadHandler(p);
+ }
+ });
+ }
+ return;
}
-}
+ /*
+ * Native code helper for RunOnUiThread
+ */
+ native public void RunOnUiThreadHandler(long pointer);
+} \ No newline at end of file
diff --git a/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h b/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h
index 1ea7df1..5f949b0 100644
--- a/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h
+++ b/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h
@@ -45,7 +45,7 @@ public:
GLenum GetDepthBufferFormat()const
{
if (depth_size_ == 32)
- GL_DEPTH_COMPONENT32F;
+ return GL_DEPTH_COMPONENT32F;
else if (depth_size_ == 24)
return GL_DEPTH_COMPONENT24;
else if(depth_size_ == 16)
diff --git a/unityplugin/build/Win32/UnityPlugin.sln b/unityplugin/build/Win32/UnityPlugin.sln
index 48a3787..036f107 100644
--- a/unityplugin/build/Win32/UnityPlugin.sln
+++ b/unityplugin/build/Win32/UnityPlugin.sln
@@ -68,6 +68,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GhostCubeScene", "..\..\Gho
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GhostCubeScene.Assets", "..\..\GhostCubeScene\build\GhostCubeScene.Assets.vcxitems", "{CAF59C31-47E1-4F26-8455-C5E49F75BB3C}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NdkHelper", "..\..\..\diligentcore\External\Android\ndk_helper\build\NdkHelper.vcxproj", "{22BA09AE-E0B5-49F1-8403-2A824762376E}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\..\diligentcore\Graphics\GraphicsEngine\build\Windows.Shared\GraphicsEngine.Shared.vcxitems*{052dd700-477c-4512-a7f4-b05ebef5c80e}*SharedItemsImports = 4
@@ -269,6 +271,14 @@ Global
{516AA088-64B1-4DCF-9631-59F91F0E849A}.Release|x64.Build.0 = Release|x64
{516AA088-64B1-4DCF-9631-59F91F0E849A}.Release|x86.ActiveCfg = Release|Win32
{516AA088-64B1-4DCF-9631-59F91F0E849A}.Release|x86.Build.0 = Release|Win32
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Debug|ARM.ActiveCfg = Debug|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Debug|ARM.Build.0 = Debug|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Debug|x64.ActiveCfg = Debug|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Debug|x86.ActiveCfg = Debug|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Release|ARM.ActiveCfg = Release|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Release|ARM.Build.0 = Release|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Release|x64.ActiveCfg = Release|ARM
+ {22BA09AE-E0B5-49F1-8403-2A824762376E}.Release|x86.ActiveCfg = Release|ARM
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -296,5 +306,6 @@ Global
{8ADA5F93-7A38-4AD8-B8F5-1FFD4D4F630C} = {1A93BE77-E0C0-48BC-83FB-96518008B148}
{58F32677-436B-412A-BBF8-2B1310D82CD8} = {1A93BE77-E0C0-48BC-83FB-96518008B148}
{E333476E-15E3-4D43-A4CF-8748058B3BE9} = {1A93BE77-E0C0-48BC-83FB-96518008B148}
+ {22BA09AE-E0B5-49F1-8403-2A824762376E} = {1D709544-3FFA-4778-81E4-F1BEFEA67EDF}
EndGlobalSection
EndGlobal