author | Wuzzy <Wuzzy2@mail.ru> |
Sun, 07 Apr 2019 19:26:16 +0200 | |
changeset 14755 | ab7bf5036314 |
parent 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
8465
9114b50fed82
Fix Hedgeroid argc/argv parameter passing to the engine
Medo <smaxein@googlemail.com>
parents:
5934
diff
changeset
|
1 |
#include<stdint.h> |
5304
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
2 |
|
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
3 |
#include "android/log.h" |
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
4 |
#include "SDL.h" |
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
5 |
#include "dlfcn.h" |
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
6 |
#include "GLES/gl.h" |
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
7 |
|
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
8 |
#define TAG "HWEngine Loader" |
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
9 |
|
8465
9114b50fed82
Fix Hedgeroid argc/argv parameter passing to the engine
Medo <smaxein@googlemail.com>
parents:
5934
diff
changeset
|
10 |
typedef (*HWEngine_Game)(int32_t argc, char** argv); |
5304
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
11 |
|
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
12 |
main(int argc, char *argv[]){ |
10017 | 13 |
void *handle; |
14 |
char *error; |
|
15 |
HWEngine_Game Game; |
|
16 |
||
5304
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
17 |
|
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
18 |
__android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine being loaded"); |
10017 | 19 |
handle = dlopen("libhwengine.so", RTLD_NOW|RTLD_GLOBAL); |
20 |
if(!handle){ |
|
21 |
__android_log_print(ANDROID_LOG_INFO, TAG, dlerror()); |
|
22 |
__android_log_print(ANDROID_LOG_INFO, TAG, "error dlopen"); |
|
23 |
exit(EXIT_FAILURE); |
|
24 |
} |
|
25 |
dlerror(); |
|
5304
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
26 |
|
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
27 |
__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
|
28 |
|
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
29 |
|
10017 | 30 |
Game = (HWEngine_Game) dlsym(handle,"Game"); |
31 |
if((error = dlerror()) != NULL){ |
|
32 |
__android_log_print(ANDROID_LOG_INFO, TAG, error); |
|
33 |
__android_log_print(ANDROID_LOG_INFO, TAG, "error dlsym"); |
|
34 |
exit(EXIT_FAILURE); |
|
35 |
} |
|
36 |
__android_log_print(ANDROID_LOG_INFO, TAG, "dlsym succeeded"); |
|
37 |
Game(argc, argv); |
|
38 |
__android_log_print(ANDROID_LOG_INFO, TAG, "Game() ended"); |
|
5304
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
39 |
|
10017 | 40 |
dlclose(handle); |
5304
e29aa9e29f00
Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff
changeset
|
41 |
} |