From 0a89f2b70731a281bdfd61a2ae652ffe26fac0fd Mon Sep 17 00:00:00 2001 From: pelya Date: Wed, 12 Jan 2011 18:09:40 +0000 Subject: [PATCH] Fixed SDL_GL_GetProcAddress --- build.sh | 2 +- .../fheroes2/AndroidAppSettings.cfg | 4 ++-- .../glxgears/AndroidAppSettings.cfg | 5 +++-- project/jni/sdl-1.2/src/video/SDL_video.c | 4 ++++ .../src/video/android/SDL_androidvideo-1.2.c | 20 +++++++++++++++---- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 36dbc8887..33b5def5c 100755 --- a/build.sh +++ b/build.sh @@ -15,5 +15,5 @@ if ( grep "package $AppFullName;" project/src/Globals.java > /dev/null && [ "`re touch project/src/Globals.java fi -cd project && env PATH=$NDKBUILDPATH nice -n10 ndk-build -j4 V=1 && ant `test -n "$1" && echo release || echo debug` && test -z "$1" && cd bin && adb install -r DemoActivity-debug.apk +cd project && env PATH=$NDKBUILDPATH nice -n10 ndk-build V=1 && ant `test -n "$1" && echo release || echo debug` && test -z "$1" && cd bin && adb install -r DemoActivity-debug.apk diff --git a/project/jni/application/fheroes2/AndroidAppSettings.cfg b/project/jni/application/fheroes2/AndroidAppSettings.cfg index b47f57dd2..b6f449b63 100644 --- a/project/jni/application/fheroes2/AndroidAppSettings.cfg +++ b/project/jni/application/fheroes2/AndroidAppSettings.cfg @@ -22,8 +22,8 @@ AppTouchscreenKeyboardKeysAmount=0 AppTouchscreenKeyboardKeysAmountAutoFire=0 RedefinedKeysScreenKb="LCTRL M T H E C SPACE C S L" MultiABI=n -AppVersionCode=218811 -AppVersionName="2188.11" +AppVersionCode=219311 +AppVersionName="2193.11" CompiledLibraries="sdl_net sdl_mixer sdl_image sdl_ttf png intl" CustomBuildScript=n AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DWITH_AI=simple' diff --git a/project/jni/application/glxgears/AndroidAppSettings.cfg b/project/jni/application/glxgears/AndroidAppSettings.cfg index 58e57058e..196357a8b 100644 --- a/project/jni/application/glxgears/AndroidAppSettings.cfg +++ b/project/jni/application/glxgears/AndroidAppSettings.cfg @@ -1,6 +1,6 @@ # The application settings for Android libSDL port -AppSettingVersion=15 -LibSdlVersion=1.3 +AppSettingVersion=16 +LibSdlVersion=1.2 AppName="GLXGears" AppFullName=org.opengl.glxgears ScreenOrientation=h @@ -20,6 +20,7 @@ NonBlockingSwapBuffers=n RedefinedKeys="RETURN" AppTouchscreenKeyboardKeysAmount=0 AppTouchscreenKeyboardKeysAmountAutoFire=0 +RedefinedKeysScreenKb="RETURN" MultiABI=n AppVersionCode=1 AppVersionName="1" diff --git a/project/jni/sdl-1.2/src/video/SDL_video.c b/project/jni/sdl-1.2/src/video/SDL_video.c index 4ebc47e92..2e74d627a 100644 --- a/project/jni/sdl-1.2/src/video/SDL_video.c +++ b/project/jni/sdl-1.2/src/video/SDL_video.c @@ -1423,7 +1423,11 @@ void *SDL_GL_GetProcAddress(const char* proc) func = NULL; if ( video->GL_GetProcAddress ) { +#ifdef ANDROID + if ( 1 ) { +#else if ( video->gl_config.driver_loaded ) { +#endif func = video->GL_GetProcAddress(this, proc); } else { SDL_SetError("No GL driver has been loaded"); 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 d99a058b3..06c8dc5a8 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 @@ -42,6 +42,7 @@ #include #include #include // for memset() +#include #define _THIS SDL_VideoDevice *this @@ -67,6 +68,7 @@ static int ANDROID_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst); static int ANDROID_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color); static int ANDROID_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key); static int ANDROID_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value); +static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc); // Stubs to get rid of crashing in OpenGL mode // The implementation dependent data for the window manager cursor @@ -111,11 +113,12 @@ typedef struct SDL_Texture private_hwdata; // Pointer to in-memory video surface int SDL_ANDROID_sFakeWindowWidth = 640; int SDL_ANDROID_sFakeWindowHeight = 480; -static int sdl_opengl = 0; +int sdl_opengl = 0; static SDL_Window *SDL_VideoWindow = NULL; SDL_Surface *SDL_CurrentVideoSurface = NULL; static int HwSurfaceCount = 0; static SDL_Surface ** HwSurfaceList = NULL; +void * glLibraryHandle = NULL; static Uint32 SDL_VideoThreadID = 0; int SDL_ANDROID_InsideVideoThread() @@ -175,6 +178,7 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex) device->InitOSKeymap = ANDROID_InitOSKeymap; device->PumpEvents = ANDROID_PumpEvents; device->GL_SwapBuffers = ANDROID_GL_SwapBuffers; + device->GL_GetProcAddress = ANDROID_GL_GetProcAddress; device->free = ANDROID_DeleteDevice; // Stubs @@ -183,6 +187,9 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex) device->ShowWMCursor = ANDROID_ShowWMCursor; //device->WarpWMCursor = ANDROID_WarpWMCursor; //device->MoveWMCursor = ANDROID_MoveWMCursor; + + glLibraryHandle = dlopen("libGLESv1_CM.so", RTLD_NOW); + __android_log_print(ANDROID_LOG_INFO, "libSDL", "dlopen(\"libGLESv1_CM.so\"): %p", glLibraryHandle); return device; } @@ -245,7 +252,7 @@ int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat) SDL_modelist[11] = NULL; SDL_VideoInit_1_3(NULL, 0); - + /* We're done! */ return(0); } @@ -263,7 +270,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, SDL_PixelFormat format; int bpp1; - __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d", width, height); + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d OpenGL %d HW %d", width, height, flags & SDL_OPENGL, flags & SDL_HWSURFACE); if( ! SDL_ANDROID_InsideVideoThread() ) { __android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__); @@ -351,7 +358,6 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, /* Set up the new mode framebuffer */ SDL_CurrentVideoSurface = current; - /* We're done */ return(current); @@ -954,3 +960,9 @@ void SDL_ANDROID_VideoContextRecreated() } }; +static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc) +{ + void * func = dlsym(glLibraryHandle, proc); + __android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_GL_GetProcAddress(\"%s\"): %p", proc, func); + return func; +};