Skip to content

Commit

Permalink
Add support for looking up GLES3 functions using dlsym().
Browse files Browse the repository at this point in the history
ARM and Mesa disagreed on how to look up the functions, so support
both ways.

Fixes #21
  • Loading branch information
anholt committed Mar 17, 2014
1 parent 053ac5f commit 14f2448
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/dispatch_common.c
Expand Up @@ -207,7 +207,7 @@ do_dlsym(void **handle, const char *lib_name, const char *name,
#else
result = dlsym(*handle, name);
#endif
if (!result) {
if (!result && exit_on_fail) {
fprintf(stderr,"%s() not found in %s\n", name, lib_name);
exit(1);
}
Expand Down Expand Up @@ -381,6 +381,27 @@ epoxy_gles2_dlsym(const char *name)
return do_dlsym(&api.gles2_handle, "libGLESv2.so.2", name, true);
}

/**
* Does the appropriate dlsym() or eglGetProcAddress() for GLES3
* functions.
*
* Mesa interpreted GLES as intending that the GLES3 functions were
* available only through eglGetProcAddress() and not dlsym(), while
* ARM's Mali drivers interpreted GLES as intending that GLES3
* functions were available only through dlsym() and not
* eglGetProcAddress(). Thanks, Khronos.
*/
void *
epoxy_gles3_dlsym(const char *name)
{
void *func = do_dlsym(&api.gles2_handle, "libGLESv2.so.2", name, false);

if (func)
return func;

return epoxy_get_proc_address(name);
}

/**
* Performs either the dlsym or glXGetProcAddress()-equivalent for
* core functions in desktop GL.
Expand Down
1 change: 1 addition & 0 deletions src/dispatch_common.h
Expand Up @@ -78,6 +78,7 @@ void *epoxy_glx_dlsym(const char *name);
void *epoxy_gl_dlsym(const char *name);
void *epoxy_gles1_dlsym(const char *name);
void *epoxy_gles2_dlsym(const char *name);
void *epoxy_gles3_dlsym(const char *name);
void *epoxy_get_proc_address(const char *name);
void *epoxy_get_core_proc_address(const char *name, int core_version);
void *epoxy_get_bootstrap_proc_address(const char *name);
Expand Down

0 comments on commit 14f2448

Please sign in to comment.