Add android build files

This commit is contained in:
Lucas Baudin 2016-02-24 20:41:21 +01:00
parent 48069a7bcc
commit c7c5788086
29 changed files with 20514 additions and 0 deletions

3
.gitignore vendored
View File

@ -52,3 +52,6 @@ packets_log.txt
history.dat
README.dependencies
xx
android/android-ndk-r10e
android/jni/jpeglib

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.supertuxkart.stk"
android:versionCode="1"
android:versionName="1.0">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="8" />
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:debuggable="true" android:label="@string/app_name" android:hasCode="false">
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:icon="@drawable/stkicon">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name"
android:value="irrlicht2" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
<!-- END_INCLUDE(manifest) -->

22
android/Makefile Normal file
View File

@ -0,0 +1,22 @@
NDK_PATH=android-ndk-r10e/
# target: all - Default target. Build and create the apk.
all: build apk
# target: build - Build the native code
build:
NDK_CCACHE=ccache ${NDK_PATH}/ndk-build -j3
# target: apk - Make a debug APK
apk:
ant debug
# target: install - Install the debug APK to the plugged device/emulator
install:
ant installd
# target: help - Display callable targets.
help:
egrep "^# target:" [Mm]akefile
run:
adb shell am start -n org.supertuxkart.stk/android.app.NativeActivity

View File

@ -0,0 +1,51 @@
Dwarf lowpoly model Pack
Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk
INSTALLATION INSTRUCTIONS:
To install, simply unzip to your hard drive with the "Use Folder Names" option turned on. And that's it you're ready to go!
USAGE INFORMATION:
Each zip contains the models, textures and animation info for that particular format!
Please Read the "animationinfo.txt" file included in each zip for the exact frames of animation to use
Credits to me "Psionic" are really appreciated but are not essential ;-)
Any questions, screenshots of him in use etc drop by my site or email me at:-
website: http://www.psionic3d.co.uk
email: psionic@blueyonder.co.uk
WHAT'S INCLUDED IN THE ZIP:
ReadMe.txt - This file
b3d.zip - Blitz 3D Format models and textures
ms3d.zip - Milkshape 3D Format models and textures
x.zip - DarkBasic Direct X 8 Format models and textures
RESTRICTIONS:
This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:-
**You may not sell/re-sell this model pack or claim it as your own.
***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent.
Psi
http://www.psionic3d.co.uk

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

18468
android/assets/media/dwarf.x Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

85
android/build.xml Normal file
View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="NativeActivity" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<loadproperties srcFile="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

183
android/jni/Android.mk Normal file
View File

@ -0,0 +1,183 @@
# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
#include $(CLEAR_VARS)
#LOCAL_MODULE := my_gnustl_shared
#LOCAL_SRC_FILES := external/lib/$(TARGET_ARCH_ABI)/libgnustl_shared.so
#include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
# PNG
LOCAL_CPP_FEATURES += rtti
LOCAL_MODULE := png
LOCAL_SRC_FILES = libpng/example.c \
libpng/png.c \
libpng/pngerror.c \
libpng/pngget.c \
libpng/pngmem.c \
libpng/pngpread.c \
libpng/pngread.c \
libpng/pngrio.c \
libpng/pngrtran.c \
libpng/pngrutil.c \
libpng/pngset.c \
libpng/pngtest.c \
libpng/pngtrans.c \
libpng/pngwio.c \
libpng/pngwrite.c \
libpng/pngwtran.c \
libpng/pngwutil.c \
zlib/adler32.c \
zlib/compress.c \
zlib/crc32.c \
zlib/deflate.c \
zlib/gzclose.c \
zlib/gzlib.c \
zlib/gzread.c \
zlib/gzwrite.c \
zlib/infback.c \
zlib/inffast.c \
zlib/inflate.c \
zlib/inftrees.c \
zlib/trees.c \
zlib/uncompr.c \
zlib/zutil.c
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lGLESv2
LOCAL_CFLAGS := -I./../include/ -I./include/ -I.
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# AngelScript
ANGELSCRIPT_INCLUDE := /angelscript/include/
# -----------------------------------------------------
# Build the AngelScript library
# -----------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libangelscript
LOCAL_CPP_FEATURES += rtti exceptions
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/angelscript/source/*.S)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/angelscript/source/*.cpp)
LOCAL_PATH:=.
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_CPP_FEATURES += rtti
LOCAL_PATH := .
# ENET
LOCAL_SRC_FILES := $(wildcard jni/enet/*.c)
LOCAL_MODULE := enet
LOCAL_LDLIBS := -llog -landroid
LOCAL_CFLAGS := -DHAS_SOCKLEN_T -Ijni/ -Ijni/enet/include/
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
# ------------------------------------------------------------------
# Static library for Cocos
# ------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_PATH := jni/jpeglib/
LOCAL_MODULE := jpeglib
LOCAL_MODULE_FILENAME := libjpeg
LOCAL_SRC_FILES := \
jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \
jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \
jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \
jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \
jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c \
jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \
jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \
jquant2.c jutils.c jmemmgr.c jcarith.c jdarith.c jaricom.c
# Use the no backing store memory manager provided by
# libjpeg. See install.txt
LOCAL_SRC_FILES += \
jmemnobs.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)
LOCAL_CPP_FEATURES += rtti
LOCAL_PATH := .
# glew
LOCAL_SRC_FILES := $(wildcard jni/glew/src/*.c)
LOCAL_MODULE := glew
LOCAL_LDLIBS := -llog -landroid
LOCAL_CFLAGS := -Ijni/glew/include
#include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_CPP_FEATURES += rtti
# Bullet
LOCAL_SRC_FILES := $(wildcard jni/bullet/src/*/*.cpp)
LOCAL_SRC_FILES += $(wildcard jni/bullet/src/*/*/*.cpp)
LOCAL_PATH:=.
LOCAL_MODULE := bullet
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lGLESv2
LOCAL_CFLAGS := -Ijni/bullet/src/ -I../include -I../../include
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_CPP_FEATURES += rtti
LOCAL_PATH:= jni
# Irrlicht
LOCAL_SRC_FILES := $(wildcard jni/irrlicht/source/Irrlicht/*.cpp) $(wildcard jni/irrlicht/source/Irrlicht/Android/*.cpp) jni/irrexample.cpp
LOCAL_PATH:=.
LOCAL_MODULE := irrlicht
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lGLESv2
LOCAL_CFLAGS := -Ijni/irrlicht/source/Irrlicht/ -Ijni/irrlicht/include/ -Ijni/jpeglib/ -Ijni/libpng/ -Ijni/ -Iinclude/ -I$(call my-dir)/../../sources/android/native_app_glue/ -DBUILD_OGLES2 -DNO_IRR_COMPILE_WITH_SOFTWARE_ -DNO_IRR_COMPILE_WITH_BURNINGSVIDEO_
LOCAL_STATIC_LIBRARIES := jpeglib png
$(warning I$(call my-dir)/../../sources/android/native_app_glue/)
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_PATH:= jni
LOCAL_MODULE := irrlicht2
LOCAL_SRC_FILES := main.c
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lGLESv2
LOCAL_CFLAGS := -I./jni/irrlicht/include/ -Ijni/irrlicht/source/Irrlicht/ -DNO_CURL -DHAS_SOCKLEN_T -DSUPERTUXKART_DATADIR=\"/sdcard/stk/\"
LOCAL_STATIC_LIBRARIES := android_native_app_glue #jpeg #libirrlicht jpeg png
#LOCAL_SHARED_LIBRARIES := jpeg
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)

View File

@ -0,0 +1,3 @@
APP_PLATFORM := android-21
APP_STL := gnustl_shared

1
android/jni/angelscript Symbolic link
View File

@ -0,0 +1 @@
../../lib/angelscript/

1
android/jni/bullet Symbolic link
View File

@ -0,0 +1 @@
../../lib/bullet/

1
android/jni/enet Symbolic link
View File

@ -0,0 +1 @@
../../lib/enet/

1
android/jni/glew Symbolic link
View File

@ -0,0 +1 @@
../../lib/glew

420
android/jni/irrexample.cpp Normal file
View File

@ -0,0 +1,420 @@
/** Example 008 SpecialFX
This tutorials describes how to do special effects. It shows how to use stencil
buffer shadows, the particle system, billboards, dynamic light, and the water
surface scene node.
We start like in some tutorials before. Please note that this time, the
'shadows' flag in createDevice() is set to true, for we want to have a dynamic
shadow casted from an animated character. If this example runs too slow,
set it to false. The Irrlicht Engine checks if your hardware doesn't support
the stencil buffer, and disables shadows by itself, but just in case the demo
runs slow on your hardware.
*/
#define _IRR_ANDROID_PLATFORM_
#include <irrlicht.h>
#ifndef _IRR_ANDROID_PLATFORM_
# include <iostream>
# include "driverChoice.h"
#else
# include "CAndroidAssetFileArchive.h"
# include <android/log.h>
# include <android_native_app_glue.h>
#include <assert.h>
#endif
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
#ifndef _IRR_ANDROID_PLATFORM_
int main()
#else
extern "C" void android_main2(struct android_app* app)
#endif
{
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "The value of 1 + 1 is %d", 1+1);
#ifdef _IRR_ANDROID_PLATFORM_
const bool shadows = false;
video::E_DRIVER_TYPE driverType=video::EDT_OGLES1;
#else
// ask if user would like shadows
char i;
printf("Please press 'y' if you want to use realtime shadows.\n");
std::cin >> i;
const bool shadows = (i == 'y');
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
{
#ifdef _IRR_ANDROID_PLATFORM_
return;
#else
return 1;
#endif
}
#endif
/*
Create device and exit if creation failed. We make the stencil flag
optional to avoid slow screen modes for runs without shadows.
*/
#ifdef _IRR_ANDROID_PLATFORM_
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "The value of 1 + 4 is %d", 1+1);
struct irr::SIrrlichtCreationParameters p;
p.DriverType = driverType;
// The android app object is needed by the irrlicht device.
p.PrivateData = app;
p.WindowSize = core::dimension2d<u32>(1280,800);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d %d", __LINE__, ((struct android_app *)(p.PrivateData))->window);
IrrlichtDevice *device = createDeviceEx(p);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
#else
IrrlichtDevice *device =
createDevice(driverType, core::dimension2d<u32>(640, 480),
16, false, shadows);
#endif
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
if (device == 0)
{
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
#ifdef _IRR_ANDROID_PLATFORM_
return;
#else
return 1; // could not create selected driver.
#endif
}
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::ISceneNode* node = 0;
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
/*
For our environment, we load a .3ds file. It is a small room I modelled
with Anim8or and exported into the 3ds format because the Irrlicht
Engine does not support the .an8 format. I am a very bad 3d graphic
artist, and so the texture mapping is not very nice in this model.
Luckily I am a better programmer than artist, and so the Irrlicht
Engine is able to create a cool texture mapping for me: Just use the
mesh manipulator and create a planar texture mapping for the mesh. If
you want to see the mapping I made with Anim8or, uncomment this line. I
also did not figure out how to set the material right in Anim8or, it
has a specular light color which I don't really like. I'll switch it
off too with this code.
*/
#ifdef _IRR_ANDROID_PLATFORM_
scene::IAnimatedMesh* mesh = smgr->getMesh("media/room.3ds");
#else
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/room.3ds");
#endif
if (mesh)
{
smgr->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.004f);
node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
//((scene::IAnimatedMeshSceneNode*)node)->addShadowVolumeSceneNode();
#ifdef _IRR_ANDROID_PLATFORM_
node->setMaterialTexture(0, driver->getTexture("media/wall.jpg"));
#else
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg"));
#endif
node->getMaterial(0).SpecularColor.set(0,0,0,0);
}
}
/*
Now, for the first special effect: Animated water. It works like this:
The WaterSurfaceSceneNode takes a mesh as input and makes it wave like
a water surface. And if we let this scene node use a nice material like
the EMT_REFLECTION_2_LAYER, it looks really cool. We are doing this
with the next few lines of code. As input mesh, we create a hill plane
mesh, without hills. But any other mesh could be used for this, you
could even use the room.3ds (which would look really strange) if you
want to.
*/
mesh = 0;//smgr->addHillPlaneMesh( "myHill",
// core::dimension2d<f32>(20,20),
// core::dimension2d<u32>(40,40), 0, 0,
// core::dimension2d<f32>(0,0),
// core::dimension2d<f32>(10,10));
if (mesh)
{
node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
if (node)
{
node->setPosition(core::vector3df(0,7,0));
#ifdef _IRR_ANDROID_PLATFORM_
node->setMaterialTexture(0, driver->getTexture("media/stones.jpg"));
node->setMaterialTexture(1, driver->getTexture("media/water.jpg"));
#else
node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg"));
node->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));
#endif
node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
}
}
/*
The second special effect is very basic, I bet you saw it already in
some Irrlicht Engine demos: A transparent billboard combined with a
dynamic light. We simply create a light scene node, let it fly around,
and to make it look more cool, we attach a billboard scene node to it.
*/
// create light
node = smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 800.0f);
if (node)
{
scene::ISceneNodeAnimator* anim = 0;
anim = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),250.0f);
node->addAnimator(anim);
anim->drop();
}
// attach billboard to light
node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
if (node)
{
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
#ifdef _IRR_ANDROID_PLATFORM_
node->setMaterialTexture(0, driver->getTexture("media/particlewhite.bmp"));
#else
node->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp"));
#endif
}
/*
Next we add a volumetric light node, which adds a glowing fake area light to
the scene. Like with the billboards and particle systems we also assign a
texture for the desired effect, though this time we'll use a texture animator
to create the illusion of a magical glowing area effect.
*/
/*scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1,
32, // Subdivisions on U axis
32, // Subdivisions on V axis
video::SColor(0, 255, 255, 255), // foot color
video::SColor(0, 0, 0, 0)); // tail color*/
/*if (n)
{
n->setScale(core::vector3df(56.0f, 56.0f, 56.0f));
n->setPosition(core::vector3df(-120,50,40));
// load textures for animation
core::array<video::ITexture*> textures;
for (s32 g=7; g > 0; --g)
{
core::stringc tmp;
#ifdef _IRR_ANDROID_PLATFORM_
tmp = "media/portal";
#else
tmp = "../../media/portal";
#endif
tmp += g;
tmp += ".bmp";
video::ITexture* t = driver->getTexture( tmp.c_str() );
textures.push_back(t);
}
// create texture animator
scene::ISceneNodeAnimator* glow = smgr->createTextureAnimator(textures, 150);
// add the animator
n->addAnimator(glow);
// drop the animator because it was created with a create() function
glow->drop();
}*/
/*
The next special effect is a lot more interesting: A particle system.
The particle system in the Irrlicht Engine is quite modular and
extensible, but yet easy to use. There is a particle system scene node
into which you can put a particle emitter, which makes particles come out
of nothing. These emitters are quite flexible and usually have lots of
parameters like direction, amount, and color of the particles they
create.
There are different emitters, for example a point emitter which lets
particles pop out at a fixed point. If the particle emitters available
in the engine are not enough for you, you can easily create your own
ones, you'll simply have to create a class derived from the
IParticleEmitter interface and attach it to the particle system using
setEmitter(). In this example we create a box particle emitter, which
creates particles randomly inside a box. The parameters define the box,
direction of the particles, minimal and maximal new particles per
second, color, and minimal and maximal lifetime of the particles.
Because only with emitters particle system would be a little bit
boring, there are particle affectors which modify particles while
they fly around. Affectors can be added to a particle system for
simulating additional effects like gravity or wind.
The particle affector we use in this example is an affector which
modifies the color of the particles: It lets them fade out. Like the
particle emitters, additional particle affectors can also be
implemented by you, simply derive a class from IParticleAffector and
add it with addAffector().
After we set a nice material to the particle system, we have a cool
looking camp fire. By adjusting material, texture, particle emitter,
and affector parameters, it is also easily possible to create smoke,
rain, explosions, snow, and so on.
*/
// create a particle system
scene::IParticleSystemSceneNode* ps =
smgr->addParticleSystemSceneNode(false);
if (ps)
{
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
core::vector3df(0.0f,0.06f,0.0f), // initial direction
80,100, // emit rate
video::SColor(0,255,255,255), // darkest color
video::SColor(0,255,255,255), // brightest color
800,2000,0, // min and max age, angle
core::dimension2df(10.f,10.f), // min size
core::dimension2df(20.f,20.f)); // max size
ps->setEmitter(em); // this grabs the emitter
em->drop(); // so we can drop it here without deleting it
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
ps->addAffector(paf); // same goes for the affector
paf->drop();
ps->setPosition(core::vector3df(-70,60,40));
ps->setScale(core::vector3df(2,2,2));
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
ps->setMaterialTexture(0, driver->getTexture("../../media/fire.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
}
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
/*
As our last special effect, we want a dynamic shadow be casted from an
animated character. For this we load a DirectX .x model and place it
into our world. For creating the shadow, we simply need to call
addShadowVolumeSceneNode(). The color of shadows is only adjustable
globally for all shadows, by calling ISceneManager::setShadowColor().
Voila, here is our dynamic shadow.
Because the character is a little bit too small for this scene, we make
it bigger using setScale(). And because the character is lighted by a
dynamic light, we need to normalize the normals to make the lighting on
it correct. This is always necessary if the scale of a dynamic lighted
model is not (1,1,1). Otherwise it would get too dark or too bright
because the normals will be scaled too.
*/
// add animated character
#ifdef _IRR_ANDROID_PLATFORM_
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
mesh = smgr->getMesh("media/dwarf.x");
assert(mesh);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
#else
mesh = smgr->getMesh("../../media/dwarf.x");
#endif
scene::IAnimatedMeshSceneNode* anode = 0;
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
anode = smgr->addAnimatedMeshSceneNode(mesh);
anode->setPosition(core::vector3df(-50,20,-60));
anode->setAnimationSpeed(15);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
// add shadow
//anode->addShadowVolumeSceneNode();
smgr->setShadowColor(video::SColor(150,0,0,0));
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
// make the model a little bit bigger and normalize its normals
// because of the scaling, for correct lighting
anode->setScale(core::vector3df(2,2,2));
anode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
/*
Finally we simply have to draw everything, that's all.
*/
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(-50,50,-150));
camera->setFarValue(10000.0f); // this increase a shadow visible range.
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
// disable mouse cursor
device->getCursorControl()->setVisible(false);
s32 lastFPS = -1;
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", __LINE__);
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);
smgr->drawAll();
driver->endScene();
const s32 fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - SpecialFX example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d", lastFPS);
}
device->drop();
#ifdef _IRR_ANDROID_PLATFORM_
return;
#else
return 0;
#endif
}
/*
**/

1
android/jni/irrlicht Symbolic link
View File

@ -0,0 +1 @@
../../lib/irrlicht/

1
android/jni/libpng Symbolic link
View File

@ -0,0 +1 @@
../../lib/libpng/

391
android/jni/main.c Normal file
View File

@ -0,0 +1,391 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//BEGIN_INCLUDE(all)
#include <jni.h>
#include <errno.h>
#include <dlfcn.h>
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <main.h>
#include <android/sensor.h>
#include <android/log.h>
#include <android_native_app_glue.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
void (*plug_set_window)(NativeWindowType);
void (*plug_set_width)(int);
void (*plug_set_height)(int);
void (*plug_main_loop_interation)(void);
void (*plug_android_main_2)(void*);
void (*plug_go_move)(int, int);
/**
* Our saved state data.
*/
struct saved_state {
float angle;
int32_t x;
int32_t y;
};
int android_height, android_width;
/**
* Shared state for our app.
*/
struct engine {
struct android_app* app;
ASensorManager* sensorManager;
const ASensor* accelerometerSensor;
ASensorEventQueue* sensorEventQueue;
int animating;
EGLDisplay display;
EGLSurface surface;
EGLContext context;
int32_t width;
int32_t height;
struct saved_state state;
};
#if 0
/**
* Initialize an EGL context for the current display.
*/
static int engine_init_display(struct engine* engine) {
// initialize OpenGL ES and EGL
/*
* Here specify the attributes of the desired configuration.
* Below, we select an EGLConfig with at least 8 bits per color
* component compatible with on-screen windows
*/
const EGLint attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_NONE
};
EGLint w, h, dummy, format;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
EGLContext context;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, 0, 0);
/* Here, the application chooses the configuration it desires. In this
* sample, we have a very simplified selection process, where we pick
* the first EGLConfig that matches our criteria */
eglChooseConfig(display, attribs, &config, 1, &numConfigs);
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
* As soon as we picked a EGLConfig, we can safely reconfigure the
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);
surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
context = eglCreateContext(display, config, NULL, NULL);
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
LOGW("Unable to eglMakeCurrent");
return -1;
}
eglQuerySurface(display, surface, EGL_WIDTH, &w);
eglQuerySurface(display, surface, EGL_HEIGHT, &h);
engine->display = display;
engine->context = context;
engine->surface = surface;
engine->width = w;
engine->height = h;
engine->state.angle = 0;
// Initialize GL state.
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
return 0;
}
#endif
/**
* Just the current frame in the display.
*/
static void engine_draw_frame(struct engine* engine) {
if (engine->display == NULL) {
// No display.
return;
}
// Just fill the screen with a color.
glClearColor(((float)engine->state.x)/engine->width, engine->state.angle,
((float)engine->state.y)/engine->height, 1);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(engine->display, engine->surface);
}
/**
* Tear down the EGL context currently associated with the display.
*/
static void engine_term_display(struct engine* engine) {
if (engine->display != EGL_NO_DISPLAY) {
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (engine->context != EGL_NO_CONTEXT) {
eglDestroyContext(engine->display, engine->context);
}
if (engine->surface != EGL_NO_SURFACE) {
eglDestroySurface(engine->display, engine->surface);
}
eglTerminate(engine->display);
}
engine->animating = 0;
engine->display = EGL_NO_DISPLAY;
engine->context = EGL_NO_CONTEXT;
engine->surface = EGL_NO_SURFACE;
}
/**
* Process the next input event.
*/
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
struct engine* engine = (struct engine*)app->userData;
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
int x = AMotionEvent_getX(event, 0);
int y = AMotionEvent_getY(event, 0);
int end = !(AKeyEvent_getAction(event) == AMOTION_EVENT_ACTION_UP);
if(x < 100) /* left */
{
plug_go_move(2, end);
}
else if(x > 700) /* right */
{
plug_go_move(3, end);
}
else if(y < 240) /* up */
{
plug_go_move(0, end);
}
else /* down */
{
plug_go_move(1, end);
}
LOGI("%d\n", AKeyEvent_getAction(event));
LOGI("up event: %d\n", AKeyEvent_getAction(event) == AMOTION_EVENT_ACTION_UP),
engine->animating = 1;
engine->state.x = AMotionEvent_getX(event, 0);
engine->state.y = AMotionEvent_getY(event, 0);
LOGI("%f", AMotionEvent_getX(event, 0));
return 1;
}
return 0;
}
/**
* Process the next main command.
*/
static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
struct engine* engine = (struct engine*)app->userData;
switch (cmd) {
case APP_CMD_SAVE_STATE:
// The system has asked us to save our current state. Do so.
engine->app->savedState = malloc(sizeof(struct saved_state));
*((struct saved_state*)engine->app->savedState) = engine->state;
engine->app->savedStateSize = sizeof(struct saved_state);
break;
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
if (engine->app->window != NULL) {
//__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d %d", __LINE__, app->window);
//plug_android_main_2(app);
/*LOGI("native: %d", engine->app->contentRect.left);*/
/* plug_set_width(1080);
plug_set_height(1920);
plug_set_window(engine->app->window);
plug_android_main_2 ();*/
}
engine->animating = 1;
break;
case APP_CMD_TERM_WINDOW:
// The window is being hidden or closed, clean it up.
engine_term_display(engine);
break;
case APP_CMD_GAINED_FOCUS:
// When our app gains focus, we start monitoring the accelerometer.
if (engine->accelerometerSensor != NULL) {
ASensorEventQueue_enableSensor(engine->sensorEventQueue,
engine->accelerometerSensor);
// We'd like to get 60 events per second (in us).
ASensorEventQueue_setEventRate(engine->sensorEventQueue,
engine->accelerometerSensor, (1000L/60)*1000);
}
break;
case APP_CMD_LOST_FOCUS:
// When our app loses focus, we stop monitoring the accelerometer.
// This is to avoid consuming battery while not being used.
if (engine->accelerometerSensor != NULL) {
ASensorEventQueue_disableSensor(engine->sensorEventQueue,
engine->accelerometerSensor);
}
// Also stop animating.
engine->animating = 0;
engine_draw_frame(engine);
break;
case APP_CMD_CONTENT_RECT_CHANGED:
LOGI("RESIZED");
LOGI("%d\n", ANativeWindow_getWidth(engine->app->window));
break;
}
}
/**
* This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own
* event loop for receiving input events and doing other things.
*/
void android_main(struct android_app* state) {
struct engine engine;
void * dlhandle = NULL;
void * dlstk = NULL;
/*dlstk = dlopen("/data/data/com.example.native_activity/lib/libjpeg.so", RTLD_NOW);*/
dlhandle = dlopen("/data/data/org.supertuxkart.stk/lib/libgnustl_shared.so", RTLD_NOW);
dlhandle = dlopen("/data/data/org.supertuxkart.stk/lib/libirrlicht.so", RTLD_NOW);
/*dlstk = dlopen("/data/data/com.example.native_activity/lib/libenet.so", RTLD_NOW);
dlstk = dlopen("/data/data/com.example.native_activity/lib/libbullet.so", RTLD_NOW);
dlstk = dlopen("/data/data/com.example.native_activity/lib/libstk.so", RTLD_NOW);*/
dlstk = dlopen("/data/data/org.supertuxkart.stk/lib/libenet.so", RTLD_NOW);
dlstk = dlopen("/data/data/org.supertuxkart.stk/lib/libbullet.so", RTLD_NOW);
//dlstk = dlopen("/data/data/org.supertuxkart.stk/lib/libstkmain.so", RTLD_NOW);
if(dlhandle == NULL)
LOGW("Can't open libirrlicht.so. %s", dlerror());
if(dlstk == NULL)
LOGW("Can't open libstkmain.so. %s", dlerror());
//plug_main_loop_interation = (void(*)(void))dlsym(dlstk, "main_loop_interation");
//if(plug_main_loop_interation == NULL)
// LOGW("Can't open plug_main_loop");
plug_android_main_2 = (void(*)(void))dlsym(dlhandle, "android_main2");
LOGW("----------------------------------------------------------- lanchit");
app_dummy();
__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", "frame %d %d", __LINE__, ((struct android_app *)(state))->window);
//plug_android_main_2(state);
plug_android_main_2(state);
/*if(plug_android_main_2 == NULL)
LOGW("Can't open plug_android_main_2");*/
/*plug_set_window = (void(*)(void))dlsym(dlhandle, "set_android_window");
if(plug_set_window == NULL)
LOGW("Can't open plug_set_window");*/
/*plug_set_width = (void(*)(void))dlsym(dlhandle, "set_android_window_width");
plug_set_height = (void(*)(void))dlsym(dlhandle, "set_android_window_height");
plug_go_move = (void(*)(int,int))dlsym(dlstk, "go_move");*/
// Make sure glue isn't stripped.
memset(&engine, 0, sizeof(engine));
state->userData = &engine;
state->onAppCmd = engine_handle_cmd;
state->onInputEvent = engine_handle_input;
engine.app = state;
// Prepare to monitor accelerometer
engine.sensorManager = ASensorManager_getInstance();
engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
ASENSOR_TYPE_ACCELEROMETER);
engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager,
state->looper, LOOPER_ID_USER, NULL, NULL);
if (state->savedState != NULL) {
// We are starting with a previous saved state; restore from it.
engine.state = *(struct saved_state*)state->savedState;
}
// loop waiting for stuff to do.
int i = 0;
while (1) {
i++;
// Read all pending events.
int ident;
int events;
struct android_poll_source* source;
// If not animating, we will block forever waiting for events.
// If animating, we loop until all events are read, then continue
// to draw the next frame of animation.
while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events,
(void**)&source)) >= 0) {
// Process this event.
if (source != NULL) {
source->process(state, source);
}
// If a sensor has data, process it now.
if (ident == LOOPER_ID_USER) {
if (engine.accelerometerSensor != NULL) {
ASensorEvent event;
while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
&event, 1) > 0) {
LOGI("accelerometer: x=%f y=%f z=%f",
event.acceleration.x, event.acceleration.y,
event.acceleration.z);
}
}
}
// Check if we are exiting.
if (state->destroyRequested != 0) {
engine_term_display(&engine);
return;
}
}
// LOGI("frame");
//plug_main_loop_interation();
if (engine.animating) {
// Done with events; draw next animation frame.
engine.state.angle += .01f;
if (engine.state.angle > 1) {
engine.state.angle = 0;
}
// Drawing is throttled to the screen update rate, so there
// is no need to do timing here.
}
if(i > 60000)
exit(0);
}
}
//END_INCLUDE(all)

171
android/jni/main.cpp Normal file
View File

@ -0,0 +1,171 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//BEGIN_INCLUDE(all)
#include <jni.h>
#include <errno.h>
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <android/sensor.h>
#include <android/log.h>
#include <android_native_app_glue.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
#include <irrlicht.h>
/*
In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if
you want to use a class of the engine, you have to write irr:: before the name
of the class. For example to use the IrrlichtDevice write: irr::IrrlichtDevice.
To get rid of the irr:: in front of the name of every class, we tell the
compiler that we use that namespace from now on, and we will not have to write
irr:: anymore.
*/
using namespace irr;
/*
There are 5 sub namespaces in the Irrlicht Engine. Take a look at them, you can
read a detailed description of them in the documentation by clicking on the top
menu item 'Namespace List' or by using this link:
http://irrlicht.sourceforge.net/docu/namespaces.html
Like the irr namespace, we do not want these 5 sub namespaces now, to keep this
example simple. Hence, we tell the compiler again that we do not want always to
write their names.
*/
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/**
* This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own
* event loop for receiving input events and doing other things.
*/
void android_main_2() {
/*
The most important function of the engine is the createDevice()
function. The IrrlichtDevice is created by it, which is the root
object for doing anything with the engine. createDevice() has 7
parameters:
- deviceType: Type of the device. This can currently be the Null-device,
one of the two software renderers, D3D8, D3D9, or OpenGL. In this
example we use EDT_SOFTWARE, but to try out, you might want to
change it to EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8,
EDT_DIRECT3D9, or EDT_OPENGL.
- windowSize: Size of the Window or screen in FullScreenMode to be
created. In this example we use 640x480.
- bits: Amount of color bits per pixel. This should be 16 or 32. The
parameter is often ignored when running in windowed mode.
- fullscreen: Specifies if we want the device to run in fullscreen mode
or not.
- stencilbuffer: Specifies if we want to use the stencil buffer (for
drawing shadows).
- vsync: Specifies if we want to have vsync enabled, this is only useful
in fullscreen mode.
- eventReceiver: An object to receive events. We do not want to use this
parameter here, and set it to 0.
Always check the return value to cope with unsupported drivers,
dimensions, etc.
*/
IrrlichtDevice *device =
createDevice( video::EDT_OGLES1, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
if (!device)
return ;
/*
Set the caption of the window to some nice text. Note that there is an
'L' in front of the string. The Irrlicht Engine uses wide character
strings when displaying text.
*/
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
/*
Get a pointer to the VideoDriver, the SceneManager and the graphical
user interface environment, so that we do not always have to write
device->getVideoDriver(), device->getSceneManager(), or
device->getGUIEnvironment().
*/
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
/*
We add a hello world label to the window, using the GUI environment.
The text is placed at the position (10,10) as top left corner and
(260,22) as lower right corner.
*/
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
/*
To look at the mesh, we place a camera into 3d space at the position
(0, 30, -40). The camera looks from there to (0,5,0), which is
approximately the place where our md2 model is.
*/
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
/*
Ok, now we have set up the scene, lets draw everything: We run the
device in a while() loop, until the device does not want to run any
more. This would be when the user closes the window or presses ALT+F4
(or whatever keycode closes a window).
*/
while(device->run())
{
/*
Anything can be drawn between a beginScene() and an endScene()
call. The beginScene() call clears the screen with a color and
the depth buffer, if desired. Then we let the Scene Manager and
the GUI Environment draw their content. With the endScene()
call everything is presented on the screen.
*/
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
/*
After we are done with the render loop, we have to delete the Irrlicht
Device created before with createDevice(). In the Irrlicht Engine, you
have to delete all objects you created with a method or function which
starts with 'create'. The object is simply deleted by calling ->drop().
See the documentation at irr::IReferenceCounted::drop() for more
information.
*/
device->drop();
}
//END_INCLUDE(all)

2
android/jni/main.h Normal file
View File

@ -0,0 +1,2 @@
void main_loop_interation();
void android_main_2();

84
android/jni/main2.cpp Normal file
View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//BEGIN_INCLUDE(all)
#include <jni.h>
#include <errno.h>
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <android/sensor.h>
#include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
#include <irrlicht.h>
#include <android/log.h>
#include "main_loop.hpp"
/*
In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if
you want to use a class of the engine, you have to write irr:: before the name
of the class. For example to use the IrrlichtDevice write: irr::IrrlichtDevice.
To get rid of the irr:: in front of the name of every class, we tell the
compiler that we use that namespace from now on, and we will not have to write
irr:: anymore.
*/
using namespace irr;
/*
There are 5 sub namespaces in the Irrlicht Engine. Take a look at them, you can
read a detailed description of them in the documentation by clicking on the top
menu item 'Namespace List' or by using this link:
http://irrlicht.sourceforge.net/docu/namespaces.html
Like the irr namespace, we do not want these 5 sub namespaces now, to keep this
example simple. Hence, we tell the compiler again that we do not want always to
write their names.
*/
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#define T __android_log_print(ANDROID_LOG_DEBUG, "L", "%s, %d: %s", __FILE__, __LINE__, __FUNCTION__);
int main2(int argc, char *argv[] );
/**
* This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own
* event loop for receiving input events and doing other things.
*/
static IrrlichtDevice *device;
static IVideoDriver* driver;
static ISceneManager* smgr;
static IGUIEnvironment* guienv;
extern int android_height, android_width;
extern "C" void android_main_2() {
LOGI("android");
main2(0, NULL);
LOGI("end main");
}
static bool first_run = true;
extern "C" void main_loop_interation(){
LOGI("Iteration");
if(first_run) main_loop->firstRun();
first_run = false;
main_loop->doIteration();
}
//END_INCLUDE(all)

506
android/jni/zconf.h Normal file
View File

@ -0,0 +1,506 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2012 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef ZCONF_H
#define ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
* Even better than compiling with -DZ_PREFIX would be to use configure to set
* this permanently in zconf.h using "./configure --zprefix".
*/
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
# define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block
# define _tr_tally z__tr_tally
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# endif
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset
# define deflateResetKeep z_deflateResetKeep
# define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table
# ifndef Z_SOLO
# define gz_error z_gz_error
# define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr
# define gzclose z_gzclose
# define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect
# define gzdopen z_gzdopen
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
# define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64
# define gzopen z_gzopen
# define gzopen64 z_gzopen64
# ifdef _WIN32
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
# define gzrewind z_gzrewind
# define gzseek z_gzseek
# define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define inflateBackInit_ z_inflateBackInit_
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
# define inflateGetHeader z_inflateGetHeader
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
# define inflateResetKeep z_inflateResetKeep
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
# endif
# define zError z_zError
# ifndef Z_SOLO
# define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion
/* all zlib typedefs in zlib.h and zconf.h */
# define Byte z_Byte
# define Bytef z_Bytef
# define alloc_func z_alloc_func
# define charf z_charf
# define free_func z_free_func
# ifndef Z_SOLO
# define gzFile z_gzFile
# endif
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# define in_func z_in_func
# define intf z_intf
# define out_func z_out_func
# define uInt z_uInt
# define uIntf z_uIntf
# define uLong z_uLong
# define uLongf z_uLongf
# define voidp z_voidp
# define voidpc z_voidpc
# define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s
# define internal_state z_internal_state
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# endif
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
#else
# define z_const
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
#ifndef Z_ARG /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define Z_ARG(args) args
# else
# define Z_ARG(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
/* ./configure may #define Z_U4 here */
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
# else
# if (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long
# else
# if (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short
# endif
# endif
# endif
#endif
#ifdef Z_U4
typedef Z_U4 z_crc_t;
#else
typedef unsigned long z_crc_t;
#endif
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H
#endif
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H
#endif
#ifdef STDC
# ifndef Z_SOLO
# include <sys/types.h> /* for off_t */
# endif
#endif
#ifdef _WIN32
# include <stddef.h> /* for wchar_t */
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations
*/
#if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
# define Z_HAVE_UNISTD_H
#endif
#ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# ifndef z_off_t
# define z_off_t off_t
# endif
# endif
#endif
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
# define Z_LFS64
#endif
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
# define Z_LARGE64
#endif
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
# define Z_WANT64
#endif
#if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
#else
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
# define z_off64_t __int64
# else
# define z_off64_t z_off_t
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
#pragma map(deflateInit_,"DEIN")
#pragma map(deflateInit2_,"DEIN2")
#pragma map(deflateEnd,"DEEND")
#pragma map(deflateBound,"DEBND")
#pragma map(inflateInit_,"ININ")
#pragma map(inflateInit2_,"ININ2")
#pragma map(inflateEnd,"INEND")
#pragma map(inflateSync,"INSY")
#pragma map(inflateSetDictionary,"INSEDI")
#pragma map(compressBound,"CMBND")
#pragma map(inflate_table,"INTABL")
#pragma map(inflate_fast,"INFA")
#pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

1
android/jni/zlib Symbolic link
View File

@ -0,0 +1 @@
../../lib/zlib/

10
android/local.properties Normal file
View File

@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/opt/android-sdk/

40
android/proguard.cfg Normal file
View File

@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

View File

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-22

17
android/readme.android Normal file
View File

@ -0,0 +1,17 @@
First, download and extract the ndk android-ndk-r10e to this folder (i.e. android/android-ndk-r10e/).
The android sdk must be installed in /opt.
ant is also needed.
Download a suitable jpeglib
===========================
> git clone https://github.com/folecr/jpeg8d jni/jpeglib
Build an apk
============
> make build apk
Install and run
===============
> make install run

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SuperTuxKart</string>
</resources>