diff --git a/include/Render/RenderInterface.h b/include/Render/RenderInterface.h index 2338fef..856a4b1 100644 --- a/include/Render/RenderInterface.h +++ b/include/Render/RenderInterface.h @@ -38,6 +38,9 @@ public: virtual float GetMatrixWidth(); virtual float GetMatrixHeight(); + virtual void SetMatrixWidth(float matrixWidth); + virtual void SetMatrixHeight(float matrixHeight); + virtual void SetScreenWidthHeight(int screenWidth, int screenHeight); virtual void SetUniforms() = 0; diff --git a/include/Utils/JniApi/JniApi.h b/include/Utils/JniApi/JniApi.h index 2191b14..d04ef36 100644 --- a/include/Utils/JniApi/JniApi.h +++ b/include/Utils/JniApi/JniApi.h @@ -36,13 +36,13 @@ extern int FileSize; extern std::string ApkFilePath; extern "C" { - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIEnv* env, jobject thiz); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_SetupEnviroment(JNIEnv* env, jobject thiz); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s); //All 2 deprecated - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize); }; diff --git a/include/Utils/JniApi/JniApplication.h b/include/Utils/JniApi/JniApplication.h index 4a0829e..c1a7b75 100644 --- a/include/Utils/JniApi/JniApplication.h +++ b/include/Utils/JniApi/JniApplication.h @@ -23,10 +23,12 @@ extern bool Inited; template -void JniInitApp(int width, int height, float matrixWidth, float matrixHeight) +APPTYPE* JniInitApp(int width, int height, float matrixWidth, float matrixHeight) { InitLock.lock(); + APPTYPE* result = NULL; + try { @@ -41,8 +43,12 @@ void JniInitApp(int width, int height, float matrixWidth, float matrixHeight) } CreateEngine(); - - App = new APPTYPE; + + *Console<OuterInit(width, height, matrixWidth, matrixHeight); @@ -53,21 +59,23 @@ void JniInitApp(int width, int height, float matrixWidth, float matrixHeight) throw; } InitLock.unlock(); + + return result; } extern "C" { //JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_Update(JNIEnv * env, jobject obj, long dt); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_Destroy(JNIEnv * env, jobject obj); - JNIEXPORT int JNICALL Java_fishrungames_engine_FileWrapper_IsInited(JNIEnv * env, jobject obj); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUpAfterMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time); - JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_Update(JNIEnv * env, jobject obj, long dt); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_Destroy(JNIEnv * env, jobject obj); + JNIEXPORT int JNICALL Java_fishrungames_engine_EngineWrapper_IsInited(JNIEnv * env, jobject obj); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapUpAfterMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time); + JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode); }; diff --git a/src/Render/RenderInterface.cpp b/src/Render/RenderInterface.cpp index b075c37..e28fc44 100644 --- a/src/Render/RenderInterface.cpp +++ b/src/Render/RenderInterface.cpp @@ -54,6 +54,15 @@ float TRendererInterface::GetMatrixHeight() return MatrixHeight; } +void TRendererInterface::SetMatrixWidth(float matrixWidth) +{ + MatrixWidth = matrixWidth; +} + +void TRendererInterface::SetMatrixHeight(float matrixHeight) +{ + MatrixHeight = matrixHeight; +} diff --git a/src/SalmonEngineInterface.cpp b/src/SalmonEngineInterface.cpp index 42017e8..6a57f2c 100644 --- a/src/SalmonEngineInterface.cpp +++ b/src/SalmonEngineInterface.cpp @@ -91,6 +91,8 @@ void TApplicationAncestor::OuterInit(int screenWidth, int screenHeight, float ma void TApplicationAncestor::OuterDeinit() { + TryUpdateMainThreadId(); + *Console<<"Outer Deinit"; CheckGlError("OuterDeinit"); InnerDeinit(); } diff --git a/src/Utils/JniApi/JniApi.cpp b/src/Utils/JniApi/JniApi.cpp index a6fb4aa..5efe00b 100644 --- a/src/Utils/JniApi/JniApi.cpp +++ b/src/Utils/JniApi/JniApi.cpp @@ -7,7 +7,7 @@ namespace SE JavaVM* JavaVirtualMachine = 0; -const std::string CONST_JAVA_FILESYSTEM_CLASS_NAME = "fishrungames/engine/FileWrapper"; +const std::string CONST_JAVA_FILESYSTEM_CLASS_NAME = "fishrungames/engine/EngineWrapper"; //Private data @@ -32,7 +32,7 @@ void JniCallOpenFile(const std::string& fileName); //================================================== -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIEnv* env, jobject thiz) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_SetupEnviroment(JNIEnv* env, jobject thiz) { int JVMResult; JVMResult = env->GetJavaVM(&JavaVirtualMachine); @@ -40,7 +40,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIE //TODO: Check if jmvresult != 0 } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s) { const char *nativeString = env->GetStringUTFChars(s, 0); @@ -51,7 +51,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupApkFilePath(JNI } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s) { const char *nativeString = env->GetStringUTFChars(s, 0); @@ -63,7 +63,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* e //Deprecated -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize) { FileSize = fileSize; FileArr = new cardinal [fileSize % 4 == 0 ? fileSize/4 : fileSize/4 + 1]; @@ -72,7 +72,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_CreateFile(JNIEnv* e //Deprecated -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize) { JNIEnv* jenv; JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); diff --git a/src/Utils/JniApi/JniApplication.cpp b/src/Utils/JniApi/JniApplication.cpp index ab55daf..afbc189 100644 --- a/src/Utils/JniApi/JniApplication.cpp +++ b/src/Utils/JniApi/JniApplication.cpp @@ -11,7 +11,7 @@ boost::mutex InitLock; bool Inited = false; -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_Update(JNIEnv * env, jobject obj, long dt) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_Update(JNIEnv * env, jobject obj, long dt) { InitLock.lock(); try @@ -32,7 +32,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_Update(JNIEnv * env, } -JNIEXPORT int JNICALL Java_fishrungames_engine_FileWrapper_IsInited(JNIEnv * env, jobject obj) +JNIEXPORT int JNICALL Java_fishrungames_engine_EngineWrapper_IsInited(JNIEnv * env, jobject obj) { if (Inited) { @@ -46,7 +46,7 @@ JNIEXPORT int JNICALL Java_fishrungames_engine_FileWrapper_IsInited(JNIEnv * env } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_Destroy(JNIEnv * env, jobject obj) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_Destroy(JNIEnv * env, jobject obj) { InitLock.lock(); try @@ -77,7 +77,7 @@ void DestroyThreaded() } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time) { InitLock.lock(); try @@ -95,7 +95,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapDown(JNIEnv * e } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time) { InitLock.lock(); try @@ -112,7 +112,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUp(JNIEnv * env InitLock.unlock(); } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUpAfterMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapUpAfterMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time) { InitLock.lock(); try @@ -129,7 +129,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUpAfterMove(JNI InitLock.unlock(); } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time) { InitLock.lock(); try @@ -146,12 +146,12 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapMove(JNIEnv * e InitLock.unlock(); } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time) { } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time) { InitLock.lock(); try @@ -168,7 +168,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnScroll(JNIEnv * en InitLock.unlock(); } -JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode) +JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode) { InitLock.lock(); try