mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Allow overriding the main entry point on Android
This commit is contained in:
parent
dbb0a2aa74
commit
60182eb71b
@ -73,6 +73,29 @@ public class SDLActivity extends Activity {
|
|||||||
protected static AudioTrack mAudioTrack;
|
protected static AudioTrack mAudioTrack;
|
||||||
protected static AudioRecord mAudioRecord;
|
protected static AudioRecord mAudioRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the name of the shared object with the application entry point
|
||||||
|
* It can be overridden by derived classes.
|
||||||
|
*/
|
||||||
|
protected String getMainSharedObject() {
|
||||||
|
String library;
|
||||||
|
String[] libraries = SDLActivity.mSingleton.getLibraries();
|
||||||
|
if (libraries.length > 0) {
|
||||||
|
library = "lib" + libraries[libraries.length - 1] + ".so";
|
||||||
|
} else {
|
||||||
|
library = "libmain.so";
|
||||||
|
}
|
||||||
|
return library;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the name of the application entry point
|
||||||
|
* It can be overridden by derived classes.
|
||||||
|
*/
|
||||||
|
protected String getMainFunction() {
|
||||||
|
return "SDL_main";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by SDL before loading the native shared libraries.
|
* This method is called by SDL before loading the native shared libraries.
|
||||||
* It can be overridden to provide names of shared libraries to be loaded.
|
* It can be overridden to provide names of shared libraries to be loaded.
|
||||||
@ -1218,17 +1241,12 @@ class SDLMain implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Runs SDL_main()
|
// Runs SDL_main()
|
||||||
String library;
|
String library = SDLActivity.mSingleton.getMainSharedObject();
|
||||||
String[] libraries = SDLActivity.mSingleton.getLibraries();
|
String function = SDLActivity.mSingleton.getMainFunction();
|
||||||
if (libraries.length > 0) {
|
String[] arguments = SDLActivity.mSingleton.getArguments();
|
||||||
library = "lib" + libraries[libraries.length - 1] + ".so";
|
|
||||||
} else {
|
|
||||||
library = "libmain.so";
|
|
||||||
}
|
|
||||||
String function = "SDL_main";
|
|
||||||
|
|
||||||
Log.v("SDL", "Running main function " + function + " from library " + library);
|
Log.v("SDL", "Running main function " + function + " from library " + library);
|
||||||
SDLActivity.nativeRunMain(library, function, SDLActivity.mSingleton.getArguments());
|
SDLActivity.nativeRunMain(library, function, arguments);
|
||||||
|
|
||||||
Log.v("SDL", "Finished main function");
|
Log.v("SDL", "Finished main function");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user