project_files/Android-build/SDL-android-project/jni/src/hedgewars_main.c
author Xeli
Thu, 14 Jul 2011 15:58:08 +0200
branchhedgeroid
changeset 5435 d060bfb6f670
parent 5369 0ce1ef75c08f
child 5934 9f05a0f43003
permissions -rw-r--r--
added startlocalgame activity
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
5350
4c100fbfad5f Fixed a fault strcpy
Xeli
parents: 5304
diff changeset
     9
typedef  (*HWEngine_Game)(char**);
5304
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");
5369
0ce1ef75c08f Removed absolute path to libhwengine.so, the library must be preloaded from Java now. Which automagically knows where libhwengine.so is!
Xeli
parents: 5350
diff changeset
    18
	handle = dlopen("libhwengine.so", RTLD_NOW|RTLD_GLOBAL);
5304
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");
5350
4c100fbfad5f Fixed a fault strcpy
Xeli
parents: 5304
diff changeset
    36
	Game(argv);
5304
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
}