source: trunk/src/androidapp.cpp @ 744

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

android: use GLES2 instead of GLES.

  • 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
24#include "interface.h"
25
26namespace lol
27{
28jobject g_ctx;
29JNIEnv *g_env;
30};
31
32extern "C" void
33Java_org_zoy_LolEngine_LolActivity_nativeInit(JNIEnv* env, jobject thiz)
34{
35    env->NewGlobalRef(thiz); /* FIXME: never released! */
36    g_ctx = thiz;
37}
38
39extern "C" void
40Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env)
41{
42    g_env = env;
43
44    __android_log_print(ANDROID_LOG_INFO, "LOL", "init");
45    Ticker::Setup(30.0f);
46    Video::Setup(320, 200);
47
48    new Interface();
49    new DebugFps(20, 20);
50}
51
52extern "C" void
53Java_org_zoy_LolEngine_LolRenderer_nativeResize(JNIEnv* env, jobject thiz,
54                                                jint w, jint h)
55{
56    __android_log_print(ANDROID_LOG_INFO, "LOL", "resize w=%d h=%d", w, h);
57    Video::Setup(w, h);
58}
59
60extern "C" void
61Java_org_zoy_LolEngine_LolRenderer_nativeDone(JNIEnv* env)
62{
63    /* FIXME: clean up */
64}
65
66extern "C" void
67Java_org_zoy_LolEngine_LolView_nativePause(JNIEnv* env)
68{
69    /* TODO: unimplemented */
70}
71
72extern "C" void
73Java_org_zoy_LolEngine_LolView_nativeDown(JNIEnv* env)
74{
75    Input::SetMouseButton(0);
76}
77
78extern "C" void
79Java_org_zoy_LolEngine_LolView_nativeUp(JNIEnv* env)
80{
81    Input::UnsetMouseButton(0);
82}
83
84extern "C" void
85Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz,
86                                          jint x, jint y)
87{
88    vec2i pos(x * 640 / Video::GetWidth(),
89              480 - 1 - y * 480 / Video::GetHeight());
90    Input::SetMousePos(pos);
91}
92
93/* Call to render the next GL frame */
94extern "C" void
95Java_org_zoy_LolEngine_LolRenderer_nativeRender(JNIEnv* env)
96{
97    Ticker::ClampFps();
98    Ticker::TickGame();
99    Ticker::TickDraw();
100}
101
Note: See TracBrowser for help on using the repository browser.