project_files/Android-build/SDL-android-project/jni/src/hedgewars_main.c
author Xeli
Wed, 22 Jun 2011 23:59:01 +0200
branchhedgeroid
changeset 5304 e29aa9e29f00
child 5350 4c100fbfad5f
permissions -rw-r--r--
Added SDL-android-project, this is the Android/Java part of the application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5304
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     1
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     2
#include "android/log.h"
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     3
#include "SDL.h"
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     4
#include "dlfcn.h"
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     5
#include "GLES/gl.h"
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     6
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     7
#define TAG "HWEngine Loader"
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     8
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
     9
typedef  (*HWEngine_Game)(int);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    10
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    11
main(int argc, char *argv[]){
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    12
	void *handle;
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    13
	char *error;
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    14
	HWEngine_Game Game;
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    15
	
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    16
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    17
        __android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine being loaded");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    18
	handle = dlopen("/data/data/org.hedgewars/lib/libhwengine.so", RTLD_NOW|RTLD_GLOBAL);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    19
	if(!handle){
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    20
		__android_log_print(ANDROID_LOG_INFO, "foo", dlerror());
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    21
		__android_log_print(ANDROID_LOG_INFO, "foo", "error dlopen");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    22
		exit(EXIT_FAILURE);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    23
	}
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    24
	dlerror();
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    25
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    26
        __android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine successfully loaded..");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    27
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    28
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    29
	Game = (HWEngine_Game) dlsym(handle,"Game");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    30
	if((error = dlerror()) != NULL){
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    31
		__android_log_print(ANDROID_LOG_INFO, "foo", error);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    32
		__android_log_print(ANDROID_LOG_INFO, "foo", "error dlsym");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    33
		exit(EXIT_FAILURE);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    34
	}
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    35
	__android_log_print(ANDROID_LOG_INFO, "foo", "dlsym succeeded");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    36
	Game(1);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    37
	__android_log_print(ANDROID_LOG_INFO, "foo", "Game() succeeded");
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    38
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    39
	dlclose(handle);
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    40
}