src/main/android/SDL_android_main.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sat, 06 Sep 2014 23:20:14 +0200
changeset 9125 e004bdb812ce
parent 9006 98c808d72e20
child 9171 3464a9bda1e2
permissions -rw-r--r--
Fixed example in header file.

Did not compile because of typo in function name and missing argument.
slouken@8616
     1
/*
slouken@8616
     2
    SDL_android_main.c, placed in the public domain by Sam Lantinga  3/13/14
slouken@8616
     3
*/
icculus@8093
     4
#include "../../SDL_internal.h"
slouken@6044
     5
slouken@6044
     6
#ifdef __ANDROID__
slouken@4964
     7
slouken@4964
     8
/* Include the SDL main definition header */
slouken@4964
     9
#include "SDL_main.h"
slouken@4964
    10
slouken@4964
    11
/*******************************************************************************
slouken@4964
    12
                 Functions called by JNI
slouken@4964
    13
*******************************************************************************/
slouken@4964
    14
#include <jni.h>
slouken@4964
    15
gabomdq@7663
    16
/* Called before SDL_main() to initialize JNI bindings in SDL library */
ewing@7501
    17
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
slouken@4964
    18
gabomdq@7663
    19
/* Start up the SDL app */
philipp@8694
    20
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
slouken@4964
    21
{
slouken@4964
    22
    /* This interface could expand with ABI negotiation, calbacks, etc. */
slouken@4998
    23
    SDL_Android_Init(env, cls);
slouken@4964
    24
slouken@7281
    25
    SDL_SetMainReady();
slouken@7281
    26
slouken@4964
    27
    /* Run the application code! */
slouken@9006
    28
    /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
slouken@9006
    29
       https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
slouken@9006
    30
     */
slouken@4999
    31
    int status;
slouken@4964
    32
    char *argv[2];
slouken@9006
    33
    argv[0] = SDL_strdup("app_process");
slouken@4964
    34
    argv[1] = NULL;
slouken@4999
    35
    status = SDL_main(1, argv);
slouken@4999
    36
slouken@6186
    37
    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
gabomdq@7678
    38
    /* exit(status); */
philipp@8694
    39
philipp@8694
    40
    return status;
slouken@4964
    41
}
slouken@4999
    42
slouken@6044
    43
#endif /* __ANDROID__ */
slouken@6044
    44
slouken@4999
    45
/* vi: set ts=4 sw=4 expandtab: */