SDL  2.0
org.libsdl.app.SDL Class Reference
+ Collaboration diagram for org.libsdl.app.SDL:

Static Public Member Functions

static void setupJNI ()
 
static void initialize ()
 
static void setContext (Context context)
 
static Context getContext ()
 
static void loadLibrary (String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException
 

Static Protected Attributes

static Context mContext
 

Detailed Description

SDL library initialization

Definition at line 10 of file SDL.java.

Member Function Documentation

◆ getContext()

◆ initialize()

static void org.libsdl.app.SDL.initialize ( )
inlinestatic

Definition at line 21 of file SDL.java.

References org.libsdl.app.SDLAudioManager.initialize(), org.libsdl.app.SDLControllerManager.initialize(), org.libsdl.app.SDLActivity.initialize(), and org.libsdl.app.SDL.setContext().

Referenced by org.libsdl.app.SDLActivity.onCreate().

21  {
22  setContext(null);
23 
24  SDLActivity.initialize();
25  SDLAudioManager.initialize();
26  SDLControllerManager.initialize();
27  }
static void setContext(Context context)
Definition: SDL.java:30

◆ loadLibrary()

static void org.libsdl.app.SDL.loadLibrary ( String  libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException
inlinestatic

Definition at line 38 of file SDL.java.

References e, and org.libsdl.app.SDL.mContext.

Referenced by org.libsdl.app.HIDDeviceManager.HIDDeviceManager(), and org.libsdl.app.SDLActivity.loadLibraries().

38  {
39 
40  if (libraryName == null) {
41  throw new NullPointerException("No library name provided.");
42  }
43 
44  try {
45  // Let's see if we have ReLinker available in the project. This is necessary for
46  // some projects that have huge numbers of local libraries bundled, and thus may
47  // trip a bug in Android's native library loader which ReLinker works around. (If
48  // loadLibrary works properly, ReLinker will simply use the normal Android method
49  // internally.)
50  //
51  // To use ReLinker, just add it as a dependency. For more information, see
52  // https://github.com/KeepSafe/ReLinker for ReLinker's repository.
53  //
54  Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
55  Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
56  Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
57  Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
58 
59  // Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
60  // they've changed during updates.
61  Method forceMethod = relinkClass.getDeclaredMethod("force");
62  Object relinkInstance = forceMethod.invoke(null);
63  Class relinkInstanceClass = relinkInstance.getClass();
64 
65  // Actually load the library!
66  Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
67  loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
68  }
69  catch (final Throwable e) {
70  // Fall back
71  try {
72  System.loadLibrary(libraryName);
73  }
74  catch (final UnsatisfiedLinkError ule) {
75  throw ule;
76  }
77  catch (final SecurityException se) {
78  throw se;
79  }
80  }
81  }
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
static Context mContext
Definition: SDL.java:83

◆ setContext()

static void org.libsdl.app.SDL.setContext ( Context  context)
inlinestatic

Definition at line 30 of file SDL.java.

References context, and org.libsdl.app.SDL.mContext.

Referenced by org.libsdl.app.SDL.initialize(), and org.libsdl.app.SDLActivity.onCreate().

30  {
31  mContext = context;
32  }
static Context mContext
Definition: SDL.java:83
static screen_context_t context
Definition: video.c:25

◆ setupJNI()

static void org.libsdl.app.SDL.setupJNI ( )
inlinestatic

Definition at line 14 of file SDL.java.

References org.libsdl.app.SDLControllerManager.nativeSetupJNI(), org.libsdl.app.SDLAudioManager.nativeSetupJNI(), and org.libsdl.app.SDLActivity.nativeSetupJNI().

Referenced by org.libsdl.app.SDLActivity.onCreate().

14  {
15  SDLActivity.nativeSetupJNI();
16  SDLAudioManager.nativeSetupJNI();
17  SDLControllerManager.nativeSetupJNI();
18  }

Field Documentation

◆ mContext

Context org.libsdl.app.SDL.mContext
staticprotected

The documentation for this class was generated from the following file: