85 lines
2.8 KiB
C++
85 lines
2.8 KiB
C++
/*
|
|
* 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)
|