libepoxy
1.5.3
|
Implements common code shared by the generated GL/EGL/GLX dispatch code. More...
#include <assert.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <err.h>
#include <pthread.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "dispatch_common.h"
Macros | |
#define | GLVND_GLX_LIB "libGLX.so.1" |
#define | EGL_LIB "libEGL.so.1" |
#define | GLES1_LIB "libGLESv1_CM.so.1" |
#define | GLES2_LIB "libGLESv2.so.2" |
#define | OPENGL_LIB "libOpenGL.so.0" |
Functions | |
bool | epoxy_is_desktop_gl (void) |
Checks whether we're using OpenGL or OpenGL ES. More... | |
int | epoxy_gl_version (void) |
Returns the version of OpenGL we are using. More... | |
int | epoxy_conservative_gl_version (void) |
int | epoxy_glsl_version (void) |
Returns the version of the GL Shading Language we are using. More... | |
bool | epoxy_extension_in_string (const char *extension_list, const char *ext) |
Checks for the presence of an extension in an OpenGL extension string. More... | |
bool | epoxy_load_glx (bool exit_if_fails, bool load) |
void * | epoxy_conservative_glx_dlsym (const char *name, bool exit_if_fails) |
bool | epoxy_has_gl_extension (const char *ext) |
Returns true if the given GL extension is supported in the current context. More... | |
bool | epoxy_conservative_has_gl_extension (const char *ext) |
bool | epoxy_load_egl (bool exit_if_fails, bool load) |
void * | epoxy_conservative_egl_dlsym (const char *name, bool exit_if_fails) |
void * | epoxy_egl_dlsym (const char *name) |
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) |
Does the appropriate dlsym() or eglGetProcAddress() for GLES3 functions. More... | |
void * | epoxy_get_core_proc_address (const char *name, int core_version) |
Performs either the dlsym or glXGetProcAddress()-equivalent for core functions in desktop GL. More... | |
void * | epoxy_get_bootstrap_proc_address (const char *name) |
Performs the dlsym() for the core GL 1.0 functions that we use for determining version and extension support for deciding on dlsym versus glXGetProcAddress() for all other functions. More... | |
void * | epoxy_get_proc_address (const char *name) |
WRAPPER() | epoxy_glBegin (GLenum primtype) |
WRAPPER() | epoxy_glEnd (void) |
epoxy_resolver_failure_handler_t | epoxy_set_resolver_failure_handler (epoxy_resolver_failure_handler_t handler) |
Sets the function that will be called every time Epoxy fails to resolve a symbol. More... | |
Variables | |
PFNGLBEGINPROC | epoxy_glBegin = epoxy_glBegin_wrapped |
PFNGLENDPROC | epoxy_glEnd = epoxy_glEnd_wrapped |
epoxy_resolver_failure_handler_t | epoxy_resolver_failure_handler |
Implements common code shared by the generated GL/EGL/GLX dispatch code.
A collection of some important specs on getting GL function pointers.
From the linux GL ABI (http://www.opengl.org/registry/ABI/):
"3.4. The libraries must export all OpenGL 1.2, GLU 1.3, GLX 1.3, and ARB_multitexture entry points statically. 3.5. Because non-ARB extensions vary so widely and are constantly increasing in number, it's infeasible to require that they all be supported, and extensions can always be added to hardware drivers after the base link libraries are released. These drivers are dynamically loaded by libGL, so extensions not in the base library must also be obtained dynamically. 3.6. To perform the dynamic query, libGL also must export an entry point called void (*glXGetProcAddressARB(const GLubyte *))(); The full specification of this function is available separately. It takes the string name of a GL or GLX entry point and returns a pointer to a function implementing that entry point. It is functionally identical to the wglGetProcAddress query defined by the Windows OpenGL library, except that the function pointers returned are context independent, unlike the WGL query."
From the EGL 1.4 spec:
"Client API function pointers returned by eglGetProcAddress are independent of the display and the currently bound client API context, and may be used by any client API context which supports the extension.
eglGetProcAddress may be queried for all of the following functions:
• All EGL and client API extension functions supported by the implementation (whether those extensions are supported by the current client API context or not). This includes any mandatory OpenGL ES extensions.
eglGetProcAddress may not be queried for core (non-extension) functions in EGL or client APIs 20 .
For functions that are queryable with eglGetProcAddress, implementations may choose to also export those functions statically from the object libraries im- plementing those functions. However, portable clients cannot rely on this behavior.
From the GLX 1.4 spec:
"glXGetProcAddress may be queried for all of the following functions: • All GL and GLX extension functions supported by the implementation (whether those extensions are supported by the current context or not). • All core (non-extension) functions in GL and GLX from version 1.0 up to and including the versions of those specifications supported by the implementation, as determined by glGetString(GL VERSION) and glXQueryVersion queries."
#define EGL_LIB "libEGL.so.1" |
#define GLES1_LIB "libGLESv1_CM.so.1" |
#define GLES2_LIB "libGLESv2.so.2" |
#define GLVND_GLX_LIB "libGLX.so.1" |
#define OPENGL_LIB "libOpenGL.so.0" |
void* epoxy_conservative_egl_dlsym | ( | const char * | name, |
bool | exit_if_fails | ||
) |
int epoxy_conservative_gl_version | ( | void | ) |
void* epoxy_conservative_glx_dlsym | ( | const char * | name, |
bool | exit_if_fails | ||
) |
bool epoxy_conservative_has_gl_extension | ( | const char * | ext | ) |
void* epoxy_egl_dlsym | ( | const char * | name | ) |
bool epoxy_extension_in_string | ( | const char * | extension_list, |
const char * | ext | ||
) |
Checks for the presence of an extension in an OpenGL extension string.
extension_list | The string containing the list of extensions to check |
ext | The name of the GL extension |
true
if the extension is available'Some parts of the spec for OpenGL and friends will return an OpenGL formatted extension string that is separate from the usual extension strings for the spec. This function provides easy parsing of those strings.
void* epoxy_get_bootstrap_proc_address | ( | const char * | name | ) |
Performs the dlsym() for the core GL 1.0 functions that we use for determining version and extension support for deciding on dlsym versus glXGetProcAddress() for all other functions.
This needs to succeed on implementations without GLX (since glGetString() and glGetIntegerv() are both in GLES1/2 as well, and at call time we don't know for sure what API they're trying to use without inspecting contexts ourselves).
void* epoxy_get_core_proc_address | ( | const char * | name, |
int | core_version | ||
) |
Performs either the dlsym or glXGetProcAddress()-equivalent for core functions in desktop GL.
void* epoxy_get_proc_address | ( | const char * | name | ) |
void* epoxy_gl_dlsym | ( | const char * | name | ) |
int epoxy_gl_version | ( | void | ) |
Returns the version of OpenGL we are using.
The version is encoded as:
So it can be easily used for version comparisons.
WRAPPER() epoxy_glBegin | ( | GLenum | primtype | ) |
WRAPPER() epoxy_glEnd | ( | void | ) |
void* epoxy_gles1_dlsym | ( | const char * | name | ) |
void* epoxy_gles2_dlsym | ( | const char * | name | ) |
void* epoxy_gles3_dlsym | ( | const char * | name | ) |
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.
int epoxy_glsl_version | ( | void | ) |
Returns the version of the GL Shading Language we are using.
The version is encoded as:
So it can be easily used for version comparisons.
void* epoxy_glx_dlsym | ( | const char * | name | ) |
bool epoxy_has_gl_extension | ( | const char * | ext | ) |
Returns true if the given GL extension is supported in the current context.
ext | The name of the GL extension |
true
if the extension is availableglBegin()
and glEnd()
.bool epoxy_is_desktop_gl | ( | void | ) |
Checks whether we're using OpenGL or OpenGL ES.
true
if we're using OpenGL bool epoxy_load_egl | ( | bool | exit_if_fails, |
bool | load | ||
) |
bool epoxy_load_glx | ( | bool | exit_if_fails, |
bool | load | ||
) |
epoxy_resolver_failure_handler_t epoxy_set_resolver_failure_handler | ( | epoxy_resolver_failure_handler_t | handler | ) |
Sets the function that will be called every time Epoxy fails to resolve a symbol.
handler | The new handler function |
PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped |
PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped |
epoxy_resolver_failure_handler_t epoxy_resolver_failure_handler |