From b3eb112ae3c189b9d8cee5f2847e9d93b64a63b9 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Sun, 10 Feb 2013 12:47:51 +0000 Subject: [PATCH] catch up --- .../jni/android_api.cpp | 64 +++---------------- .../SalmonWallpaperTemplate/jni/android_api.h | 6 -- .../SalmonWallpaperTemplate/jni/main_code.cpp | 14 ++-- .../wallpapertemplate/GLWallpaperService.java | 5 +- .../wallpapertemplate/JniWrapper.java | 6 -- .../MainWallpaperService.java | 10 +-- .../windows/Template/main.cpp | 25 ++++++-- 7 files changed, 44 insertions(+), 86 deletions(-) diff --git a/Templates/SalmonWallpaperTemplate/jni/android_api.cpp b/Templates/SalmonWallpaperTemplate/jni/android_api.cpp index 444a4a1..21bccc6 100644 --- a/Templates/SalmonWallpaperTemplate/jni/android_api.cpp +++ b/Templates/SalmonWallpaperTemplate/jni/android_api.cpp @@ -1,11 +1,9 @@ #include "android_api.h" #include "main_code.h" -#include "boost\thread.hpp" +#include "boost/thread.hpp" -std::shared_ptr App(new TAndroidApplication); - -boost::mutex RenderMutex; +TAndroidApplication* Application = NULL; float lastOffsetX = 0.5f; @@ -16,13 +14,17 @@ bool RedBkgPref = false; JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height) { + Application = JniInitApp(width, height, 800.f, 480.f); + boost::get(Renderer->Camera).SetAlpha((lastOffsetX) * pi / 180.f); + + /* RenderMutex.lock(); try { - if (App->IsInited()) + if (Application->IsInited()) { App->OuterDeinit(); //Clean up what is left at previous launch (if applicable) } @@ -48,57 +50,11 @@ JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEn throw; } - RenderMutex.unlock(); + RenderMutex.unlock();*/ } -JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt) -{ - RenderMutex.unlock(); - - try - { - if (App->IsInited()) - { - App->OuterDraw(); - App->OuterUpdate(dt); - - if (OffsetChanged) - { - Renderer->SetAlpha((lastOffsetX) * pi / 180.f); - } - } - } - catch (...) - { - throw; - } - - RenderMutex.unlock(); -} - - -JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y) -{ - try - { - if (App->IsInited()) - { - - vec2 offset = vec2(x*Renderer->GetMatrixWidth()/static_cast(App->Width), y*Renderer->GetMatrixHeight()/static_cast(App->Height)); - - App->OuterOnMove(offset); - - } - } - catch (...) - { - throw; - } -} - - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY) { @@ -109,10 +65,6 @@ JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset( } } -JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOrientation(JNIEnv * env, jobject obj, int isLandscape) -{ -} - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetRedBkgPref(JNIEnv * env, jobject obj, jboolean r) { RedBkgPref = r; diff --git a/Templates/SalmonWallpaperTemplate/jni/android_api.h b/Templates/SalmonWallpaperTemplate/jni/android_api.h index b3ca6c5..c6ab513 100644 --- a/Templates/SalmonWallpaperTemplate/jni/android_api.h +++ b/Templates/SalmonWallpaperTemplate/jni/android_api.h @@ -16,14 +16,8 @@ extern "C" { JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height); - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt); - - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y); - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY); - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOrientation(JNIEnv * env, jobject obj, int isLandscape); - JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetRedBkgPref(JNIEnv * env, jobject obj, jboolean r); }; diff --git a/Templates/SalmonWallpaperTemplate/jni/main_code.cpp b/Templates/SalmonWallpaperTemplate/jni/main_code.cpp index c90e5ea..e174bae 100644 --- a/Templates/SalmonWallpaperTemplate/jni/main_code.cpp +++ b/Templates/SalmonWallpaperTemplate/jni/main_code.cpp @@ -108,7 +108,7 @@ void TAndroidApplication::InnerInit() CheckGlError(); - Renderer->MovePhi(pi/32); + boost::get(Renderer->Camera).MovePhi(pi/32); //ResourceManager->ModelManager.AddLiteModel("bt_box_yellow.lm1"); @@ -119,19 +119,21 @@ void TAndroidApplication::InnerInit() LoadModels(); - if (Width > Height) + if (Renderer->GetScreenWidth() > Renderer->GetScreenHeight()) { - Renderer->MoveDist(30.f); + boost::get(Renderer->Camera).MoveDist(30.f); } else { - Renderer->MoveDist(45.f); + boost::get(Renderer->Camera).MoveDist(45.f); } CheckGlError(); - Renderer->SetPerspectiveFullScreenViewport(); + glViewport(0, 0, Renderer->GetScreenWidth(), Renderer->GetScreenHeight()); + + Renderer->SetPerspectiveProjection(pi / 6.f, 1.0f, 100.0f); *Console<<"Inner init end!\n"; @@ -174,7 +176,7 @@ void TAndroidApplication::InnerUpdate(cardinal dt) void TAndroidApplication::InnerOnMove(vec2 shift) { - Renderer->MoveAlpha(-pi*shift.v[0]*0.1f); + boost::get(Renderer->Camera).MoveAlpha(-pi*shift.v[0]*0.1f); } void TAndroidApplication::OnMouseDown(TMouseState& mouseState) diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java index bfd7e0f..6827305 100644 --- a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java @@ -18,6 +18,9 @@ import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.SurfaceHolder; +import fishrungames.engine.EngineWrapper; + + public class GLWallpaperService extends WallpaperService { private static final String TAG = "GLWallpaperService"; @@ -654,7 +657,7 @@ class GLThread extends Thread { long currentTimeStamp = c.getTimeInMillis(); - JniWrapper.Update(currentTimeStamp - lastTimeStamp); + EngineWrapper.Update(currentTimeStamp - lastTimeStamp); lastTimeStamp = currentTimeStamp; diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java index 061f9fa..394b648 100644 --- a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java @@ -18,12 +18,6 @@ public class JniWrapper public static native void Init(int width, int height); - public static native void Update(long dt); - - public static native void OnTapMove(float x, float y); - public static native void SetOffset(float offsetX, float offsetY); - public static native void SetOrientation(int isLandscape); - } diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java index d7f527d..8e0b5a6 100644 --- a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java @@ -19,7 +19,7 @@ import android.view.SurfaceHolder; //import com.seb.SLWP.SLWP.GlEngine.DownloadTask; -import fishrungames.engine.FileWrapper; +import fishrungames.engine.EngineWrapper; public class MainWallpaperService extends GLWallpaperService implements OnSharedPreferenceChangeListener { @@ -30,7 +30,7 @@ public class MainWallpaperService extends GLWallpaperService implements */ static { - FileWrapper.LoadSalmonEngineLibrary(); + EngineWrapper.LoadSalmonEngineLibrary(); JniWrapper.LoadLibrary(); } @@ -81,8 +81,8 @@ public class MainWallpaperService extends GLWallpaperService implements PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); - FileWrapper.SetActivityInstance(this); - FileWrapper.SetupEnviroment(); + EngineWrapper.SetActivityInstance(this); + EngineWrapper.SetupEnviroment(); String apkFilePath = null; ApplicationInfo appInfo = null; @@ -98,7 +98,7 @@ public class MainWallpaperService extends GLWallpaperService implements } apkFilePath = appInfo.sourceDir; - FileWrapper.SetupApkFilePath(apkFilePath); + EngineWrapper.SetupApkFilePath(apkFilePath); Init(); } diff --git a/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp b/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp index 6fcddd4..e36c679 100644 --- a/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp +++ b/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp @@ -4,12 +4,25 @@ int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, LPSTR lpszCmdLine, int nCmdShow) { - //Create application - TAndroidApplication Application; + int width = 800; + int height = 480; - Application.Width = 800; - Application.Height = 480; + if (CreateEngine(width, height)) + { + + //MyApplication scope + { + TAndroidApplication Application; - //Start application - return MainLoop(Application); + Application.OuterInit(width, height, width, height); + + MainLoop(&Application); + + Application.OuterDeinit(); + } + + DestroyEngine(); + } + + return 0; } \ No newline at end of file