catch up
This commit is contained in:
parent
287ab26da1
commit
b3eb112ae3
@ -1,11 +1,9 @@
|
||||
#include "android_api.h"
|
||||
|
||||
#include "main_code.h"
|
||||
#include "boost\thread.hpp"
|
||||
#include "boost/thread.hpp"
|
||||
|
||||
std::shared_ptr<TAndroidApplication> 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<TAndroidApplication>(width, height, 800.f, 480.f);
|
||||
|
||||
boost::get<TPanoramicCamera>(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<float>(App->Width), y*Renderer->GetMatrixHeight()/static_cast<float>(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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -108,7 +108,7 @@ void TAndroidApplication::InnerInit()
|
||||
|
||||
CheckGlError();
|
||||
|
||||
Renderer->MovePhi(pi/32);
|
||||
boost::get<TPanoramicCamera>(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<TPanoramicCamera>(Renderer->Camera).MoveDist(30.f);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Renderer->MoveDist(45.f);
|
||||
boost::get<TPanoramicCamera>(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<TPanoramicCamera>(Renderer->Camera).MoveAlpha(-pi*shift.v[0]*0.1f);
|
||||
}
|
||||
|
||||
void TAndroidApplication::OnMouseDown(TMouseState& mouseState)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user