On Sunday 20 February 2005 13:20, Brian Paul wrote:
> Adam Jackson wrote:
> > I'm working on this, actually.  Right now I'm doing it as an EGL->GLX
> > translation layer so we can get glitz retargeted at the EGL API.  Turning
> > that into a dispatch layer wouldn't be too tough, particularly since a
> > good bit of the engine is already written in miniglx.  I've nearly got it
> > to the point of being able to run eglinfo, but it seems to have uncovered
> > a bug or two in the fbconfig handling.
>
> I actually started writing some EGL interface code a few months ago,
> but haven't touched it since.  Give me a day or two to clean it up.
> Then let's exchange code and see what we've got.

I pounded out most of the rest of the API compat today.  This is good enough 
to run eglinfo and return mostly correct answers (caveat is always "slow" for 
some reason), and of the 25ish egl* entrypoints only around three are still 
stubs.

Apply patch to a newish Mesa checkout, add egl.c to sources in 
src/glx/x11/Makefile, build libGL.

- ajax
--- /dev/null	2004-05-08 19:17:35.000000000 -0400
+++ src/glx/x11/egl.c	2005-02-20 19:57:11.000000000 -0500
@@ -0,0 +1,780 @@
+/*
+ * Copyright 2005 Adam Jackson.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file egl.c
+ * API compatibility with OpenGL ES.
+ *
+ * \author Adam Jackson <[EMAIL PROTECTED]>
+ */
+
+#include <GL/egl.h>
+#include <GL/glx.h>
+#include "glheader.h"
+#include "glxclient.h"
+
+#define DISPLAY_CHECK(d) \
+    do { \
+        if (!d || !d->dpy) { \
+            _egl_errno = EGL_BAD_DISPLAY; \
+            return EGL_FALSE; \
+        } \
+    } while (0)
+
+#define CONTEXT_CHECK(c) \
+    do { \
+        if (!c || !c->ctx) { \
+            _egl_errno = EGL_BAD_CONTEXT; \
+            return EGL_FALSE; \
+        } \
+    } while (0)
+
+#define INITED_CHECK(d) \
+    do { \
+        if (!d->initialized) { \
+            _egl_errno = EGL_NOT_INITIALIZED; \
+            return EGL_FALSE; \
+        } \
+    } while (0)
+
+#define SURFACE_CHECK(s) \
+    do { \
+        if (!s || !s->surf) { \
+            _egl_errno = EGL_BAD_SURFACE; \
+            return EGL_FALSE; \
+        } \
+    } while (0)
+
+typedef struct _egl_context
+{
+    GLXContext      ctx;
+    XVisualInfo     *visinfo;
+    EGLSurface      read;
+    EGLSurface      draw;
+    EGLint          config_id;
+    EGLBoolean      current;
+    EGLBoolean      doomed;
+} egl_context;
+
+typedef struct _egl_display
+{
+    Display     *dpy;
+    EGLBoolean  initialized;
+} egl_display;
+
+#define _EGL_WINDOW_SURFACE     1
+#define _EGL_PIXMAP_SURFACE     2
+#define _EGL_PBUFFER_SURFACE    3
+
+typedef struct _egl_surface
+{
+    EGLint      type;
+    GLXDrawable surf;
+    EGLBoolean  current;
+    EGLBoolean  doomed;
+} egl_surface;
+
+#ifdef GLX_USE_TLS
+#define _EGL_TLSVAR __thread
+#else
+#define _EGL_TLSVAR
+#endif
+static _EGL_TLSVAR EGLint       _egl_errno          = EGL_SUCCESS;
+static _EGL_TLSVAR egl_context  *_egl_current_ctx   = EGL_NO_CONTEXT;
+static _EGL_TLSVAR egl_display  *_egl_current_dpy   = EGL_NO_DISPLAY;
+
+/* internal helper functions */
+
+static int map_attrib_egl_to_glx(const EGLint in)
+{
+    switch (in)
+    {
+        case EGL_BUFFER_SIZE:
+            return GLX_BUFFER_SIZE;
+        case EGL_ALPHA_SIZE:
+            return GLX_ALPHA_SIZE;
+        case EGL_BLUE_SIZE:
+            return GLX_BLUE_SIZE;
+        case EGL_GREEN_SIZE:
+            return GLX_GREEN_SIZE;
+        case EGL_RED_SIZE:
+            return GLX_RED_SIZE;
+        case EGL_DEPTH_SIZE:
+            return GLX_DEPTH_SIZE;
+        case EGL_STENCIL_SIZE:
+            return GLX_STENCIL_SIZE;
+        case EGL_CONFIG_CAVEAT:
+            return GLX_CONFIG_CAVEAT;
+        case EGL_CONFIG_ID:
+            return GLX_FBCONFIG_ID;
+        case EGL_LEVEL:
+            return GLX_LEVEL;
+        case EGL_MAX_PBUFFER_HEIGHT:
+            return GLX_MAX_PBUFFER_HEIGHT;
+        case EGL_MAX_PBUFFER_PIXELS:
+            return GLX_MAX_PBUFFER_PIXELS;
+        case EGL_MAX_PBUFFER_WIDTH:
+            return GLX_MAX_PBUFFER_WIDTH;
+        case EGL_NATIVE_RENDERABLE:
+            return GLX_X_RENDERABLE;
+        case EGL_NATIVE_VISUAL_ID:
+            return GLX_VISUAL_ID;
+        case EGL_NATIVE_VISUAL_TYPE:
+            return GLX_X_VISUAL_TYPE;
+        case EGL_SAMPLES:
+            return GLX_SAMPLES;
+        case EGL_SAMPLE_BUFFERS:
+            return GLX_SAMPLE_BUFFERS;
+        case EGL_SURFACE_TYPE:
+            return GLX_DRAWABLE_TYPE;
+        case EGL_TRANSPARENT_TYPE:
+            return GLX_TRANSPARENT_TYPE;
+        case EGL_TRANSPARENT_BLUE_VALUE:
+            return GLX_TRANSPARENT_BLUE_VALUE;
+        case EGL_TRANSPARENT_GREEN_VALUE:
+            return GLX_TRANSPARENT_GREEN_VALUE;
+        case EGL_TRANSPARENT_RED_VALUE:
+            return GLX_TRANSPARENT_RED_VALUE;
+/*
+        case EGL_BIND_TO_TEXTURE_RGB:
+        case EGL_BIND_TO_TEXTURE_RGBA:
+        case EGL_MIN_SWAP_INTERVAL:
+        case EGL_MAX_SWAP_INTERVAL:
+*/
+        default: return GLX_NONE;
+    }
+}
+
+static int *convert_attrib_egl_to_glx(const EGLint *egllist)
+{
+    int *glxlist;
+    int i = 0, len;
+
+    if (!egllist)
+    {
+        glxlist = Xmalloc(sizeof(EGLint));
+        *glxlist = 0;
+        return glxlist;
+    }
+
+    while(egllist[i++] != EGL_NONE) /* do nothing */ ;
+    len = i;
+
+    if (!(glxlist = Xmalloc(len * sizeof(int))))
+        return glxlist;
+
+    for (i = 0; egllist[i] != EGL_NONE; i += 2)
+    {
+        glxlist[i] = map_attrib_egl_to_glx(egllist[i]);
+        glxlist[i+1] = egllist[i+1];
+    }
+    glxlist[i] = GLX_NONE;
+
+    return glxlist;
+}
+
+static void convert_error(void)
+{
+    GLenum i;
+    /* XXX some of these are guesses */
+    switch((i = glGetError()))
+    {
+        case GLX_BAD_SCREEN:
+            _egl_errno = EGL_BAD_DISPLAY;
+            return;
+        case GLX_BAD_ATTRIBUTE:
+            _egl_errno = EGL_BAD_ATTRIBUTE;
+            return;
+        case GLX_NO_EXTENSION:
+            _egl_errno = EGL_BAD_CONFIG;
+        case GLX_BAD_VISUAL:
+            _egl_errno = EGL_BAD_MATCH;
+            return;
+        case GLX_BAD_CONTEXT:
+            _egl_errno = EGL_BAD_CONTEXT;
+            return;
+        case GLX_BAD_VALUE: /* fallthrough */
+        case GLX_BAD_ENUM:
+            _egl_errno = EGL_BAD_PARAMETER;
+            return;
+        default:
+            _egl_errno = EGL_CONTEXT_LOST; /* XXX catchall */
+            return;
+    }
+}
+
+static void doDestroyContext(EGLDisplay display, EGLContext context)
+{
+    egl_context *c = context;
+    egl_display *d = display;
+    GLX_PREFIX(glXDestroyContext)(d->dpy, c->ctx);
+    Xfree(c->visinfo);
+    Xfree(c);
+}
+
+static EGLBoolean doDestroySurface(EGLDisplay display, EGLSurface surface)
+{
+    egl_display *d = display;
+    egl_surface *s = surface;
+    switch (s->type)
+    {
+        case _EGL_WINDOW_SURFACE:
+            GLX_PREFIX(glXDestroyWindow)(d->dpy, (GLXWindow)(s->surf));
+            convert_error();
+            break;
+
+        case _EGL_PIXMAP_SURFACE:
+            GLX_PREFIX(glXDestroyGLXPixmap)(d->dpy, (GLXPixmap)(s->surf));
+            convert_error();
+            break;
+
+        case _EGL_PBUFFER_SURFACE:
+            GLX_PREFIX(glXDestroyPbuffer)(d->dpy, (GLXPbuffer)(s->surf));
+            convert_error();
+            break;
+
+        default:
+            _egl_errno = EGL_BAD_SURFACE;
+            return EGL_FALSE;
+    }
+
+    Xfree(s);
+    return (_egl_errno == EGL_SUCCESS) ? EGL_TRUE : EGL_FALSE;
+}
+
+/* public API */
+
+/*
+ * cheat.  EGLConfig -> GLXFBConfig.
+ */
+PUBLIC EGLBoolean eglChooseConfig(EGLDisplay display,
+                                  EGLint const *attrib_list,
+                                  EGLConfig *configs,
+                                  EGLint config_size,
+                                  EGLint *num_config)
+{
+    egl_display *d = display;
+    int i = 0;
+    int n = 0;
+    int *glx_attrib_list;
+    GLXFBConfig *fbconfigs;
+
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+    if (!num_config)
+    {
+        _egl_errno = EGL_BAD_PARAMETER;
+        return EGL_FALSE;
+    }
+
+    /* XXX need to check for EGL_BAD_ATTRIBUTE */
+    if (!(glx_attrib_list = convert_attrib_egl_to_glx(attrib_list)))
+        return EGL_FALSE;
+        
+    if (!(fbconfigs = GLX_PREFIX(glXChooseFBConfig)(d->dpy,
+                                                    DefaultScreen(d->dpy),
+                                                    glx_attrib_list, &n)))
+    {
+        Xfree(glx_attrib_list);
+        return EGL_FALSE;
+    }
+
+    *num_config = n;
+    if (configs)
+        for (i = 0; i < config_size && i < n; i++)
+            configs[i] = fbconfigs[i];
+
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglCopyBuffers(EGLDisplay display,
+                                 EGLSurface surface,
+                                 NativePixmapType native_pixmap)
+{
+    return EGL_TRUE;
+}
+
+PUBLIC EGLContext eglCreateContext(EGLDisplay display,
+                                   EGLConfig config,
+                                   EGLContext share_context,
+                                   EGLint const *attrib_list)
+{
+    egl_context *newctx = EGL_NO_CONTEXT;
+    GLXContext sharectx = NULL;
+    int *glx_attrib;
+    int default_attrib[] = { GLX_RED_SIZE, 1, None };
+    egl_display *d = display;
+    egl_context *share = share_context;
+
+    DISPLAY_CHECK(d);
+    
+    if (share)
+    {
+        if (!share->ctx)
+        {
+             _egl_errno = EGL_BAD_CONTEXT;
+            return EGL_NO_CONTEXT;
+        }
+        else sharectx = share->ctx;
+    }
+
+    if (!(newctx = Xmalloc(sizeof(egl_context))))
+        /* XXX out of memory in errno? */
+        return EGL_NO_CONTEXT;
+
+    newctx->visinfo = GLX_PREFIX(glXGetVisualFromFBConfig)(d->dpy, config);
+    if (!newctx->visinfo)
+    {
+        Xfree(newctx);
+        return EGL_NO_CONTEXT;
+    }
+
+    newctx->ctx = GLX_PREFIX(glXCreateContext)(d->dpy, newctx->visinfo,
+                                               sharectx, EGL_TRUE);
+    if (!newctx->ctx)
+    {
+        convert_error();
+        Xfree(newctx->visinfo);
+        Xfree(newctx);
+        return EGL_NO_CONTEXT;
+    }
+
+    newctx->read = EGL_NO_SURFACE;
+    newctx->draw = EGL_NO_SURFACE;
+    newctx->current = EGL_FALSE;
+    newctx->doomed = EGL_FALSE;
+
+    return (EGLContext)newctx;
+}
+
+PUBLIC EGLSurface eglCreatePbufferSurface(EGLDisplay display,
+                                          EGLConfig config,
+                                          EGLint const *attrib_list)
+{
+    EGLSurface newsurf = NULL;
+    egl_display *d = display;
+
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+
+    return EGL_NO_SURFACE;
+}
+
+PUBLIC EGLSurface eglCreatePixmapSurface(EGLDisplay display,
+                                         EGLConfig config,
+                                         NativePixmapType native_pixmap,
+                                         EGLint const *attrib_list)
+{
+    egl_surface *newsurf = NULL;
+    egl_display *d = display;
+
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+
+    if (!attrib_list || *attrib_list != EGL_NONE)
+    {
+        _egl_errno = EGL_BAD_ATTRIBUTE;
+        return EGL_NO_SURFACE;
+    }
+
+    newsurf = Xmalloc(sizeof(egl_surface));
+    newsurf->type = _EGL_PIXMAP_SURFACE;
+    newsurf->surf = glXCreateGLXPixmap(d->dpy, NULL /* XXX */,
+                                       (Pixmap)native_pixmap);
+
+    if (!newsurf->surf)
+    {
+        convert_error();
+        Xfree(newsurf);
+        return EGL_NO_SURFACE;
+    }
+
+    return newsurf;
+}
+
+PUBLIC EGLSurface eglCreateWindowSurface(EGLDisplay display,
+                                         EGLConfig config,
+                                         NativeWindowType native_window,
+                                         EGLint const *attrib_list)
+{
+    egl_display *d = display;
+    egl_surface *s;
+    int *glx_attrib;
+
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+
+    if (!(s = Xmalloc(sizeof(egl_surface))))
+        return EGL_NO_SURFACE;
+    s->type = _EGL_WINDOW_SURFACE;
+    s->surf = native_window;
+    s->current = EGL_FALSE;
+    s->doomed = EGL_FALSE;
+
+    return s;
+
+#if 0
+    /* This is ostensibly correct but glXCreateWindow generates BadRequest */
+    glx_attrib = convert_attrib_egl_to_glx(attrib_list);
+
+    w = GLX_PREFIX(glXCreateWindow)(d->dpy, config, (Window)native_window,
+                                    glx_attrib);
+
+    if (!w)
+    {
+        convert_error();
+        return EGL_NO_SURFACE;
+    }
+
+    return (EGLSurface) w;
+#endif
+}
+
+PUBLIC EGLBoolean eglDestroyContext(EGLDisplay display,
+                                    EGLContext context)
+{
+    egl_context *c = context;
+    egl_display *d = display;
+    DISPLAY_CHECK(d);
+    CONTEXT_CHECK(c);
+    INITED_CHECK(d);
+
+    if (c->current)
+        c->doomed = EGL_TRUE;
+    else
+        doDestroyContext(d, c);
+
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglDestroySurface(EGLDisplay display,
+                                    EGLSurface surface)
+{
+    egl_display *d = display;
+    egl_surface *s = surface;
+    DISPLAY_CHECK(d);
+    SURFACE_CHECK(s);
+
+    if (_egl_current_ctx->read == s || _egl_current_ctx->draw == s)
+    {
+        s->doomed = EGL_TRUE;
+        return EGL_TRUE;
+    }
+
+    return doDestroySurface(display, surface);
+}
+
+PUBLIC EGLBoolean eglGetConfigAttrib(EGLDisplay display,
+                                     EGLConfig config,
+                                     EGLint attribute,
+                                     EGLint *value)
+{
+    egl_display *d = display;
+    int glx_attr;
+    int glx_val;
+    int i;
+
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+
+    glx_attr = map_attrib_egl_to_glx(attribute);
+
+    i = GLX_PREFIX(glXGetFBConfigAttrib)(d->dpy, config, glx_attr, &glx_val);
+
+    switch (i)
+    {
+        case GLXBadFBConfig:
+            _egl_errno = EGL_BAD_CONFIG;
+            return EGL_FALSE;
+        default: break;
+    }
+
+    switch(attribute)
+    {
+        case EGL_CONFIG_CAVEAT:
+            if (glx_val == GLX_NONE)
+                *value = EGL_NONE;
+            else if (glx_val == GLX_SLOW_CONFIG)
+                *value = EGL_SLOW_CONFIG;
+            else if (glx_val == GLX_NON_CONFORMANT_CONFIG)
+                *value = EGL_NON_CONFORMANT_CONFIG;
+            break;
+        case EGL_TRANSPARENT_TYPE:
+            if (glx_val == GLX_NONE)
+                *value = EGL_NONE;
+            else if (glx_val == GLX_TRANSPARENT_RGB)
+                *value = EGL_TRANSPARENT_RGB;
+            break;
+        case EGL_SURFACE_TYPE: /* XXX */ break;
+        default:
+            *value = glx_val;
+            break;
+    }
+
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglGetConfigs(EGLDisplay display,
+                                EGLConfig *configs,
+                                EGLint config_size,
+                                EGLint *num_config)
+{
+    egl_display *d = display;
+    int n;
+    GLXFBConfig *glxconfigs;
+
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+
+    if (!num_config)
+    {
+        _egl_errno = EGL_BAD_PARAMETER;
+        return EGL_FALSE;
+    }
+
+    glxconfigs = glXGetFBConfigs(d->dpy, DefaultScreen(d->dpy), &n);
+    if (!glxconfigs)
+    {
+        _egl_errno = EGL_BAD_PARAMETER;
+        return EGL_FALSE;
+    }
+
+    *num_config = n;
+    if (configs)
+    {
+        int i;
+        for (i = 0; i < config_size && i < n; i++)
+        {
+            configs[i] = glxconfigs[i];
+        }
+    }
+
+    return EGL_TRUE;
+}
+
+PUBLIC EGLContext eglGetCurrentContext(void)
+{
+    return _egl_current_ctx;
+}
+
+PUBLIC EGLDisplay eglGetCurrentDisplay(void)
+{
+    return _egl_current_dpy;
+}
+
+PUBLIC EGLSurface eglGetCurrentSurface(EGLint readdraw)
+{
+    switch (readdraw)
+    {
+        case EGL_DRAW:  return _egl_current_ctx->draw;
+        case EGL_READ:  return _egl_current_ctx->read;
+        default:        return EGL_NO_SURFACE;
+    }
+}
+
+/*
+ * The app is assumed to pass in a valid Display already.
+ */
+PUBLIC EGLDisplay eglGetDisplay(NativeDisplayType native_display)
+{
+    egl_display *ret = Xmalloc(sizeof(egl_display));
+    if (native_display == EGL_DEFAULT_DISPLAY)
+    {
+        ret->dpy = XOpenDisplay(NULL);
+    }
+    else ret->dpy = (Display *)native_display;
+    return ret;
+}
+
+PUBLIC EGLint eglGetError(void)
+{
+    EGLint ret = _egl_errno;
+    _egl_errno = EGL_SUCCESS;
+    return ret;
+}
+
+
+PUBLIC void (*eglGetProcAddress(char const *procname))(void)
+{
+    /* XXX extend this for the egl* extension funcs? */
+    return glXGetProcAddress(procname);
+}
+
+/*
+ * Only EGL 1.0 is supported for now.  1.1 is icky.
+ */
+PUBLIC EGLBoolean eglInitialize(EGLDisplay display,
+                                EGLint *major,
+                                EGLint *minor)
+{
+    egl_display *d = display;
+    DISPLAY_CHECK(d);
+
+    d->initialized = EGL_TRUE;
+
+    if (major) *major = 1;
+    if (minor) *minor = 0;
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglMakeCurrent(EGLDisplay display,
+                                 EGLSurface draw,
+                                 EGLSurface read,
+                                 EGLContext context)
+{
+    egl_surface *oldread;
+    egl_surface *olddraw;
+    egl_context *oldcontext;
+    egl_display *d = display;
+    egl_context *c = context;
+    egl_surface *newdraw = draw;
+    egl_surface *newread = read;
+    DISPLAY_CHECK(d);
+    CONTEXT_CHECK(c);
+
+    oldread = c->read;
+    olddraw = c->draw;
+    oldcontext = _egl_current_ctx;
+    
+    if (glXMakeContextCurrent(d->dpy,
+                              (GLXDrawable) (newdraw ? newdraw->surf : NULL),
+                              (GLXDrawable) (newread ? newread->surf : NULL),
+                              c->ctx))
+    {
+        EGLint saved_errno = _egl_errno;
+        
+        /* handle lazy demolition of the old surfaces and context */
+        if (oldread && oldread->doomed)
+        {
+            doDestroySurface(d, oldread);
+            oldcontext->read = EGL_NO_SURFACE;
+        }
+        if (olddraw && olddraw->doomed)
+        {
+            doDestroySurface(d, olddraw);
+            oldcontext->draw = EGL_NO_SURFACE;
+        }
+        if (oldcontext && oldcontext->doomed)
+            doDestroyContext(d, oldcontext);
+        _egl_errno = saved_errno;       /* don't worry if anything failed */
+
+        if (oldcontext)
+            oldcontext->current = EGL_FALSE;
+        c->current = EGL_TRUE;
+
+        c->read = read;
+        c->draw = draw;
+        _egl_current_ctx = c;
+
+        return EGL_TRUE;
+    } else {
+        convert_error();
+        return EGL_FALSE;
+    }
+}
+
+PUBLIC EGLBoolean eglQueryContext(EGLDisplay display,
+                                  EGLContext context,
+                                  EGLint attribute,
+                                  EGLint *value)
+{
+    egl_display *d = display;
+    egl_context *c = context;
+    DISPLAY_CHECK(d);
+    CONTEXT_CHECK(c);
+    INITED_CHECK(d);
+
+    switch (attribute)
+    {
+        case EGL_CONFIG_ID:
+            *value = c->config_id;
+            break;
+        default:
+            _egl_errno = EGL_BAD_ATTRIBUTE;
+            return EGL_FALSE;
+    }
+
+    return EGL_TRUE;
+}
+
+PUBLIC char const *eglQueryString(EGLDisplay display,
+                                  EGLint name)
+{
+    static const char *vendor = "DRI Ninja Strike Force";
+    static const char *version = "1.0 Mesa 6.3"; /* XXX automate this */
+    static const char *extensions = "";
+    switch (name)
+    {
+        case EGL_VENDOR:        return vendor;
+        case EGL_VERSION:       return version;
+        case EGL_EXTENSIONS:    return extensions;
+        default:
+            _egl_errno = EGL_BAD_PARAMETER;
+            return NULL;
+    }
+}
+
+PUBLIC EGLBoolean eglQuerySurface(EGLDisplay display,
+                                  EGLSurface surface,
+                                  EGLint attribute,
+                                  EGLint *value)
+{
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglSwapBuffers(EGLDisplay display,
+                                 EGLSurface surface)
+{
+    egl_display *d = display;
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglTerminate(EGLDisplay display)
+{
+    egl_display *d = display;
+    DISPLAY_CHECK(d);
+    INITED_CHECK(d);
+    XCloseDisplay(d->dpy);
+    Xfree(display);
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglWaitGL(void)
+{
+    GLX_PREFIX(glXWaitGL)();
+    return EGL_TRUE;
+}
+
+PUBLIC EGLBoolean eglWaitNative(EGLint engine)
+{
+    if (engine == EGL_CORE_NATIVE_ENGINE)
+    {
+        GLX_PREFIX(glXWaitX)();
+        return EGL_TRUE;
+    } else {
+        _egl_errno = EGL_BAD_PARAMETER;
+        return EGL_FALSE;
+    }
+}
--- /dev/null	2004-05-08 19:17:35.000000000 -0400
+++ include/GL/egl.h	2005-01-19 18:44:59.000000000 -0500
@@ -0,0 +1,230 @@
+#ifndef _EGL_H
+#define _EGL_H
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.0 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+#include <GL/gl.h>
+#include <GL/egltypes.h>
+
+/* XXX none of this crap belongs here */
+#define GL_OES_VERSION_1_0  1
+#define GL_OES_read_format  1
+#define GL_OES_compressed_paletted_texture 1
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#define GL_PALETTE4_RGB8_OES        0x8B90
+#define GL_PALETTE4_RGBA8_OES       0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES    0x8B92
+#define GL_PALETTE4_RGBA4_OES       0x8B93
+#define GL_PALETTE4_RGB5_A1_OES     0x8B94
+#define GL_PALETTE8_RGB8_OES        0x8B95
+#define GL_PALETTE8_RGBA8_OES       0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES    0x8B97
+#define GL_PALETTE8_RGBA4_OES       0x8B98
+#define GL_PALETTE8_RGB5_A1_OES     0x8B99
+/* XXX end incorrect crap */
+
+/*
+** Versioning and extensions
+*/
+#define EGL_VERSION_1_0		       1
+#define EGL_VERSION_1_1		       1
+
+/*
+** Boolean
+*/
+#define EGL_FALSE		       0
+#define EGL_TRUE		       1
+
+/*
+** Errors
+*/
+#define EGL_SUCCESS		       0x3000
+#define EGL_NOT_INITIALIZED	       0x3001
+#define EGL_BAD_ACCESS		       0x3002
+#define EGL_BAD_ALLOC		       0x3003
+#define EGL_BAD_ATTRIBUTE	       0x3004
+#define EGL_BAD_CONFIG		       0x3005
+#define EGL_BAD_CONTEXT		       0x3006
+#define EGL_BAD_CURRENT_SURFACE        0x3007
+#define EGL_BAD_DISPLAY		       0x3008
+#define EGL_BAD_MATCH		       0x3009
+#define EGL_BAD_NATIVE_PIXMAP	       0x300A
+#define EGL_BAD_NATIVE_WINDOW	       0x300B
+#define EGL_BAD_PARAMETER	       0x300C
+#define EGL_BAD_SURFACE		       0x300D
+#define EGL_CONTEXT_LOST	       0x300E
+/* 0x300F - 0x301F reserved for additional errors. */
+
+/*
+** Config attributes
+*/
+#define EGL_BUFFER_SIZE		       0x3020
+#define EGL_ALPHA_SIZE		       0x3021
+#define EGL_BLUE_SIZE		       0x3022
+#define EGL_GREEN_SIZE		       0x3023
+#define EGL_RED_SIZE		       0x3024
+#define EGL_DEPTH_SIZE		       0x3025
+#define EGL_STENCIL_SIZE	       0x3026
+#define EGL_CONFIG_CAVEAT	       0x3027
+#define EGL_CONFIG_ID		       0x3028
+#define EGL_LEVEL		       0x3029
+#define EGL_MAX_PBUFFER_HEIGHT	       0x302A
+#define EGL_MAX_PBUFFER_PIXELS	       0x302B
+#define EGL_MAX_PBUFFER_WIDTH	       0x302C
+#define EGL_NATIVE_RENDERABLE	       0x302D
+#define EGL_NATIVE_VISUAL_ID	       0x302E
+#define EGL_NATIVE_VISUAL_TYPE	       0x302F
+/*#define EGL_PRESERVED_RESOURCES	 0x3030*/
+#define EGL_SAMPLES		       0x3031
+#define EGL_SAMPLE_BUFFERS	       0x3032
+#define EGL_SURFACE_TYPE	       0x3033
+#define EGL_TRANSPARENT_TYPE	       0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE     0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE    0x3036
+#define EGL_TRANSPARENT_RED_VALUE      0x3037
+#define EGL_NONE		       0x3038	/* Also a config value */
+#define EGL_BIND_TO_TEXTURE_RGB        0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA       0x303A
+#define EGL_MIN_SWAP_INTERVAL	       0x303B
+#define EGL_MAX_SWAP_INTERVAL	       0x303C
+
+/*
+** Config values
+*/
+#define EGL_DONT_CARE		       ((EGLint) -1)
+
+#define EGL_SLOW_CONFIG		       0x3050	/* EGL_CONFIG_CAVEAT value */
+#define EGL_NON_CONFORMANT_CONFIG      0x3051	/* " */
+#define EGL_TRANSPARENT_RGB	       0x3052	/* EGL_TRANSPARENT_TYPE value */
+#define EGL_NO_TEXTURE		       0x305C	/* EGL_TEXTURE_FORMAT/TARGET value */
+#define EGL_TEXTURE_RGB		       0x305D	/* EGL_TEXTURE_FORMAT value */
+#define EGL_TEXTURE_RGBA	       0x305E	/* " */
+#define EGL_TEXTURE_2D		       0x305F	/* EGL_TEXTURE_TARGET value */
+
+/*
+** Config attribute mask bits
+*/
+#define EGL_PBUFFER_BIT		       0x01	/* EGL_SURFACE_TYPE mask bit */
+#define EGL_PIXMAP_BIT		       0x02	/* " */
+#define EGL_WINDOW_BIT		       0x04	/* " */
+
+/*
+** String names
+*/
+#define EGL_VENDOR		       0x3053	/* eglQueryString target */
+#define EGL_VERSION		       0x3054	/* " */
+#define EGL_EXTENSIONS		       0x3055	/* " */
+
+/*
+** Surface attributes
+*/
+#define EGL_HEIGHT		       0x3056
+#define EGL_WIDTH		       0x3057
+#define EGL_LARGEST_PBUFFER	       0x3058
+#define EGL_TEXTURE_FORMAT	       0x3080	/* For pbuffers bound as textures */
+#define EGL_TEXTURE_TARGET	       0x3081	/* " */
+#define EGL_MIPMAP_TEXTURE	       0x3082	/* " */
+#define EGL_MIPMAP_LEVEL	       0x3083	/* " */
+
+/*
+** BindTexImage / ReleaseTexImage buffer target
+*/
+#define EGL_BACK_BUFFER		       0x3084
+
+/*
+** Current surfaces
+*/
+#define EGL_DRAW		       0x3059
+#define EGL_READ		       0x305A
+
+/*
+** Engines
+*/
+#define EGL_CORE_NATIVE_ENGINE	       0x305B
+
+/* 0x305C-0x3FFFF reserved for future use */
+
+/*
+** Functions
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+GLAPI EGLint APIENTRY eglGetError (void);
+
+GLAPI EGLDisplay APIENTRY eglGetDisplay (NativeDisplayType display);
+GLAPI EGLBoolean APIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
+GLAPI EGLBoolean APIENTRY eglTerminate (EGLDisplay dpy);
+GLAPI const char * APIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
+GLAPI void (* APIENTRY eglGetProcAddress (const char *procname))();
+
+GLAPI EGLBoolean APIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+GLAPI EGLBoolean APIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+GLAPI EGLBoolean APIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+
+GLAPI EGLSurface APIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
+GLAPI EGLSurface APIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list);
+GLAPI EGLSurface APIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
+GLAPI EGLBoolean APIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+
+/* EGL 1.1 render-to-texture APIs */
+GLAPI EGLBoolean APIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+GLAPI EGLBoolean APIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+GLAPI EGLBoolean APIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+
+/* EGL 1.1 swap control API */
+GLAPI EGLBoolean APIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
+
+GLAPI EGLContext APIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
+GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+GLAPI EGLContext APIENTRY eglGetCurrentContext (void);
+GLAPI EGLSurface APIENTRY eglGetCurrentSurface (EGLint readdraw);
+GLAPI EGLDisplay APIENTRY eglGetCurrentDisplay (void);
+GLAPI EGLBoolean APIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+
+GLAPI EGLBoolean APIENTRY eglWaitGL (void);
+GLAPI EGLBoolean APIENTRY eglWaitNative (EGLint engine);
+GLAPI EGLBoolean APIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface draw);
+GLAPI EGLBoolean APIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _EGL_H */
--- /dev/null	2004-05-08 19:17:35.000000000 -0400
+++ include/GL/egltypes.h	2005-01-19 00:21:45.000000000 -0500
@@ -0,0 +1,48 @@
+/*
+ * egltypes.h - EGL API compatibility
+ *
+ * The intention here is to support multiple EGL implementations for the
+ * various backends - GLX, AGL, WGL, Solo - so we define the EGL types as
+ * opaque handles.  We also define the Native types as opaque handles for
+ * now, which should be fine for GLX and Solo but the others who knows.
+ * They can extend this later.
+ *
+ * We require that 'int' be 32 bits.  Other than that this should be pretty
+ * portable.
+ *
+ * Derived from the OpenGL|ES 1.1 egl.h on the Khronos website:
+ * http://www.khronos.org/opengles/spec_headers/opengles1_1/egl.h
+ *
+ */
+
+#ifndef _EGLTYPES_H
+#define _EGLTYPES_H
+
+#include <sys/types.h>
+
+/*
+ * Native types
+ */
+typedef void    *NativeDisplayType;
+typedef void    *NativePixmapType;
+typedef void    *NativeWindowType;
+
+/*
+ * Types and resources
+ */
+typedef GLboolean   EGLBoolean;
+typedef GLint       EGLint;
+typedef void        *EGLDisplay;
+typedef void        *EGLConfig;
+typedef void        *EGLSurface;
+typedef void        *EGLContext;
+
+/*
+ * EGL and native handle values
+ */
+#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
+#define EGL_NO_CONTEXT      ((EGLContext)0)
+#define EGL_NO_DISPLAY      ((EGLDisplay)0)
+#define EGL_NO_SURFACE      ((EGLSurface)0)
+
+#endif /* _EGLTYPES_H */

Attachment: pgpe29fyHrMAS.pgp
Description: PGP signature

Reply via email to