egl: adjust how we load symbols in SDL_EGL_GetProcAddress.
Use eglGetProcAddress for everything on EGL >= 1.5. Try SDL_LoadFunction first for EGL <= 1.4 in case it's a core symbol, and as a fallback if eglGetProcAddress fails. Finally, for EGL <= 1.4, fallback to eglGetProcAddress to catch extensions not exported from the shared library. (Maybe) Fixes Bugzilla #4794.
parent
4f304fd88c
commit
3ecce84749
|
@ -222,25 +222,41 @@ static SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const ch
|
||||||
void *
|
void *
|
||||||
SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
||||||
{
|
{
|
||||||
static char procname[1024];
|
const Uint32 eglver = (((Uint32) _this->egl_data->egl_version_major) << 16) | ((Uint32) _this->egl_data->egl_version_minor);
|
||||||
void *retval;
|
const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32) 1) << 16) | 5);
|
||||||
|
void *retval = NULL;
|
||||||
|
|
||||||
/* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */
|
/* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */
|
||||||
#if !defined(SDL_VIDEO_DRIVER_ANDROID)
|
#if !defined(SDL_VIDEO_DRIVER_ANDROID)
|
||||||
if (_this->egl_data->eglGetProcAddress) {
|
/* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */
|
||||||
|
if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
|
||||||
|
retval = _this->egl_data->eglGetProcAddress(proc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */
|
||||||
|
if (!retval) {
|
||||||
|
static char procname[64];
|
||||||
|
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, proc);
|
||||||
|
/* just in case you need an underscore prepended... */
|
||||||
|
if (!retval && (SDL_strlen(proc) < (sizeof (procname) - 1))) {
|
||||||
|
procname[0] = '_';
|
||||||
|
SDL_strlcpy(procname + 1, proc, sizeof (procname) - 1);
|
||||||
|
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, procname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */
|
||||||
|
#if !defined(SDL_VIDEO_DRIVER_ANDROID)
|
||||||
|
/* Try eglGetProcAddress if we on <= 1.4 and still searching... */
|
||||||
|
if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
|
||||||
retval = _this->egl_data->eglGetProcAddress(proc);
|
retval = _this->egl_data->eglGetProcAddress(proc);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, proc);
|
|
||||||
if (!retval && SDL_strlen(proc) <= 1022) {
|
|
||||||
procname[0] = '_';
|
|
||||||
SDL_strlcpy(procname + 1, proc, 1022);
|
|
||||||
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, procname);
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue