libepoxy 1.5.4

Macros | Functions | Variables
dispatch_common.c File Reference

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

## Detailed Description

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."

## Macro Definition Documentation

## ◆ EGL_LIB

#define EGL_LIB "libEGL.so.1"

## ◆ GLES1_LIB

#define GLES1_LIB "libGLESv1_CM.so.1"

## ◆ GLES2_LIB

#define GLES2_LIB "libGLESv2.so.2"

## ◆ GLVND_GLX_LIB

#define GLVND_GLX_LIB "libGLX.so.1"

## ◆ OPENGL_LIB

#define OPENGL_LIB "libOpenGL.so.0"

## Function Documentation

## ◆ epoxy_conservative_egl_dlsym()

void* epoxy_conservative_egl_dlsym | ( | const char * | name,
|  | bool | exit_if_fails
| ) |  |

## ◆ epoxy_conservative_gl_version()

int epoxy_conservative_gl_version | ( | void |  | ) |

## ◆ epoxy_conservative_glx_dlsym()

void* epoxy_conservative_glx_dlsym | ( | const char * | name,
|  | bool | exit_if_fails
| ) |  |

## ◆ epoxy_conservative_has_gl_extension()

bool epoxy_conservative_has_gl_extension | ( | const char * | ext | ) |

## ◆ epoxy_egl_dlsym()

void* epoxy_egl_dlsym | ( | const char * | name | ) |

## ◆ epoxy_extension_in_string()

bool epoxy_extension_in_string | ( | const char * | extension_list,
|  | const char * | ext
| ) |  |

Checks for the presence of an extension in an OpenGL extension string.

Parameters

  extension_list | The string containing the list of extensions to check
  ext | The name of the GL extension

Returns
  `true` if the extension is available'

Note
  If you are looking to check whether a normal GL, EGL or GLX extension is supported by the client, this probably isn't the function you want.

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.

See also
  epoxy_has_gl_extension()
  epoxy_has_egl_extension()
  epoxy_has_glx_extension()

## ◆ epoxy_get_bootstrap_proc_address()

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).

## ◆ epoxy_get_core_proc_address()

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.

## ◆ epoxy_get_proc_address()

void* epoxy_get_proc_address | ( | const char * | name | ) |

## ◆ epoxy_gl_dlsym()

void* epoxy_gl_dlsym | ( | const char * | name | ) |

## ◆ epoxy_gl_version()

int epoxy_gl_version | ( | void |  | ) |

Returns the version of OpenGL we are using.

The version is encoded as:

version = major * 10 + minor

So it can be easily used for version comparisons.

Returns
  The encoded version of OpenGL we are using

## ◆ epoxy_glBegin()

WRAPPER() epoxy_glBegin | ( | GLenum | primtype | ) |

## ◆ epoxy_glEnd()

WRAPPER() epoxy_glEnd | ( | void |  | ) |

## ◆ epoxy_gles1_dlsym()

void* epoxy_gles1_dlsym | ( | const char * | name | ) |

## ◆ epoxy_gles2_dlsym()

void* epoxy_gles2_dlsym | ( | const char * | name | ) |

## ◆ epoxy_gles3_dlsym()

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.

## ◆ epoxy_glsl_version()

int epoxy_glsl_version | ( | void |  | ) |

Returns the version of the GL Shading Language we are using.

The version is encoded as:

version = major * 100 + minor

So it can be easily used for version comparisons.

Returns
  The encoded version of the GL Shading Language we are using

## ◆ epoxy_glx_dlsym()

void* epoxy_glx_dlsym | ( | const char * | name | ) |

## ◆ epoxy_has_gl_extension()

bool epoxy_has_gl_extension | ( | const char * | ext | ) |

Returns true if the given GL extension is supported in the current context.

Parameters

  ext | The name of the GL extension

Returns
  `true` if the extension is available

Note
  that this function can't be called from within `glBegin()` and `glEnd()`.

See also
  epoxy_has_egl_extension()
  epoxy_has_glx_extension()

## ◆ epoxy_is_desktop_gl()

bool epoxy_is_desktop_gl | ( | void |  | ) |

Checks whether we're using OpenGL or OpenGL ES.

Returns
  `true` if we're using OpenGL

## ◆ epoxy_load_egl()

bool epoxy_load_egl | ( | bool | exit_if_fails,
|  | bool | load
| ) |  |

## ◆ epoxy_load_glx()

bool epoxy_load_glx | ( | bool | exit_if_fails,
|  | bool | load
| ) |  |

## ◆ epoxy_set_resolver_failure_handler()

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.

Parameters

  handler | The new handler function

Returns
  The previous handler function

## Variable Documentation

## ◆ epoxy_glBegin

PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped

## ◆ epoxy_glEnd

PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped

## ◆ epoxy_resolver_failure_handler

epoxy_resolver_failure_handler_t epoxy_resolver_failure_handler