src/video/android/SDL_androidgl.c
changeset 5992 f4b73deb9d26
parent 5535 96594ac5fd1a
child 6044 35448a5ea044
     1.1 --- a/src/video/android/SDL_androidgl.c	Fri Oct 14 00:20:44 2011 -0400
     1.2 +++ b/src/video/android/SDL_androidgl.c	Thu Oct 13 01:30:01 2011 -0400
     1.3 @@ -29,26 +29,43 @@
     1.4  
     1.5  #include <android/log.h>
     1.6  
     1.7 +#include <dlfcn.h>
     1.8 +
     1.9 +static void* Android_GLHandle = NULL;
    1.10  
    1.11  /* GL functions */
    1.12  int
    1.13  Android_GL_LoadLibrary(_THIS, const char *path)
    1.14  {
    1.15 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_LoadLibrary\n");
    1.16 +    if (!Android_GLHandle) {
    1.17 +        Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL);
    1.18 +        if (!Android_GLHandle) {
    1.19 +            SDL_SetError("Could not initialize GL ES library\n");
    1.20 +            return -1;
    1.21 +        }
    1.22 +    }
    1.23      return 0;
    1.24  }
    1.25  
    1.26  void *
    1.27  Android_GL_GetProcAddress(_THIS, const char *proc)
    1.28  {
    1.29 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetProcAddress\n");
    1.30 -    return 0;
    1.31 +    /*
    1.32 +       !!! FIXME: this _should_ use eglGetProcAddress(), but it appears to be
    1.33 +       !!! FIXME:  busted on Android at the moment...
    1.34 +       !!! FIXME:  http://code.google.com/p/android/issues/detail?id=7681
    1.35 +       !!! FIXME: ...so revisit this later.  --ryan.
    1.36 +    */
    1.37 +    return dlsym(Android_GLHandle, proc);
    1.38  }
    1.39  
    1.40  void
    1.41  Android_GL_UnloadLibrary(_THIS)
    1.42  {
    1.43 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n");
    1.44 +    if(Android_GLHandle) {
    1.45 +        dlclose(Android_GLHandle);
    1.46 +        Android_GLHandle = NULL;
    1.47 +    }
    1.48  }
    1.49  
    1.50  SDL_GLContext