source: trunk/src/platform/android/androidapp.cpp @ 1106

Last change on this file since 1106 was 1106, checked in by sam, 10 years ago

core: try to merge Ticker and Emcee. Still not very good.

  • Property svn:keywords set to Id
File size: 2.1 KB
RevLine 
[706]1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <jni.h>
16#include <android/log.h>
17
18#include "core.h"
19#include "lolgl.h"
20#include "loldebug.h"
21
22using namespace lol;
23
[714]24namespace lol
25{
[864]26JavaVM *g_vm;
27jobject g_activity;
[714]28};
29
[836]30extern "C" jint
31JNI_OnLoad(JavaVM* vm, void* reserved)
32{
[864]33    g_vm = vm;
[836]34    return JNI_VERSION_1_4;
35}
36
[706]37extern "C" void
[714]38Java_org_zoy_LolEngine_LolActivity_nativeInit(JNIEnv* env, jobject thiz)
39{
40    env->NewGlobalRef(thiz); /* FIXME: never released! */
[864]41    g_activity = thiz;
[714]42}
43
44extern "C" void
[706]45Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env)
46{
[836]47    Log::Info("initialising renderer");
[714]48    Ticker::Setup(30.0f);
[863]49    Video::Setup(ivec2(320, 200));
[706]50
[709]51    new Interface();
[706]52    new DebugFps(20, 20);
53}
54
55extern "C" void
[710]56Java_org_zoy_LolEngine_LolRenderer_nativeResize(JNIEnv* env, jobject thiz,
[706]57                                                jint w, jint h)
58{
[836]59    Log::Info("resizing to %i x %i", w, h);
[863]60    Video::Setup(ivec2(w, h));
[706]61}
62
63extern "C" void
64Java_org_zoy_LolEngine_LolRenderer_nativeDone(JNIEnv* env)
65{
66    /* FIXME: clean up */
67}
68
69extern "C" void
[744]70Java_org_zoy_LolEngine_LolView_nativePause(JNIEnv* env)
[706]71{
72    /* TODO: unimplemented */
73}
74
[719]75extern "C" void
[744]76Java_org_zoy_LolEngine_LolView_nativeDown(JNIEnv* env)
[719]77{
78    Input::SetMouseButton(0);
79}
80
81extern "C" void
[744]82Java_org_zoy_LolEngine_LolView_nativeUp(JNIEnv* env)
[719]83{
84    Input::UnsetMouseButton(0);
85}
86
87extern "C" void
[744]88Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz,
89                                          jint x, jint y)
[719]90{
[863]91    ivec2 pos = ivec2(0, 479) + ivec2(x * 640, -y * 480) / Video::GetSize();
[719]92    Input::SetMousePos(pos);
93}
94
[706]95/* Call to render the next GL frame */
96extern "C" void
97Java_org_zoy_LolEngine_LolRenderer_nativeRender(JNIEnv* env)
98{
99    Ticker::TickDraw();
100}
101
Note: See TracBrowser for help on using the repository browser.