Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/external/mit/libepoxy/dist/src merge libepoxy 1.4.3.
details: https://anonhg.NetBSD.org/xsrc/rev/58bc9ca41ffb
branches: trunk
changeset: 10326:58bc9ca41ffb
user: mrg <mrg%NetBSD.org@localhost>
date: Tue Jul 09 21:55:21 2019 +0000
description:
merge libepoxy 1.4.3.
diffstat:
external/mit/libepoxy/dist/src/dispatch_common.c | 224 +++++++++++++++++-----
external/mit/libepoxy/dist/src/dispatch_common.h | 42 ++--
2 files changed, 186 insertions(+), 80 deletions(-)
diffs (truncated from 433 to 300 lines):
diff -r 14548ea46340 -r 58bc9ca41ffb external/mit/libepoxy/dist/src/dispatch_common.c
--- a/external/mit/libepoxy/dist/src/dispatch_common.c Tue Jul 09 21:37:36 2019 +0000
+++ b/external/mit/libepoxy/dist/src/dispatch_common.c Tue Jul 09 21:55:21 2019 +0000
@@ -22,9 +22,80 @@
*/
/**
+ * \mainpage Epoxy
+ *
+ * \section intro_sec Introduction
+ *
+ * Epoxy is a library for handling OpenGL function pointer management for
+ * you.
+ *
+ * It hides the complexity of `dlopen()`, `dlsym()`, `glXGetProcAddress()`,
+ * `eglGetProcAddress()`, etc. from the app developer, with very little
+ * knowledge needed on their part. They get to read GL specs and write
+ * code using undecorated function names like `glCompileShader()`.
+ *
+ * Don't forget to check for your extensions or versions being present
+ * before you use them, just like before! We'll tell you what you forgot
+ * to check for instead of just segfaulting, though.
+ *
+ * \section features_sec Features
+ *
+ * - Automatically initializes as new GL functions are used.
+ * - GL 4.4 core and compatibility context support.
+ * - GLES 1/2/3 context support.
+ * - Knows about function aliases so (e.g.) `glBufferData()` can be
+ * used with `GL_ARB_vertex_buffer_object` implementations, along
+ * with GL 1.5+ implementations.
+ * - EGL, GLX, and WGL support.
+ * - Can be mixed with non-epoxy GL usage.
+ *
+ * \section using_sec Using Epoxy
+ *
+ * Using Epoxy should be as easy as replacing:
+ *
+ * ```cpp
+ * #include <GL/gl.h>
+ * #include <GL/glx.h>
+ * #include <GL/glext.h>
+ * ```
+ *
+ * with:
+ *
+ * ```cpp
+ * #include <epoxy/gl.h>
+ * #include <epoxy/glx.h>
+ * ```
+ *
+ * \subsection using_include_sec Headers
+ *
+ * Epoxy comes with the following public headers:
+ *
+ * - `epoxy/gl.h` - For GL API
+ * - `epoxy/egl.h` - For EGL API
+ * - `epoxy/glx.h` - For GLX API
+ * - `epoxy/wgl.h` - For WGL API
+ *
+ * \section links_sec Additional links
+ *
+ * The latest version of the Epoxy code is available on [GitHub](https://github.com/anholt/libepoxy).
+ *
+ * For bug reports and enhancements, please use the [Issues](https://github.com/anholt/libepoxy/issues)
+ * link.
+ *
+ * The scope of this API reference does not include the documentation for
+ * OpenGL and OpenGL ES. For more information on those programming interfaces
+ * please visit:
+ *
+ * - [Khronos](https://www.khronos.org/)
+ * - [OpenGL page on Khronos.org](https://www.khronos.org/opengl/)
+ * - [OpenGL ES page on Khronos.org](https://www.khronos.org/opengles/)
+ * - [docs.GL](http://docs.gl/)
+ */
+
+/**
* @file dispatch_common.c
*
- * Implements common code shared by the generated GL/EGL/GLX dispatch code.
+ * @brief Implements common code shared by the generated GL/EGL/GLX dispatch code.
*
* A collection of some important specs on getting GL function pointers.
*
@@ -118,6 +189,10 @@
#define EGL_LIB "libEGL.so"
#define GLES1_LIB "libGLESv1_CM.so"
#define GLES2_LIB "libGLESv2.so"
+#elif defined _WIN32
+#define EGL_LIB "libEGL.dll"
+#define GLES1_LIB "libGLES_CM.dll"
+#define GLES2_LIB "libGLESv2.dll"
#else
#define EGL_LIB "libEGL.so.1"
#define GLES1_LIB "libGLESv1_CM.so.1"
@@ -149,32 +224,32 @@
struct api {
#ifndef _WIN32
- /**
+ /*
* Locking for making sure we don't double-dlopen().
*/
pthread_mutex_t mutex;
#endif
- /** dlopen() return value for libGL.so.1. */
+ /* dlopen() return value for libGL.so.1. */
void *glx_handle;
- /**
+ /*
* dlopen() return value for OS X's GL library.
*
* On linux, glx_handle is used instead.
*/
void *gl_handle;
- /** dlopen() return value for libEGL.so.1 */
+ /* dlopen() return value for libEGL.so.1 */
void *egl_handle;
- /** dlopen() return value for libGLESv1_CM.so.1 */
+ /* dlopen() return value for libGLESv1_CM.so.1 */
void *gles1_handle;
- /** dlopen() return value for libGLESv2.so.2 */
+ /* dlopen() return value for libGLESv2.so.2 */
void *gles2_handle;
- /**
+ /*
* This value gets incremented when any thread is in
* glBegin()/glEnd() called through epoxy.
*
@@ -272,7 +347,12 @@
return result;
}
-PUBLIC bool
+/**
+ * @brief Checks whether we're using OpenGL or OpenGL ES
+ *
+ * @return `true` if we're using OpenGL
+ */
+bool
epoxy_is_desktop_gl(void)
{
const char *es_prefix = "OpenGL ES";
@@ -336,7 +416,22 @@
return 10 * major + minor;
}
-PUBLIC int
+/**
+ * @brief 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.
+ *
+ * @return The encoded version of OpenGL we are using
+ */
+int
epoxy_gl_version(void)
{
return epoxy_internal_gl_version(0);
@@ -355,7 +450,15 @@
epoxy_extension_in_string(const char *extension_list, const char *ext)
{
const char *ptr = extension_list;
- int len = strlen(ext);
+ int len;
+
+ if (!ext)
+ return false;
+
+ len = strlen(ext);
+
+ if (extension_list == NULL || *extension_list == '\0')
+ return false;
/* Make sure that don't just find an extension with our name as a prefix. */
while (true) {
@@ -387,6 +490,8 @@
for (i = 0; i < num_extensions; i++) {
const char *gl_ext = (const char *)glGetStringi(GL_EXTENSIONS, i);
+ if (!gl_ext)
+ return false;
if (strcmp(ext, gl_ext) == 0)
return true;
}
@@ -452,14 +557,17 @@
}
/**
- * Returns true if the given GL extension is supported in the current context.
+ * @brief Returns true if the given GL extension is supported in the current context.
*
- * Note that this function can't be called from within glBegin()/glEnd().
+ * @param ext The name of the GL extension
+ * @return `true` if the extension is available
*
- * \sa epoxy_has_egl_extension()
- * \sa epoxy_has_glx_extension()
+ * @note that this function can't be called from within `glBegin()` and `glEnd()`.
+ *
+ * @see epoxy_has_egl_extension()
+ * @see epoxy_has_glx_extension()
*/
-PUBLIC bool
+bool
epoxy_has_gl_extension(const char *ext)
{
return epoxy_internal_has_gl_extension(ext, false);
@@ -475,15 +583,27 @@
}
void *
+epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails)
+{
+ return do_dlsym(&api.egl_handle, EGL_LIB, name, exit_if_fails);
+}
+
+void *
epoxy_egl_dlsym(const char *name)
{
- return do_dlsym(&api.egl_handle, EGL_LIB, name, true);
+ return epoxy_conservative_egl_dlsym(name, true);
+}
+
+void *
+epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails)
+{
+ return do_dlsym(&api.glx_handle, GLX_LIB, name, exit_if_fails);
}
void *
epoxy_glx_dlsym(const char *name)
{
- return do_dlsym(&api.glx_handle, GLX_LIB, name, true);
+ return epoxy_conservative_glx_dlsym(name, true);
}
void *
@@ -576,31 +696,15 @@
static EGLenum
epoxy_egl_get_current_gl_context_api(void)
{
- EGLenum save_api = eglQueryAPI();
- EGLContext ctx;
+ EGLint curapi;
- if (eglBindAPI(EGL_OPENGL_API)) {
- ctx = eglGetCurrentContext();
- if (ctx) {
- eglBindAPI(save_api);
- return EGL_OPENGL_API;
- }
- } else {
- (void)eglGetError();
+ if (eglQueryContext(eglGetCurrentDisplay(), eglGetCurrentContext(),
+ EGL_CONTEXT_CLIENT_TYPE, &curapi) == EGL_FALSE) {
+ (void)eglGetError();
+ return EGL_NONE;
}
- 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;
+ return (EGLenum) curapi;
}
#endif /* PLATFORM_HAS_EGL */
@@ -658,28 +762,32 @@
void *
epoxy_get_proc_address(const char *name)
{
-#ifdef _WIN32
+#if PLATFORM_HAS_EGL
+ GLenum egl_api = EGL_NONE;
+
+ if (!epoxy_current_context_is_glx())
Home |
Main Index |
Thread Index |
Old Index