Browse Source

android: use the FPS value provided by the application; we now run at

60 fps on Android devices, too.
legacy
Sam Hocevar sam 13 years ago
parent
commit
10010d77e4
2 changed files with 15 additions and 7 deletions
  1. +14
    -6
      src/platform/android/androidapp.cpp
  2. +1
    -1
      src/platform/android/androidapp.h

+ 14
- 6
src/platform/android/androidapp.cpp View File

@@ -34,10 +34,12 @@ JavaVM *g_vm;
jobject g_activity; jobject g_activity;
Queue<int> g_main_queue; Queue<int> g_main_queue;
Thread *g_main_thread; Thread *g_main_thread;
float g_fps;


AndroidApp::AndroidApp(char const *title, ivec2 res, float fps) AndroidApp::AndroidApp(char const *title, ivec2 res, float fps)
: data(0)
: m_data(0)
{ {
g_fps = fps;
} }


void AndroidApp::ShowPointer(bool show) void AndroidApp::ShowPointer(bool show)
@@ -51,6 +53,7 @@ void AndroidApp::ShowPointer(bool show)
void AndroidApp::Run() void AndroidApp::Run()
{ {
g_main_queue.Push(1); g_main_queue.Push(1);
g_main_queue.Push(1);


while (!Ticker::Finished()) while (!Ticker::Finished())
{ {
@@ -100,11 +103,17 @@ Java_org_zoy_LolEngine_LolActivity_nativeInit(JNIEnv* env, jobject thiz)
extern "C" void extern "C" void
Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env) Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env)
{ {
Log::Info("Java layer initialising renderer");
Ticker::Setup(30.0f);
/* Initialise app thread and wait for it to be ready, ie. set
* the FPS value at least. */
g_main_thread = new Thread(lol::AndroidApp::MainRun, NULL);;
g_main_queue.Pop();

/* Launch our ticker */
Log::Info("Java layer initialising renderer at %g fps", g_fps);
Ticker::Setup(g_fps);
Video::Setup(ivec2(320, 200)); Video::Setup(ivec2(320, 200));


g_main_thread = new Thread(lol::AndroidApp::MainRun, NULL);;
/* Wake up app thread */
g_main_queue.Pop(); g_main_queue.Pop();
} }


@@ -145,8 +154,7 @@ extern "C" void
Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz, Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz,
jint x, jint y) jint x, jint y)
{ {
ivec2 pos = ivec2(0, 479) + ivec2(x * 640, -y * 480) / Video::GetSize();
Input::SetMousePos(pos);
Input::SetMousePos(ivec2(x, y));
} }


/* Call to render the next GL frame */ /* Call to render the next GL frame */


+ 1
- 1
src/platform/android/androidapp.h View File

@@ -35,7 +35,7 @@ public:
static void *MainRun(void *data); static void *MainRun(void *data);


private: private:
AndroidAppData *data;
AndroidAppData *m_data;
}; };


} /* namespace lol */ } /* namespace lol */


Loading…
Cancel
Save