Cleaning everything

This commit is contained in:
Vladislav Khorev 2013-02-10 12:41:42 +00:00
parent 87ad6cb2fb
commit 87f4d81238
7 changed files with 56 additions and 34 deletions

View File

@ -38,6 +38,9 @@ public:
virtual float GetMatrixWidth(); virtual float GetMatrixWidth();
virtual float GetMatrixHeight(); virtual float GetMatrixHeight();
virtual void SetMatrixWidth(float matrixWidth);
virtual void SetMatrixHeight(float matrixHeight);
virtual void SetScreenWidthHeight(int screenWidth, int screenHeight); virtual void SetScreenWidthHeight(int screenWidth, int screenHeight);
virtual void SetUniforms() = 0; virtual void SetUniforms() = 0;

View File

@ -36,13 +36,13 @@ extern int FileSize;
extern std::string ApkFilePath; extern std::string ApkFilePath;
extern "C" { extern "C" {
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIEnv* env, jobject thiz); JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_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_EngineWrapper_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_ConsoleOut(JNIEnv* env, jobject thiz, jstring s);
//All 2 deprecated //All 2 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);
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);
}; };

View File

@ -23,10 +23,12 @@ extern bool Inited;
template<typename APPTYPE> template<typename APPTYPE>
void JniInitApp(int width, int height, float matrixWidth, float matrixHeight) APPTYPE* JniInitApp(int width, int height, float matrixWidth, float matrixHeight)
{ {
InitLock.lock(); InitLock.lock();
APPTYPE* result = NULL;
try try
{ {
@ -41,8 +43,12 @@ void JniInitApp(int width, int height, float matrixWidth, float matrixHeight)
} }
CreateEngine(); CreateEngine();
App = new APPTYPE; *Console<<std::string("Console successfully started!!!");
result = new APPTYPE;
App = result;
App->OuterInit(width, height, matrixWidth, matrixHeight); App->OuterInit(width, height, matrixWidth, matrixHeight);
@ -53,21 +59,23 @@ void JniInitApp(int width, int height, float matrixWidth, float matrixHeight)
throw; throw;
} }
InitLock.unlock(); InitLock.unlock();
return result;
} }
extern "C" { extern "C" {
//JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height); //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_EngineWrapper_Update(JNIEnv * env, jobject obj, long dt);
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_Destroy(JNIEnv * env, jobject obj); JNIEXPORT void JNICALL Java_fishrungames_engine_EngineWrapper_Destroy(JNIEnv * env, jobject obj);
JNIEXPORT int JNICALL Java_fishrungames_engine_FileWrapper_IsInited(JNIEnv * env, jobject obj); JNIEXPORT int JNICALL Java_fishrungames_engine_EngineWrapper_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_EngineWrapper_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_EngineWrapper_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_EngineWrapper_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_EngineWrapper_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_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);
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);
}; };

View File

@ -54,6 +54,15 @@ float TRendererInterface::GetMatrixHeight()
return MatrixHeight; return MatrixHeight;
} }
void TRendererInterface::SetMatrixWidth(float matrixWidth)
{
MatrixWidth = matrixWidth;
}
void TRendererInterface::SetMatrixHeight(float matrixHeight)
{
MatrixHeight = matrixHeight;
}

View File

@ -91,6 +91,8 @@ void TApplicationAncestor::OuterInit(int screenWidth, int screenHeight, float ma
void TApplicationAncestor::OuterDeinit() void TApplicationAncestor::OuterDeinit()
{ {
TryUpdateMainThreadId();
*Console<<"Outer Deinit";
CheckGlError("OuterDeinit"); CheckGlError("OuterDeinit");
InnerDeinit(); InnerDeinit();
} }

View File

@ -7,7 +7,7 @@ namespace SE
JavaVM* JavaVirtualMachine = 0; 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 //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; int JVMResult;
JVMResult = env->GetJavaVM(&JavaVirtualMachine); JVMResult = env->GetJavaVM(&JavaVirtualMachine);
@ -40,7 +40,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIE
//TODO: Check if jmvresult != 0 //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); 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); const char *nativeString = env->GetStringUTFChars(s, 0);
@ -63,7 +63,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* e
//Deprecated //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; FileSize = fileSize;
FileArr = new cardinal [fileSize % 4 == 0 ? fileSize/4 : fileSize/4 + 1]; 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 //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; JNIEnv* jenv;
JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4);

View File

@ -11,7 +11,7 @@ boost::mutex InitLock;
bool Inited = false; 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(); InitLock.lock();
try 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) 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(); InitLock.lock();
try 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(); InitLock.lock();
try 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(); InitLock.lock();
try try
@ -112,7 +112,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUp(JNIEnv * env
InitLock.unlock(); 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(); InitLock.lock();
try try
@ -129,7 +129,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapUpAfterMove(JNI
InitLock.unlock(); 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(); InitLock.lock();
try try
@ -146,12 +146,12 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnTapMove(JNIEnv * e
InitLock.unlock(); 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(); InitLock.lock();
try try
@ -168,7 +168,7 @@ JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_OnScroll(JNIEnv * en
InitLock.unlock(); 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(); InitLock.lock();
try try