project_files/Android-build/SDL-android-project/jni/src/hedgewars_main.c
author Xeli
Tue, 28 Jun 2011 17:54:27 +0200
branchhedgeroid
changeset 5369 0ce1ef75c08f
parent 5350 4c100fbfad5f
child 5934 9f05a0f43003
permissions -rw-r--r--
Removed absolute path to libhwengine.so, the library must be preloaded from Java now. Which automagically knows where libhwengine.so is!


#include "android/log.h"
#include "SDL.h"
#include "dlfcn.h"
#include "GLES/gl.h"

#define TAG "HWEngine Loader"

typedef  (*HWEngine_Game)(char**);

main(int argc, char *argv[]){
	void *handle;
	char *error;
	HWEngine_Game Game;
	

        __android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine being loaded");
	handle = dlopen("libhwengine.so", RTLD_NOW|RTLD_GLOBAL);
	if(!handle){
		__android_log_print(ANDROID_LOG_INFO, "foo", dlerror());
		__android_log_print(ANDROID_LOG_INFO, "foo", "error dlopen");
		exit(EXIT_FAILURE);
	}
	dlerror();

        __android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine successfully loaded..");


	Game = (HWEngine_Game) dlsym(handle,"Game");
	if((error = dlerror()) != NULL){
		__android_log_print(ANDROID_LOG_INFO, "foo", error);
		__android_log_print(ANDROID_LOG_INFO, "foo", "error dlsym");
		exit(EXIT_FAILURE);
	}
	__android_log_print(ANDROID_LOG_INFO, "foo", "dlsym succeeded");
	Game(argv);
	__android_log_print(ANDROID_LOG_INFO, "foo", "Game() succeeded");

	dlclose(handle);
}