Refactor dispatch_common's EGL context detection code.

I want to reuse this from get_core_proc_address().
macos/v1.5.9
Eric Anholt 11 years ago
parent e6d9bb971b
commit b670c84039
  1. 54
      src/dispatch_common.c

@ -424,6 +424,38 @@ epoxy_get_core_proc_address(const char *name, int core_version)
}
}
#if PLATFORM_HAS_EGL
static EGLenum
epoxy_egl_get_current_gl_context_api(void)
{
EGLenum save_api = eglQueryAPI();
EGLContext ctx;
if (eglBindAPI(EGL_OPENGL_API)) {
ctx = eglGetCurrentContext();
if (ctx) {
eglBindAPI(save_api);
return EGL_OPENGL_API;
}
} else {
(void)eglGetError();
}
if (eglBindAPI(EGL_OPENGL_ES_API)) {
ctx = eglGetCurrentContext();
eglBindAPI(save_api);
if (ctx) {
eglBindAPI(save_api);
return EGL_OPENGL_ES_API;
}
} else {
(void)eglGetError();
}
return EGL_NONE;
}
#endif /* PLATFORM_HAS_EGL */
/**
* Performs the dlsym() for the core GL 1.0 functions that we use for
* determining version and extension support for deciding on dlsym
@ -453,23 +485,10 @@ epoxy_get_bootstrap_proc_address(const char *name)
#if PLATFORM_HAS_EGL
get_dlopen_handle(&api.egl_handle, "libEGL.so.1", false);
if (api.egl_handle) {
EGLenum save_api = eglQueryAPI();
EGLContext ctx;
if (eglBindAPI(EGL_OPENGL_API)) {
ctx = eglGetCurrentContext();
if (ctx) {
eglBindAPI(save_api);
switch (epoxy_egl_get_current_gl_context_api()) {
case EGL_OPENGL_API:
return epoxy_gl_dlsym(name);
}
} else {
(void)eglGetError();
}
if (eglBindAPI(EGL_OPENGL_ES_API)) {
ctx = eglGetCurrentContext();
eglBindAPI(save_api);
if (ctx) {
case EGL_OPENGL_ES_API:
/* We can't resolve the GL version, because
* epoxy_glGetString() is one of the two things calling
* us. Try the GLES2 implementation first, and fall back
@ -481,9 +500,6 @@ epoxy_get_bootstrap_proc_address(const char *name)
else
return epoxy_gles1_dlsym(name);
}
} else {
(void)eglGetError();
}
}
#endif /* PLATFORM_HAS_EGL */

Loading…
Cancel
Save