project_files/Android-build/SDL-android-project/jni/src/hedgewars_main.c
author unC0Rr
Mon, 13 Feb 2023 11:00:12 +0100
branchtransitional_engine
changeset 15921 5f00829c55ec
parent 10017 de822cd3df3a
permissions -rw-r--r--
Refactor landgen package structure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    13
    void *handle;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    14
    char *error;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    15
    HWEngine_Game Game;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    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
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    19
    handle = dlopen("libhwengine.so", RTLD_NOW|RTLD_GLOBAL);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    20
    if(!handle){
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    21
        __android_log_print(ANDROID_LOG_INFO, TAG, dlerror());
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    22
        __android_log_print(ANDROID_LOG_INFO, TAG, "error dlopen");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    23
        exit(EXIT_FAILURE);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    24
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    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
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    30
    Game = (HWEngine_Game) dlsym(handle,"Game");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    31
    if((error = dlerror()) != NULL){
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    32
        __android_log_print(ANDROID_LOG_INFO, TAG, error);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    33
        __android_log_print(ANDROID_LOG_INFO, TAG, "error dlsym");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    34
        exit(EXIT_FAILURE);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    35
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    36
    __android_log_print(ANDROID_LOG_INFO, TAG, "dlsym succeeded");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    37
    Game(argc, argv);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    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
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 8465
diff changeset
    40
    dlclose(handle);
5304
e29aa9e29f00 Added SDL-android-project, this is the Android/Java part of the application
Xeli
parents:
diff changeset
    41
}