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

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

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

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
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
24namespace lol
25{
26JavaVM *g_vm;
27jobject g_activity;
28};
29
30extern "C" jint
31JNI_OnLoad(JavaVM* vm, void* reserved)
32{
33    g_vm = vm;
34    return JNI_VERSION_1_4;
35}
36
37extern "C" void
38Java_org_zoy_LolEngine_LolActivity_nativeInit(JNIEnv* env, jobject thiz)
39{
40    env->NewGlobalRef(thiz); /* FIXME: never released! */
41    g_activity = thiz;
42}
43
44extern "C" void
45Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env)
46{
47    Log::Info("initialising renderer");
48    Ticker::Setup(30.0f);
49    Video::Setup(ivec2(320, 200));
50
51    new Interface();
52    new DebugFps(20, 20);
53}
54
55extern "C" void
56Java_org_zoy_LolEngine_LolRenderer_nativeResize(JNIEnv* env, jobject thiz,
57                                                jint w, jint h)
58{
59    Log::Info("resizing to %i x %i", w, h);
60    Video::Setup(ivec2(w, h));
61}
62
63extern "C" void
64Java_org_zoy_LolEngine_LolRenderer_nativeDone(JNIEnv* env)
65{
66    /* FIXME: clean up */
67}
68
69extern "C" void
70Java_org_zoy_LolEngine_LolView_nativePause(JNIEnv* env)
71{
72    /* TODO: unimplemented */
73}
74
75extern "C" void
76Java_org_zoy_LolEngine_LolView_nativeDown(JNIEnv* env)
77{
78    Input::SetMouseButton(0);
79}
80
81extern "C" void
82Java_org_zoy_LolEngine_LolView_nativeUp(JNIEnv* env)
83{
84    Input::UnsetMouseButton(0);
85}
86
87extern "C" void
88Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz,
89                                          jint x, jint y)
90{
91    ivec2 pos = ivec2(0, 479) + ivec2(x * 640, -y * 480) / Video::GetSize();
92    Input::SetMousePos(pos);
93}
94
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.