Load shared GLESv2 library

This commit is contained in:
pelya
2011-07-29 18:44:49 +03:00
parent 69de188e16
commit 6caefe96a5
5 changed files with 21 additions and 3 deletions

View File

@@ -446,6 +446,16 @@ public class MainActivity extends Activity {
public void LoadLibraries()
{
try
{
if(Globals.NeedGles2)
System.loadLibrary("GLESv2");
}
catch ( UnsatisfiedLinkError e )
{
System.out.println("libSDL: Cannot load GLESv2 lib");
}
try
{
for(String l : Globals.AppLibraries)

View File

@@ -2356,7 +2356,7 @@ class Settings
static void Apply(Activity p)
{
nativeSetVideoDepth(Globals.VideoDepthBpp);
nativeSetVideoDepth(Globals.VideoDepthBpp, Globals.NeedGles2 ? 1 : 0);
if(Globals.SmoothVideo)
nativeSetSmoothVideo();
if( Globals.CompatibilityHacks )
@@ -2489,7 +2489,7 @@ class Settings
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();
private static native void nativeSetSmoothVideo();
private static native void nativeSetVideoDepth(int bpp);
private static native void nativeSetVideoDepth(int bpp, int gles2);
private static native void nativeSetCompatibilityHacks();
private static native void nativeSetVideoMultithreaded();
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);

View File

@@ -131,6 +131,7 @@ SDL_Surface *SDL_CurrentVideoSurface = NULL;
static int HwSurfaceCount = 0;
static SDL_Surface ** HwSurfaceList = NULL;
void * glLibraryHandle = NULL;
void * gl2LibraryHandle = NULL;
static Uint32 SDL_VideoThreadID = 0;
int SDL_ANDROID_InsideVideoThread()
@@ -201,6 +202,8 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex)
device->ToggleFullScreen = ANDROID_ToggleFullScreen;
glLibraryHandle = dlopen("libGLESv1_CM.so", RTLD_NOW);
if(SDL_ANDROID_UseGles2)
gl2LibraryHandle = dlopen("libGLESv2.so", RTLD_NOW);
return device;
}
@@ -996,6 +999,8 @@ void SDL_ANDROID_VideoContextRecreated()
static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc)
{
void * func = dlsym(glLibraryHandle, proc);
if(!func && gl2LibraryHandle)
func = dlsym(gl2LibraryHandle, proc);
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_GL_GetProcAddress(\"%s\"): %p", proc, func);
return func;
};

View File

@@ -70,6 +70,7 @@ int SDL_ANDROID_VideoMultithreaded = 0;
int SDL_ANDROID_CompatibilityHacks = 0;
int SDL_ANDROID_BYTESPERPIXEL = 2;
int SDL_ANDROID_BITSPERPIXEL = 16;
int SDL_ANDROID_UseGles2 = 0;
static void appPutToBackgroundCallbackDefault(void)
@@ -311,8 +312,9 @@ JAVA_EXPORT_NAME(Settings_nativeSetCompatibilityHacks) (JNIEnv* env, jobject thi
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetVideoDepth) (JNIEnv* env, jobject thiz, jint bpp)
JAVA_EXPORT_NAME(Settings_nativeSetVideoDepth) (JNIEnv* env, jobject thiz, jint bpp, jint UseGles2)
{
SDL_ANDROID_BITSPERPIXEL = bpp;
SDL_ANDROID_BYTESPERPIXEL = SDL_ANDROID_BITSPERPIXEL / 8;
SDL_ANDROID_UseGles2 = UseGles2;
}

View File

@@ -41,6 +41,7 @@ extern int SDL_ANDROID_TouchscreenCalibrationY;
extern int SDL_ANDROID_SmoothVideo;
extern int SDL_ANDROID_VideoMultithreaded;
extern int SDL_ANDROID_CompatibilityHacks;
extern int SDL_ANDROID_UseGles2;
extern int SDL_ANDROID_BYTESPERPIXEL;
extern int SDL_ANDROID_BITSPERPIXEL;
extern void SDL_ANDROID_TextInputInit(char * buffer, int len);