Пример #1
0
static void
petalsredux_init(struct SupportModule *self, int width, int height, const char *home)
{
    self->priv->JNI_OnLoad(VM_M, NULL);

    GLOBAL_M->module_hacks->current_orientation = ORIENTATION_PORTRAIT;

    self->priv->native_start = jnienv_find_native_method(NULL, "nativeStart");
    self->priv->native_pause = jnienv_find_native_method(NULL, "nativePause");
    self->priv->native_resume = jnienv_find_native_method(NULL, "nativeResume");
    self->priv->native_back = jnienv_find_native_method(NULL, "nativeBack");
    self->priv->native_init = jnienv_find_native_method(NULL, "nativeInit");
    self->priv->native_resize = jnienv_find_native_method(NULL, "nativeResize");
    self->priv->native_render = jnienv_find_native_method(NULL, "nativeRender");
    self->priv->native_touch = jnienv_find_native_method(NULL, "nativeTouch");
    self->priv->native_mix = jnienv_find_native_method(NULL, "nativeMix");

    const char *locale = getenv("LANG");
    if (!locale) {
        locale = getenv("LC_MESSAGES");
    }
    if (!locale) {
        locale = getenv("LC_ALL");
    }

    jstring jhome = (*ENV_M)->NewStringUTF(ENV_M, home);
    jstring jlocale = (*ENV_M)->NewStringUTF(ENV_M, locale);

    self->priv->native_start(ENV_M, GLOBAL_M, jhome, jlocale);
    self->priv->native_init(ENV_M, GLOBAL_M);
    self->priv->native_resize(ENV_M, GLOBAL_M, width, height);

    int freq = 44100;
    enum AudioFormat format = AudioFormat_S16SYS;
    apkenv_audio_open(freq, 1, format, freq / 8, mix_audio, self);
    apkenv_audio_play();
}
Пример #2
0
static void
unity_init(struct SupportModule *self, int width, int height, const char *home)
{
    global = GLOBAL_M;

    system("export MALLOC_CHECK_=0"); //<unit? or who? does something weird on the pandora ...

    MODULE_DEBUG_PRINTF("JNI_OnLoad\n");
    self->priv->JNI_OnLoad_libunity(VM_M,0);
    MODULE_DEBUG_PRINTF("JNI_OnLoad done.\n");

    self->priv->nativeInit = jnienv_find_native_method(UNITYPLAYER_CLASS_NAME, "nativeInit");
    self->priv->nativeFile = jnienv_find_native_method(UNITYPLAYER_CLASS_NAME, "nativeFile");
    self->priv->nativeRender = jnienv_find_native_method(UNITYPLAYER_CLASS_NAME, "nativeRender");
    self->priv->initJni = jnienv_find_native_method(UNITYPLAYER_CLASS_NAME, "initJni");
    self->priv->unityAndroidInit = jnienv_find_native_method(UNITYPLAYER_CLASS_NAME, "unityAndroidInit");
    self->priv->unityAndroidPrepareGameLoop = jnienv_find_native_method(UNITYPLAYER_CLASS_NAME, "unityAndroidPrepareGameLoop");
    self->priv->InitPlayerPrefs = jnienv_find_native_method(PLAYERPREFS_CLASS_NAME, "InitPlayerPrefs");

    MODULE_DEBUG_PRINTF("nativeInit\n");
    self->priv->nativeInit(ENV_M,GLOBAL_M,width,height);
    MODULE_DEBUG_PRINTF("nativeInit done\n");

    MODULE_DEBUG_PRINTF("unityAndroidInit\n");
    jstring bin = GLOBAL_M->env->NewStringUTF(ENV_M,"assets/bin/");
    jstring lib = GLOBAL_M->env->NewStringUTF(ENV_M,"./lib/");//strcat(home,"lib/"));
    self->priv->unityAndroidInit(ENV_M,GLOBAL_M,bin,lib);
    MODULE_DEBUG_PRINTF("unityAndroidInitDone\n");


    MODULE_DEBUG_PRINTF("nativeFile\n");
    jstring file = GLOBAL_M->env->NewStringUTF(ENV_M,global->apk_filename);
    self->priv->nativeFile(ENV_M,GLOBAL_M,file);
    MODULE_DEBUG_PRINTF("nativeFile done\n");

}