diff --git a/changeAppSettings.sh b/changeAppSettings.sh index c12823e85..ea83cc636 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -182,6 +182,9 @@ echo "# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by echo "# you need this option only if you're developing 3-d app (y) or (n)" >> AndroidAppSettings.cfg echo NeedGles2=$NeedGles2 >> AndroidAppSettings.cfg echo >> AndroidAppSettings.cfg +echo "# Use glshim library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)" >> AndroidAppSettings.cfg +echo UseGlshim=$UseGlshim >> AndroidAppSettings.cfg +echo >> AndroidAppSettings.cfg echo "# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL," >> AndroidAppSettings.cfg echo "# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)" >> AndroidAppSettings.cfg echo SwVideoMode=$SwVideoMode >> AndroidAppSettings.cfg @@ -483,6 +486,13 @@ else NeedGles2=false fi +if [ "$UseGlshim" = "y" ] ; then + UseGlshimCFlags=-DUSE_GLSHIM=1 +else + UseGlshim= + UseGlshimCFlags= +fi + if [ "$SwVideoMode" = "y" ] ; then SwVideoMode=true else @@ -895,6 +905,7 @@ cat project/jni/SettingsTemplate.mk | \ sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \ sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \ sed "s^APPLICATION_OVERLAPS_SYSTEM_HEADERS :=.*^APPLICATION_OVERLAPS_SYSTEM_HEADERS := $AppOverlapsSystemHeaders^" | \ + sed "s^USE_GLSHIM :=.*^USE_GLSHIM := $UseGlshim^" | \ sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := \ $RedefinedKeycodes \ $RedefinedKeycodesScreenKb \ @@ -903,7 +914,8 @@ cat project/jni/SettingsTemplate.mk | \ $CompatibilityHacksAppIgnoresAudioBufferSize \ $CompatibilityHacksSlowCompatibleEventQueue \ $CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState \ - $CompatibilityHacksProperUsageOfSDL_UpdateRects^" | \ + $CompatibilityHacksProperUsageOfSDL_UpdateRects \ + $UseGlshimCFlags^" | \ sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \ sed "s^APPLICATION_BUILD_EXCLUDE :=.*^APPLICATION_BUILD_EXCLUDE := $AppBuildExclude^" | \ sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \ diff --git a/project/jni/SettingsTemplate.mk b/project/jni/SettingsTemplate.mk index 8688bf854..e591d03d0 100644 --- a/project/jni/SettingsTemplate.mk +++ b/project/jni/SettingsTemplate.mk @@ -42,6 +42,8 @@ APPLICATION_BUILD_EXCLUDE := APPLICATION_CUSTOM_BUILD_SCRIPT := +USE_GLSHIM := + SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN SDL_VERSION := 1.2 diff --git a/project/jni/sdl-1.2/Android.mk b/project/jni/sdl-1.2/Android.mk index 765062118..45eb2b10e 100644 --- a/project/jni/sdl-1.2/Android.mk +++ b/project/jni/sdl-1.2/Android.mk @@ -57,6 +57,10 @@ LOCAL_SRC_FILES := $(foreach F, $(SDL_SRCS), $(addprefix $(dir $(F)),$(notdir $( LOCAL_SHARED_LIBRARIES := sdl_native_helpers # Not really a dependency, needed for CustomBuildScript +ifdef USE_GLSHIM +LOCAL_STATIC_LIBRARIES := glshim +endif + LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog include $(BUILD_SHARED_LIBRARY) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index a316959d0..201330eab 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -61,6 +61,10 @@ If you compile this code with SDL 1.3 or newer, or use in some other way, the li #define DEBUGOUT(...) #endif +#ifdef USE_GLSHIM +#include +#endif + static int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat); static SDL_Rect **ANDROID_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); static SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); @@ -1236,6 +1240,10 @@ static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc) void * func = dlsym(glLibraryHandle, proc); if(!func && gl2LibraryHandle) func = dlsym(gl2LibraryHandle, proc); +#ifdef USE_GLSHIM + if (func==NULL) + func = glXGetProcAddress(proc); +#endif __android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_GL_GetProcAddress(\"%s\"): %p", proc, func); return func; };