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

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

build: compilation fixes for errors introduced in the recent Direct3D
and Android changes.

  • Property svn:keywords set to Id
File size: 2.5 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#if defined __ANDROID__
16
17#include <jni.h>
18#include <android/log.h>
19
20#include "core.h"
21#include "loldebug.h"
22#include "androidapp.h"
23
24using namespace lol;
25
26/* Monsterz-specific */
27#include "interface.h"
28
29namespace lol
30{
31JavaVM *g_vm;
32jobject g_activity;
33
34AndroidApp::AndroidApp(char const *title, ivec2 res, float fps) :
35    data(0)
36{
37}
38
39void AndroidApp::ShowPointer(bool show)
40{
41}
42
43void AndroidApp::Run()
44{
45    while (!Ticker::Finished())
46    {
47        /* Tick the renderer, show the frame and clamp to desired framerate. */
48        Ticker::TickDraw();
49    }
50}
51
52AndroidApp::~AndroidApp()
53{
54}
55
56};
57
58extern "C" jint
59JNI_OnLoad(JavaVM* vm, void* reserved)
60{
61    g_vm = vm;
62    return JNI_VERSION_1_4;
63}
64
65extern "C" void
66Java_org_zoy_LolEngine_LolActivity_nativeInit(JNIEnv* env, jobject thiz)
67{
68    env->NewGlobalRef(thiz); /* FIXME: never released! */
69    g_activity = thiz;
70}
71
72extern "C" void
73Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env)
74{
75    Log::Info("initialising renderer");
76    Ticker::Setup(30.0f);
77    Video::Setup(ivec2(320, 200));
78
79    new Interface();
80    new DebugFps(20, 20);
81}
82
83extern "C" void
84Java_org_zoy_LolEngine_LolRenderer_nativeResize(JNIEnv* env, jobject thiz,
85                                                jint w, jint h)
86{
87    Log::Info("resizing to %i x %i", w, h);
88    Video::Setup(ivec2(w, h));
89}
90
91extern "C" void
92Java_org_zoy_LolEngine_LolRenderer_nativeDone(JNIEnv* env)
93{
94    /* FIXME: clean up */
95}
96
97extern "C" void
98Java_org_zoy_LolEngine_LolView_nativePause(JNIEnv* env)
99{
100    /* TODO: unimplemented */
101}
102
103extern "C" void
104Java_org_zoy_LolEngine_LolView_nativeDown(JNIEnv* env)
105{
106    Input::SetMouseButton(0);
107}
108
109extern "C" void
110Java_org_zoy_LolEngine_LolView_nativeUp(JNIEnv* env)
111{
112    Input::UnsetMouseButton(0);
113}
114
115extern "C" void
116Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz,
117                                          jint x, jint y)
118{
119    ivec2 pos = ivec2(0, 479) + ivec2(x * 640, -y * 480) / Video::GetSize();
120    Input::SetMousePos(pos);
121}
122
123/* Call to render the next GL frame */
124extern "C" void
125Java_org_zoy_LolEngine_LolRenderer_nativeRender(JNIEnv* env)
126{
127    Ticker::TickDraw();
128}
129
130#endif /* __ANDROID__ */
131
Note: See TracBrowser for help on using the repository browser.