summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Jackson <ajax@freedesktop.org>2004-10-25 21:09:16 +0000
committerAdam Jackson <ajax@freedesktop.org>2004-10-25 21:09:16 +0000
commitcb3610e37c4c0a40520441b8515d044dabcc8854 (patch)
tree4c3a60c9381bc03c4ad58f9170e99d8237b1d81d /src
parentbcd8735546f3842f917f2cdc4ff530e4215f01a1 (diff)
Import the GLX client side library, formerly from xc/lib/GL/glx. Build it
by adding 'glx/x11' to SRC_DIRS in your build config.
Diffstat (limited to 'src')
-rw-r--r--src/glx/x11/Makefile115
-rw-r--r--src/glx/x11/XF86dri.c615
-rw-r--r--src/glx/x11/clientattrib.c186
-rw-r--r--src/glx/x11/compsize.c522
-rw-r--r--src/glx/x11/dispatch.c73
-rw-r--r--src/glx/x11/dri_glx.c475
-rw-r--r--src/glx/x11/dri_glx.h61
-rw-r--r--src/glx/x11/eval.c162
-rw-r--r--src/glx/x11/g_render.c819
-rw-r--r--src/glx/x11/g_single.c663
-rw-r--r--src/glx/x11/g_vendpriv.c88
-rw-r--r--src/glx/x11/glx_pbuffer.c556
-rw-r--r--src/glx/x11/glx_query.c102
-rw-r--r--src/glx/x11/glx_texture_compression.c346
-rw-r--r--src/glx/x11/glxclient.h833
-rw-r--r--src/glx/x11/glxcmds.c3082
-rw-r--r--src/glx/x11/glxext.c1872
-rw-r--r--src/glx/x11/glxextensions.c710
-rw-r--r--src/glx/x11/glxextensions.h253
-rw-r--r--src/glx/x11/indirect.h647
-rw-r--r--src/glx/x11/indirect_init.c624
-rw-r--r--src/glx/x11/indirect_init.h42
-rw-r--r--src/glx/x11/indirect_wrap.h730
-rw-r--r--src/glx/x11/packrender.h250
-rw-r--r--src/glx/x11/packsingle.h219
-rw-r--r--src/glx/x11/packvendpriv.h220
-rw-r--r--src/glx/x11/pixel.c462
-rw-r--r--src/glx/x11/pixelstore.c301
-rw-r--r--src/glx/x11/render2.c512
-rw-r--r--src/glx/x11/renderpix.c906
-rw-r--r--src/glx/x11/single2.c1097
-rw-r--r--src/glx/x11/singlepix.c415
-rw-r--r--src/glx/x11/size.h72
-rw-r--r--src/glx/x11/vertarr.c1152
-rw-r--r--src/glx/x11/xf86dri.h122
-rw-r--r--src/glx/x11/xf86dristr.h343
-rw-r--r--src/glx/x11/xfont.c377
37 files changed, 20024 insertions, 0 deletions
diff --git a/src/glx/x11/Makefile b/src/glx/x11/Makefile
new file mode 100644
index 0000000000..e5b9bff158
--- /dev/null
+++ b/src/glx/x11/Makefile
@@ -0,0 +1,115 @@
+TOP = ../../..
+include $(TOP)/configs/current
+
+# This is a bit messy. We want this libGL to be capable of loading old
+# interface drivers, so we have to turn off DRI_NEW_INTERFACE_ONLY. However,
+# glcontextmodes.c is built elsewhere with DNIO on, so we symlink it across.
+#
+# Furthermore, context creation has evolved over the years, such that this
+# code will not build with DNIO defined. When we finally drop old interface
+# support in libGL, we need to clean up both glxcmds.c and dri_interface.h.
+
+DEFINES += -DGLX_DIRECT_RENDERING -DGLXEXT -DXF86DRI -DGLX_USE_DLOPEN \
+ -DGLX_USE_MESA -DXF86VIDMODE -D_REENTRANT -UDRI_NEW_INTERFACE_ONLY \
+ -Werror
+
+C_SOURCES = \
+ $(TOP)/src/mesa/glapi/glapi.c \
+ $(TOP)/src/mesa/glapi/glthread.c \
+ glcontextmodes.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drm.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drmHash.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drmRandom.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drmSL.c \
+ clientattrib.c \
+ compsize.c \
+ dispatch.c \
+ eval.c \
+ g_render.c \
+ g_single.c \
+ g_vendpriv.c \
+ glxcmds.c \
+ glxext.c \
+ glxextensions.c \
+ indirect_init.c \
+ pixel.c \
+ pixelstore.c \
+ render2.c \
+ renderpix.c \
+ single2.c \
+ singlepix.c \
+ vertarr.c \
+ xfont.c \
+ glx_pbuffer.c \
+ glx_query.c \
+ glx_texture_compression.c \
+ dri_glx.c \
+ XF86dri.c \
+
+X86_SOURCES = $(TOP)/src/mesa/x86/glapi_x86.S
+
+# ASM_SOURCES = $(X86_SOURCES)
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+
+INCLUDES = -I. $(INCLUDE_DIRS)
+
+INCLUDE_DIRS = \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL/internal \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/math \
+ -I$(TOP)/src/mesa/transform \
+ -I$(TOP)/src/mesa/swrast \
+ -I$(TOP)/src/mesa/swrast_setup \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ -I$(DRM_SOURCE_PATH)/libdrm \
+ -I$(DRM_SOURCE_PATH)/shared
+
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+##### TARGETS #####
+
+default: depend $(LIB_DIR)/$(GL_LIB_NAME)
+
+glcontextmodes.c:
+ ln -s $(TOP)/src/mesa/drivers/dri/common/glcontextmodes.c .
+
+# Make libGL
+$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
+ CC=$(CC) CXX=$(CXX) $(TOP)/bin/mklib -o $(GL_LIB) -major 1 -minor 2 $(MKLIB_OPTIONS) \
+ -install $(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
+
+
+drmtest: xf86drm.o drmtest.o
+ rm -f drmtest && $(CC) -o drmtest xf86drm.o drmtest.o
+
+
+depend: $(C_SOURCES) $(ASM_SOURCES)
+ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(ASM_SOURCES) \
+ > /dev/null 2>&1
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` `find ../include`
+
+
+# Remove .o and backup files
+clean:
+ -rm -f $(LIB_DIR)/libGL.so*
+ -rm -f *.o *~
+ -rm -f depend
+
+include depend
diff --git a/src/glx/x11/XF86dri.c b/src/glx/x11/XF86dri.c
new file mode 100644
index 0000000000..cccc380507
--- /dev/null
+++ b/src/glx/x11/XF86dri.c
@@ -0,0 +1,615 @@
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include "xf86dristr.h"
+#include <X11/extensions/Xext.h>
+#include "extutil.h"
+
+static XExtensionInfo _xf86dri_info_data;
+static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
+static char *xf86dri_extension_name = XF86DRINAME;
+
+#define XF86DRICheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86dri_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static /* const */ XExtensionHooks xf86dri_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info,
+ xf86dri_extension_name,
+ &xf86dri_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-DRI Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
+Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ } else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+ int* patchVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryVersionReply rep;
+ xXF86DRIQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable)
+ Display* dpy;
+ int screen;
+ Bool* isCapable;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReq *req;
+
+ TRACE("QueryDirectRenderingCapable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryDirectRenderingCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return False");
+ return False;
+ }
+ *isCapable = rep.isCapable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return True");
+ return True;
+}
+
+Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString)
+ Display* dpy;
+ int screen;
+ drm_handle_t * hSAREA;
+ char **busIdString;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIOpenConnectionReply rep;
+ xXF86DRIOpenConnectionReq *req;
+
+ TRACE("OpenConnection...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIOpenConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIOpenConnection;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+
+ *hSAREA = rep.hSAREALow;
+#ifdef LONG64
+ *hSAREA |= ((drm_handle_t)rep.hSAREAHigh) << 32;
+#endif
+
+ if (rep.length) {
+ if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+ _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+ _XReadPad(dpy, *busIdString, rep.busIdStringLength);
+ } else {
+ *busIdString = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return True");
+ return True;
+}
+
+Bool XF86DRIAuthConnection(dpy, screen, magic)
+ Display* dpy;
+ int screen;
+ drm_magic_t magic;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIAuthConnectionReq *req;
+ xXF86DRIAuthConnectionReply rep;
+
+ TRACE("AuthConnection...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIAuthConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIAuthConnection;
+ req->screen = screen;
+ req->magic = magic;
+ rep.authenticated = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return True");
+ return True;
+}
+
+Bool XF86DRICloseConnection(dpy, screen)
+ Display* dpy;
+ int screen;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICloseConnectionReq *req;
+
+ TRACE("CloseConnection...");
+
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICloseConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICloseConnection;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CloseConnection... return True");
+ return True;
+}
+
+Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
+ ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
+ Display* dpy;
+ int screen;
+ int* ddxDriverMajorVersion;
+ int* ddxDriverMinorVersion;
+ int* ddxDriverPatchVersion;
+ char** clientDriverName;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetClientDriverNameReply rep;
+ xXF86DRIGetClientDriverNameReq *req;
+
+ TRACE("GetClientDriverName...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetClientDriverName, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetClientDriverName;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+
+ *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
+
+ if (rep.length) {
+ if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+ _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+ _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
+ } else {
+ *clientDriverName = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return True");
+ return True;
+}
+
+Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context, hHWContext)
+ Display* dpy;
+ int screen;
+ int configID;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReq *req;
+
+ TRACE("CreateContext...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateContext;
+ req->visual = configID;
+ req->screen = screen;
+ *context = XAllocID(dpy);
+ req->context = *context;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return False");
+ return False;
+ }
+ *hHWContext = rep.hHWContext;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return True");
+ return True;
+}
+
+Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
+ Display* dpy;
+ int screen;
+ Visual* visual;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
+ context, hHWContext );
+}
+
+GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen,
+ __DRIid context )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyContextReq *req;
+
+ TRACE("DestroyContext...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyContext;
+ req->screen = screen;
+ req->context = context;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyContext... return True");
+ return True;
+}
+
+GLboolean XF86DRICreateDrawable( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable, drm_drawable_t * hHWDrawable )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateDrawableReply rep;
+ xXF86DRICreateDrawableReq *req;
+
+ TRACE("CreateDrawable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return False");
+ return False;
+ }
+ *hHWDrawable = rep.hHWDrawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return True");
+ return True;
+}
+
+GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyDrawableReq *req;
+
+ TRACE("DestroyDrawable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyDrawable... return True");
+ return True;
+}
+
+Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
+ unsigned int* index, unsigned int* stamp,
+ int* X, int* Y, int* W, int* H,
+ int* numClipRects, drm_clip_rect_t ** pClipRects,
+ int* backX, int* backY,
+ int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDrawableInfoReply rep;
+ xXF86DRIGetDrawableInfoReq *req;
+ int total_rects;
+
+ TRACE("GetDrawableInfo...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDrawableInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDrawableInfo;
+ req->screen = screen;
+ req->drawable = drawable;
+
+ if (!_XReply(dpy, (xReply *)&rep, 1, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+ *index = rep.drawableTableIndex;
+ *stamp = rep.drawableTableStamp;
+ *X = (int)rep.drawableX;
+ *Y = (int)rep.drawableY;
+ *W = (int)rep.drawableWidth;
+ *H = (int)rep.drawableHeight;
+ *numClipRects = rep.numClipRects;
+ total_rects = *numClipRects;
+
+ *backX = rep.backX;
+ *backY = rep.backY;
+ *numBackClipRects = rep.numBackClipRects;
+ total_rects += *numBackClipRects;
+
+#if 0
+ /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+ * backwards compatibility (Because of the >> 2 shift) but the fix
+ * enables multi-threaded apps to work.
+ */
+ if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply) +
+ total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
+ _XEatData(dpy, rep.length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+#endif
+
+ if (*numClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numClipRects);
+
+ *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pClipRects)
+ _XRead(dpy, (char*)*pClipRects, len);
+ } else {
+ *pClipRects = NULL;
+ }
+
+ if (*numBackClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
+
+ *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pBackClipRects)
+ _XRead(dpy, (char*)*pBackClipRects, len);
+ } else {
+ *pBackClipRects = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return True");
+ return True;
+}
+
+Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer,
+ fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
+ Display* dpy;
+ int screen;
+ drm_handle_t * hFrameBuffer;
+ int* fbOrigin;
+ int* fbSize;
+ int* fbStride;
+ int* devPrivateSize;
+ void** pDevPrivate;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReq *req;
+
+ TRACE("GetDeviceInfo...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDeviceInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDeviceInfo;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+
+ *hFrameBuffer = rep.hFrameBufferLow;
+#ifdef LONG64
+ *hFrameBuffer |= ((drm_handle_t)rep.hFrameBufferHigh) << 32;
+#endif
+
+ *fbOrigin = rep.framebufferOrigin;
+ *fbSize = rep.framebufferSize;
+ *fbStride = rep.framebufferStride;
+ *devPrivateSize = rep.devPrivateSize;
+
+ if (rep.length) {
+ if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+ _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+ _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
+ } else {
+ *pDevPrivate = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return True");
+ return True;
+}
+
+Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
+ Display* dpy;
+ int screen;
+ Drawable drawable;
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return False;
+}
+
+Bool XF86DRICloseFullScreen(dpy, screen, drawable)
+ Display* dpy;
+ int screen;
+ Drawable drawable;
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return True;
+}
diff --git a/src/glx/x11/clientattrib.c b/src/glx/x11/clientattrib.c
new file mode 100644
index 0000000000..0672955311
--- /dev/null
+++ b/src/glx/x11/clientattrib.c
@@ -0,0 +1,186 @@
+/* $XFree86: xc/lib/GL/glx/clientattrib.c,v 1.5 2001/03/21 16:04:39 dawes Exp $ */
+/*
+** 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.1 (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-2000 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 <assert.h>
+#define NEED_GL_FUNCS_WRAPPED
+#include "glxclient.h"
+
+/*****************************************************************************/
+
+void glEnableClientState(GLenum array)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+
+ switch (array) {
+ case GL_COLOR_ARRAY:
+ ENABLE_ARRAY(state, color);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ ENABLE_ARRAY(state, edgeFlag);
+ break;
+ case GL_INDEX_ARRAY:
+ ENABLE_ARRAY(state, index);
+ break;
+ case GL_NORMAL_ARRAY:
+ ENABLE_ARRAY(state, normal);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ ENABLE_TEXARRAY(state, state->vertArray.activeTexture);
+ break;
+ case GL_VERTEX_ARRAY:
+ ENABLE_ARRAY(state, vertex);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY:
+ ENABLE_ARRAY(state, secondaryColor);
+ break;
+ case GL_FOG_COORD_ARRAY:
+ ENABLE_ARRAY(state, fogCoord);
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
+}
+
+void glDisableClientState(GLenum array)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+
+ switch (array) {
+ case GL_COLOR_ARRAY:
+ DISABLE_ARRAY(state, color);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ DISABLE_ARRAY(state, edgeFlag);
+ break;
+ case GL_INDEX_ARRAY:
+ DISABLE_ARRAY(state, index);
+ break;
+ case GL_NORMAL_ARRAY:
+ DISABLE_ARRAY(state, normal);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ DISABLE_TEXARRAY(state, state->vertArray.activeTexture);
+ break;
+ case GL_VERTEX_ARRAY:
+ DISABLE_ARRAY(state, vertex);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY:
+ DISABLE_ARRAY(state, secondaryColor);
+ break;
+ case GL_FOG_COORD_ARRAY:
+ DISABLE_ARRAY(state, fogCoord);
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
+}
+
+/************************************************************************/
+
+void glPushClientAttrib(GLuint mask)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXattribute **spp = gc->attributes.stackPointer, *sp;
+
+ if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
+ if (!(sp = *spp)) {
+ sp = (__GLXattribute *)Xmalloc(sizeof(__GLXattribute));
+ *spp = sp;
+ }
+ sp->mask = mask;
+ gc->attributes.stackPointer = spp + 1;
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ sp->storePack = state->storePack;
+ sp->storeUnpack = state->storeUnpack;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ sp->vertArray = state->vertArray;
+ }
+ } else {
+ __glXSetError(gc, GL_STACK_OVERFLOW);
+ return;
+ }
+}
+
+void glPopClientAttrib(void)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXattribute **spp = gc->attributes.stackPointer, *sp;
+ GLuint mask;
+
+ if (spp > &gc->attributes.stack[0]) {
+ --spp;
+ sp = *spp;
+ assert(sp != 0);
+ mask = sp->mask;
+ gc->attributes.stackPointer = spp;
+
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ state->storePack = sp->storePack;
+ state->storeUnpack = sp->storeUnpack;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ state->vertArray = sp->vertArray;
+ }
+
+ sp->mask = 0;
+ } else {
+ __glXSetError(gc, GL_STACK_UNDERFLOW);
+ return;
+ }
+}
+
+void __glFreeAttributeState(__GLXcontext *gc)
+{
+ __GLXattribute *sp, **spp;
+
+ for (spp = &gc->attributes.stack[0];
+ spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
+ spp++) {
+ sp = *spp;
+ if (sp) {
+ XFree((char *)sp);
+ } else {
+ break;
+ }
+ }
+}
+
+
diff --git a/src/glx/x11/compsize.c b/src/glx/x11/compsize.c
new file mode 100644
index 0000000000..a42e448e46
--- /dev/null
+++ b/src/glx/x11/compsize.c
@@ -0,0 +1,522 @@
+/* $XFree86: xc/lib/GL/glx/compsize.c,v 1.6 2004/01/28 18:11:38 alanh Exp $ */
+/*
+** 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.1 (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-2000 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 "glxclient.h"
+#include "size.h"
+
+/*
+** Return the number of elements per group of a specified format
+*/
+GLint __glElementsPerGroup(GLenum format, GLenum type)
+{
+ /*
+ ** To make row length computation valid for image extraction,
+ ** packed pixel types assume elements per group equals one.
+ */
+ switch(type) {
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
+ return 1;
+ default:
+ break;
+ }
+
+ switch(format) {
+ case GL_RGB:
+ case GL_BGR:
+ return 3;
+ case GL_422_EXT:
+ case GL_422_REV_EXT:
+ case GL_422_AVERAGE_EXT:
+ case GL_422_REV_AVERAGE_EXT:
+ case GL_YCBCR_422_APPLE:
+ case GL_LUMINANCE_ALPHA:
+ return 2;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ return 4;
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/*
+** Return the number of bytes per element, based on the element type (other
+** than GL_BITMAP).
+*/
+GLint __glBytesPerElement(GLenum type)
+{
+ switch(type) {
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ return 2;
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ return 1;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+/*
+** Compute memory required for internal packed array of data of given type
+** and format.
+*/
+GLint __glImageSize(GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type)
+{
+ int bytes_per_row;
+ int components;
+
+ if (width < 0 || height < 0 || depth < 0) {
+ return 0;
+ }
+ /*
+ ** Zero is returned if either format or type are invalid.
+ */
+ components = __glElementsPerGroup(format,type);
+ if (type == GL_BITMAP) {
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ bytes_per_row = (width + 7) >> 3;
+ } else {
+ return 0;
+ }
+ } else {
+ bytes_per_row = __glBytesPerElement(type) * width;
+ }
+ return bytes_per_row * height * depth * components;
+}
+
+GLint __glFogiv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_FOG_COLOR: return 4;
+ case GL_FOG_DENSITY: return 1;
+ case GL_FOG_END: return 1;
+ case GL_FOG_MODE: return 1;
+ case GL_FOG_INDEX: return 1;
+ case GL_FOG_START: return 1;
+ case GL_FOG_DISTANCE_MODE_NV: return 1;
+ case GL_FOG_OFFSET_VALUE_SGIX: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glFogfv_size(GLenum pname)
+{
+ return __glFogiv_size(pname);
+}
+
+GLint __glCallLists_size(GLsizei n, GLenum type)
+{
+ GLint size;
+
+ if (n < 0) return 0;
+ switch (type) {
+ case GL_BYTE: size = 1; break;
+ case GL_UNSIGNED_BYTE: size = 1; break;
+ case GL_SHORT: size = 2; break;
+ case GL_UNSIGNED_SHORT: size = 2; break;
+ case GL_INT: size = 4; break;
+ case GL_UNSIGNED_INT: size = 4; break;
+ case GL_FLOAT: size = 4; break;
+ case GL_2_BYTES: size = 2; break;
+ case GL_3_BYTES: size = 3; break;
+ case GL_4_BYTES: size = 4; break;
+ default:
+ return 0;
+ }
+ return n * size;
+}
+
+GLint __glDrawPixels_size(GLenum format, GLenum type, GLsizei w, GLsizei h)
+{
+ return __glImageSize( w, h, 1, format, type );
+}
+
+GLint __glBitmap_size(GLsizei w, GLsizei h)
+{
+ return __glDrawPixels_size(GL_COLOR_INDEX, GL_BITMAP, w, h);
+}
+
+GLint __glTexGendv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_GEN_MODE:
+ return 1;
+ case GL_OBJECT_PLANE:
+ case GL_EYE_PLANE:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexGenfv_size(GLenum e)
+{
+ return __glTexGendv_size(e);
+}
+
+GLint __glTexGeniv_size(GLenum e)
+{
+ return __glTexGendv_size(e);
+}
+
+GLint __glTexParameterfv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_PRIORITY:
+ case GL_TEXTURE_RESIDENT:
+
+ /* GL_SGIS_texture_lod / GL_EXT_texture_lod / GL 1.2 */
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+
+ /* GL_SGIX_texture_lod_bias */
+ case GL_TEXTURE_LOD_BIAS_S_SGIX:
+ case GL_TEXTURE_LOD_BIAS_T_SGIX:
+ case GL_TEXTURE_LOD_BIAS_R_SGIX:
+
+ /* GL_ARB_shadow / GL 1.4 */
+ case GL_TEXTURE_COMPARE_MODE:
+ case GL_TEXTURE_COMPARE_FUNC:
+
+ /* GL_SGIS_generate_mipmap / GL 1.4 */
+ case GL_GENERATE_MIPMAP:
+
+ /* GL_ARB_depth_texture / GL 1.4 */
+ case GL_DEPTH_TEXTURE_MODE:
+
+ /* GL_EXT_texture_lod_bias / GL 1.4 */
+ case GL_TEXTURE_LOD_BIAS:
+
+ /* GL_SGIX_shadow_ambient / GL_ARB_shadow_ambient */
+ case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
+
+ /* GL_SGIX_shadow */
+ case GL_TEXTURE_COMPARE_SGIX:
+ case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
+
+ /* GL_SGIX_texture_coordinate_clamp */
+ case GL_TEXTURE_MAX_CLAMP_S_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_T_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_R_SGIX:
+
+ /* GL_EXT_texture_filter_anisotropic */
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+
+ /* GL_NV_texture_expand_normal */
+ case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV:
+ return 1;
+
+ /* GL_SGIX_clipmap */
+ case GL_TEXTURE_CLIPMAP_CENTER_SGIX:
+ case GL_TEXTURE_CLIPMAP_OFFSET_SGIX:
+ return 2;
+
+ /* GL_SGIX_clipmap */
+ case GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX:
+ return 3;
+
+ case GL_TEXTURE_BORDER_COLOR:
+
+ /* GL_SGIX_texture_scale_bias */
+ case GL_POST_TEXTURE_FILTER_BIAS_SGIX:
+ case GL_POST_TEXTURE_FILTER_SCALE_SGIX:
+ return 4;
+
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexParameteriv_size(GLenum e)
+{
+ return __glTexParameterfv_size(e);
+}
+
+GLint __glTexEnvfv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_ENV_MODE:
+
+ /* GL_ARB_texture_env_combine / GL_EXT_texture_env_combine / GL 1.3 */
+ case GL_COMBINE_RGB:
+ case GL_COMBINE_ALPHA:
+ case GL_SOURCE0_RGB:
+ case GL_SOURCE1_RGB:
+ case GL_SOURCE2_RGB:
+ case GL_SOURCE0_ALPHA:
+ case GL_SOURCE1_ALPHA:
+ case GL_SOURCE2_ALPHA:
+ case GL_OPERAND0_RGB:
+ case GL_OPERAND1_RGB:
+ case GL_OPERAND0_ALPHA:
+ case GL_OPERAND1_ALPHA:
+ case GL_OPERAND2_RGB:
+ case GL_OPERAND2_ALPHA:
+ case GL_RGB_SCALE:
+ case GL_ALPHA_SCALE:
+
+ /* GL_EXT_texture_lod_bias / GL 1.4 */
+ case GL_TEXTURE_LOD_BIAS:
+
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ case GL_COORD_REPLACE_ARB:
+
+ /* GL_NV_texture_env_combine4 */
+ case GL_SOURCE3_RGB_NV:
+ case GL_SOURCE3_ALPHA_NV:
+ case GL_OPERAND3_RGB_NV:
+ case GL_OPERAND3_ALPHA_NV:
+ return 1;
+
+ case GL_TEXTURE_ENV_COLOR:
+ return 4;
+
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexEnviv_size(GLenum e)
+{
+ return __glTexEnvfv_size(e);
+}
+
+GLint __glTexImage1D_size(GLenum format, GLenum type, GLsizei w)
+{
+ return __glImageSize( w, 1, 1, format, type );
+}
+
+GLint __glTexImage2D_size(GLenum format, GLenum type, GLsizei w, GLsizei h)
+{
+ return __glImageSize( w, h, 1, format, type );
+}
+
+GLint __glTexImage3D_size(GLenum format, GLenum type, GLsizei w, GLsizei h,
+ GLsizei d)
+{
+ return __glImageSize( w, h, d, format, type );
+}
+
+GLint __glLightfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SPOT_EXPONENT: return 1;
+ case GL_SPOT_CUTOFF: return 1;
+ case GL_AMBIENT: return 4;
+ case GL_DIFFUSE: return 4;
+ case GL_SPECULAR: return 4;
+ case GL_POSITION: return 4;
+ case GL_SPOT_DIRECTION: return 3;
+ case GL_CONSTANT_ATTENUATION: return 1;
+ case GL_LINEAR_ATTENUATION: return 1;
+ case GL_QUADRATIC_ATTENUATION: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glLightiv_size(GLenum pname)
+{
+ return __glLightfv_size(pname);
+}
+
+GLint __glLightModelfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT: return 4;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER: return 1;
+ case GL_LIGHT_MODEL_TWO_SIDE: return 1;
+ case GL_LIGHT_MODEL_COLOR_CONTROL: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glLightModeliv_size(GLenum pname)
+{
+ return __glLightModelfv_size(pname);
+}
+
+GLint __glMaterialfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SHININESS: return 1;
+ case GL_EMISSION: return 4;
+ case GL_AMBIENT: return 4;
+ case GL_DIFFUSE: return 4;
+ case GL_SPECULAR: return 4;
+ case GL_AMBIENT_AND_DIFFUSE: return 4;
+ case GL_COLOR_INDEXES: return 3;
+ default:
+ return 0;
+ }
+}
+
+GLint __glMaterialiv_size(GLenum pname)
+{
+ return __glMaterialfv_size(pname);
+}
+
+GLint __glColorTableParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_COLOR_TABLE_FORMAT:
+ case GL_COLOR_TABLE_WIDTH:
+ case GL_COLOR_TABLE_RED_SIZE:
+ case GL_COLOR_TABLE_GREEN_SIZE:
+ case GL_COLOR_TABLE_BLUE_SIZE:
+ case GL_COLOR_TABLE_ALPHA_SIZE:
+ case GL_COLOR_TABLE_LUMINANCE_SIZE:
+ case GL_COLOR_TABLE_INTENSITY_SIZE:
+ return 1;
+ case GL_COLOR_TABLE_SCALE:
+ case GL_COLOR_TABLE_BIAS:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+GLint __glColorTableParameteriv_size(GLenum pname)
+{
+ return __glColorTableParameterfv_size(pname);
+}
+
+GLint __glConvolutionParameterfv_size(GLenum pname)
+{
+ switch(pname) {
+ case GL_CONVOLUTION_BORDER_MODE:
+ return 1;
+ case GL_CONVOLUTION_BORDER_COLOR:
+ case GL_CONVOLUTION_FILTER_SCALE:
+ case GL_CONVOLUTION_FILTER_BIAS:
+ return 4;
+ default: /* error: bad enum value */
+ return -1;
+ }
+}
+
+GLint __glConvolutionParameteriv_size(GLenum pname)
+{
+ return __glConvolutionParameterfv_size(pname);
+}
+
+GLint __glPointParameterfvARB_size(GLenum e)
+{
+ switch (e) {
+ case GL_POINT_SIZE_MIN:
+ case GL_POINT_SIZE_MAX:
+ case GL_POINT_FADE_THRESHOLD_SIZE:
+
+ /* GL_NV_point_sprite */
+ case GL_POINT_SPRITE_R_MODE_NV:
+ return 1;
+
+ case GL_POINT_DISTANCE_ATTENUATION:
+ return 3;
+
+ default:
+ return -1;
+ }
+}
+
+GLint __glPointParameteriv_size(GLenum e)
+{
+ return __glPointParameterfvARB_size(e);
+}
diff --git a/src/glx/x11/dispatch.c b/src/glx/x11/dispatch.c
new file mode 100644
index 0000000000..798da7371f
--- /dev/null
+++ b/src/glx/x11/dispatch.c
@@ -0,0 +1,73 @@
+/* $XFree86: xc/lib/GL/glx/dispatch.c,v 1.5 2003/06/30 01:45:10 torrey Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifndef GLX_USE_APPLEGL
+
+#include <GL/gl.h>
+#include "glapi.h"
+#include "glapitable.h"
+
+
+/*
+ * NOTE: this file implements C-based dispatch of the OpenGL entrypoints
+ * (glAccum, glBegin, etc).
+ * This code IS NOT USED if we're compiling on an x86 system and using
+ * the glapi_x86.S assembly code.
+ */
+
+
+#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM))
+
+#define KEYWORD1
+
+#define KEYWORD2
+
+#define NAME(func) gl##func
+
+#define DISPATCH(func, args, msg) \
+ const struct _glapi_table *dispatch; \
+ dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
+ (dispatch->func) args
+
+#define RETURN_DISPATCH(func, args, msg) \
+ const struct _glapi_table *dispatch; \
+ dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
+ return (dispatch->func) args
+
+
+#include "glapitemp.h"
+
+#endif /* USE_X86_ASM */
+
+#endif /* !GLX_USE_APPLEGL */
diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c
new file mode 100644
index 0000000000..f0b5f19eed
--- /dev/null
+++ b/src/glx/x11/dri_glx.c
@@ -0,0 +1,475 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/dri/dri_glx.c,v 1.14 2003/07/16 00:54:00 dawes Exp $ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <unistd.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include "extutil.h"
+#include "glxclient.h"
+#include "xf86dri.h"
+#include "sarea.h"
+#include <stdio.h>
+#include <dlfcn.h>
+#include "dri_glx.h"
+#include <sys/types.h>
+#include <stdarg.h>
+
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+#ifdef BUILT_IN_DRI_DRIVER
+
+extern void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config);
+
+
+#else /* BUILT_IN_DRI_DRIVER */
+
+
+#ifndef DEFAULT_DRIVER_DIR
+/* this is normally defined in the Imakefile */
+#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
+#endif
+
+static __DRIdriver *Drivers = NULL;
+
+
+/*
+ * printf wrappers
+ */
+
+static void InfoMessageF(const char *f, ...)
+{
+ va_list args;
+ const char *env;
+
+ if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) {
+ fprintf(stderr, "libGL: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ }
+}
+
+static void ErrorMessageF(const char *f, ...)
+{
+ va_list args;
+
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr, "libGL error: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ }
+}
+
+
+/*
+ * We'll save a pointer to this function when we couldn't find a
+ * direct rendering driver for a given screen.
+ */
+static void *DummyCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ (void) dpy;
+ (void) scrn;
+ (void) psc;
+ (void) numConfigs;
+ (void) config;
+ return NULL;
+}
+
+
+
+/*
+ * Extract the ith directory path out of a colon-separated list of
+ * paths.
+ * Input:
+ * index - index of path to extract (starting at zero)
+ * paths - the colon-separated list of paths
+ * dirLen - max length of result to store in <dir>
+ * Output:
+ * dir - the extracted directory path, dir[0] will be zero when
+ * extraction fails.
+ */
+static void ExtractDir(int index, const char *paths, int dirLen, char *dir)
+{
+ int i, len;
+ const char *start, *end;
+
+ /* find ith colon */
+ start = paths;
+ i = 0;
+ while (i < index) {
+ if (*start == ':') {
+ i++;
+ start++;
+ }
+ else if (*start == 0) {
+ /* end of string and couldn't find ith colon */
+ dir[0] = 0;
+ return;
+ }
+ else {
+ start++;
+ }
+ }
+
+ while (*start == ':')
+ start++;
+
+ /* find next colon, or end of string */
+ end = start + 1;
+ while (*end != ':' && *end != 0) {
+ end++;
+ }
+
+ /* copy string between <start> and <end> into result string */
+ len = end - start;
+ if (len > dirLen - 1)
+ len = dirLen - 1;
+ strncpy(dir, start, len);
+ dir[len] = 0;
+}
+
+
+/*
+ * Try to dlopen() the named driver. This function adds the
+ * "_dri.so" suffix to the driver name and searches the
+ * directories specified by the LIBGL_DRIVERS_PATH env var
+ * in order to find the driver.
+ * Input:
+ * driverName - a name like "tdfx", "i810", "mga", etc.
+ * Return:
+ * handle from dlopen, or NULL if driver file not found.
+ */
+static __DRIdriver *OpenDriver(const char *driverName)
+{
+ char *libPaths = NULL;
+ int i;
+ __DRIdriver *driver;
+
+ /* First, search Drivers list to see if we've already opened this driver */
+ for (driver = Drivers; driver; driver = driver->next) {
+ if (strcmp(driver->name, driverName) == 0) {
+ /* found it */
+ return driver;
+ }
+ }
+
+ if (geteuid() == getuid()) {
+ /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
+ libPaths = getenv("LIBGL_DRIVERS_PATH");
+ if (!libPaths)
+ libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */
+ }
+ if (!libPaths)
+ libPaths = DEFAULT_DRIVER_DIR;
+
+ for (i = 0; ; i++) {
+ char libDir[1000], realDriverName[200];
+ void *handle;
+ ExtractDir(i, libPaths, 1000, libDir);
+ if (!libDir[0])
+ break; /* ran out of paths to search */
+ snprintf(realDriverName, 200, "%s/%s_dri.so", libDir, driverName);
+ InfoMessageF("OpenDriver: trying %s\n", realDriverName);
+ handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
+ if (handle) {
+ /* allocate __DRIdriver struct */
+ driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver));
+ if (!driver)
+ return NULL; /* out of memory! */
+ /* init the struct */
+ driver->name = __glXstrdup(driverName);
+ if (!driver->name) {
+ Xfree(driver);
+ return NULL; /* out of memory! */
+ }
+
+ driver->createScreenFunc = (CreateScreenFunc)
+ dlsym(handle, "__driCreateScreen");
+ driver->createNewScreenFunc = (CreateNewScreenFunc)
+ dlsym(handle, "__driCreateNewScreen");
+
+ if ( (driver->createScreenFunc == NULL)
+ && (driver->createNewScreenFunc == NULL) ) {
+ /* If the driver doesn't have this symbol then something's
+ * really, really wrong.
+ */
+ ErrorMessageF("Neither __driCreateScreen or __driCreateNewScreen "
+ "are defined in %s_dri.so!\n", driverName);
+ Xfree(driver);
+ dlclose(handle);
+ continue;
+ }
+ driver->handle = handle;
+ /* put at head of linked list */
+ driver->next = Drivers;
+ Drivers = driver;
+ return driver;
+ }
+ else {
+ ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
+ }
+ }
+
+ ErrorMessageF("unable to find driver: %s_dri.so\n", driverName);
+ return NULL;
+}
+
+
+/*
+ * Given a display pointer and screen number, determine the name of
+ * the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
+ * Return True for success, False for failure.
+ */
+static Bool GetDriverName(Display *dpy, int scrNum, char **driverName)
+{
+ int directCapable;
+ Bool b;
+ int driverMajor, driverMinor, driverPatch;
+
+ *driverName = NULL;
+
+ if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
+ ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n");
+ return False;
+ }
+ if (!directCapable) {
+ ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n");
+ return False;
+ }
+
+ b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor,
+ &driverPatch, driverName);
+ if (!b) {
+ ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum);
+ return False;
+ }
+
+ InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
+ driverMajor, driverMinor, driverPatch, *driverName, scrNum);
+
+ return True;
+}
+
+
+/*
+ * Given a display pointer and screen number, return a __DRIdriver handle.
+ * Return NULL if anything goes wrong.
+ */
+__DRIdriver *driGetDriver(Display *dpy, int scrNum)
+{
+ char *driverName;
+ if (GetDriverName(dpy, scrNum, &driverName)) {
+ __DRIdriver *ret;
+ ret = OpenDriver(driverName);
+ if (driverName)
+ Xfree(driverName);
+ return ret;
+ }
+ return NULL;
+}
+
+
+/*
+ * Exported function for querying the DRI driver for a given screen.
+ *
+ * The returned char pointer points to a static array that will be
+ * overwritten by subsequent calls.
+ */
+const char *glXGetScreenDriver (Display *dpy, int scrNum) {
+ static char ret[32];
+ char *driverName;
+ if (GetDriverName(dpy, scrNum, &driverName)) {
+ int len;
+ if (!driverName)
+ return NULL;
+ len = strlen (driverName);
+ if (len >= 31)
+ return NULL;
+ memcpy (ret, driverName, len+1);
+ Xfree(driverName);
+ return ret;
+ }
+ return NULL;
+}
+
+
+/*
+ * Exported function for obtaining a driver's option list (UTF-8 encoded XML).
+ *
+ * The returned char pointer points directly into the driver. Therefore
+ * it should be treated as a constant.
+ *
+ * If the driver was not found or does not support configuration NULL is
+ * returned.
+ *
+ * Note: The driver remains opened after this function returns.
+ */
+const char *glXGetDriverConfig (const char *driverName) {
+ __DRIdriver *driver = OpenDriver (driverName);
+ if (driver)
+ return dlsym (driver->handle, "__driConfigOptions");
+ else
+ return NULL;
+}
+
+
+#endif /* BUILT_IN_DRI_DRIVER */
+
+
+/* This function isn't currently used.
+ */
+static void driDestroyDisplay(Display *dpy, void *private)
+{
+ __DRIdisplayPrivate *pdpyp = (__DRIdisplayPrivate *)private;
+
+ if (pdpyp) {
+ const int numScreens = ScreenCount(dpy);
+ int i;
+ for (i = 0; i < numScreens; i++) {
+ if (pdpyp->libraryHandles[i])
+ dlclose(pdpyp->libraryHandles[i]);
+ }
+ Xfree(pdpyp->libraryHandles);
+ Xfree(pdpyp);
+ }
+}
+
+
+/*
+ * Allocate, initialize and return a __DRIdisplayPrivate object.
+ * This is called from __glXInitialize() when we are given a new
+ * display pointer.
+ */
+void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
+{
+ const int numScreens = ScreenCount(dpy);
+ __DRIdisplayPrivate *pdpyp;
+ int eventBase, errorBase;
+ int major, minor, patch;
+ int scrn;
+
+ /* Initialize these fields to NULL in case we fail.
+ * If we don't do this we may later get segfaults trying to free random
+ * addresses when the display is closed.
+ */
+ pdisp->private = NULL;
+ pdisp->destroyDisplay = NULL;
+ pdisp->createScreen = NULL;
+
+ if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
+ return NULL;
+ }
+
+ if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) {
+ return NULL;
+ }
+
+ pdpyp = (__DRIdisplayPrivate *)Xmalloc(sizeof(__DRIdisplayPrivate));
+ if (!pdpyp) {
+ return NULL;
+ }
+
+ pdpyp->driMajor = major;
+ pdpyp->driMinor = minor;
+ pdpyp->driPatch = patch;
+
+ pdisp->destroyDisplay = driDestroyDisplay;
+
+ /* allocate array of pointers to createScreen funcs */
+ pdisp->createScreen = (CreateScreenFunc *) Xmalloc(numScreens * sizeof(void *));
+ if (!pdisp->createScreen) {
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+ /* allocate array of pointers to createScreen funcs */
+ pdisp->createNewScreen = (CreateNewScreenFunc *) Xmalloc(numScreens * sizeof(void *));
+ if (!pdisp->createNewScreen) {
+ Xfree(pdisp->createScreen);
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+ /* allocate array of library handles */
+ pdpyp->libraryHandles = (void **) Xmalloc(numScreens * sizeof(void*));
+ if (!pdpyp->libraryHandles) {
+ Xfree(pdisp->createNewScreen);
+ Xfree(pdisp->createScreen);
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+#ifdef BUILT_IN_DRI_DRIVER
+ /* we'll statically bind to the built-in __driCreateScreen function */
+ for (scrn = 0; scrn < numScreens; scrn++) {
+ pdisp->createScreen[scrn] = __driCreateScreen;
+ pdisp->createNewScreen[scrn] = NULL;
+ pdpyp->libraryHandles[scrn] = NULL;
+ }
+
+#else
+ /* dynamically discover DRI drivers for all screens, saving each
+ * driver's "__driCreateScreen" function pointer. That's the bootstrap
+ * entrypoint for all DRI drivers.
+ */
+ for (scrn = 0; scrn < numScreens; scrn++) {
+ __DRIdriver *driver = driGetDriver(dpy, scrn);
+ if (driver) {
+ pdisp->createScreen[scrn] = driver->createScreenFunc;
+ pdisp->createNewScreen[scrn] = driver->createNewScreenFunc;
+ pdpyp->libraryHandles[scrn] = driver->handle;
+ }
+ else {
+ pdisp->createScreen[scrn] = DummyCreateScreen;
+ pdisp->createNewScreen[scrn] = NULL;
+ pdpyp->libraryHandles[scrn] = NULL;
+ }
+ }
+#endif
+
+ return (void *)pdpyp;
+}
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/dri_glx.h b/src/glx/x11/dri_glx.h
new file mode 100644
index 0000000000..75561685c8
--- /dev/null
+++ b/src/glx/x11/dri_glx.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifndef _DRI_GLX_H_
+#define _DRI_GLX_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+struct __DRIdisplayPrivateRec {
+ /*
+ ** XFree86-DRI version information
+ */
+ int driMajor;
+ int driMinor;
+ int driPatch;
+
+ /*
+ ** Array of library handles [indexed by screen number]
+ */
+ void **libraryHandles;
+};
+
+typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
+typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
+typedef struct __DRIvisualPrivateRec __DRIvisualPrivate;
+typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
+typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
+
+#endif
+#endif /* _DRI_GLX_H_ */
diff --git a/src/glx/x11/eval.c b/src/glx/x11/eval.c
new file mode 100644
index 0000000000..aba4b5767c
--- /dev/null
+++ b/src/glx/x11/eval.c
@@ -0,0 +1,162 @@
+/* $XFree86$ */
+/*
+** 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.1 (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-2000 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 "packrender.h"
+
+/*
+** Routines to pack evaluator maps into the transport buffer. Maps are
+** allowed to have extra arbitrary data, so these routines extract just
+** the information that the GL needs.
+*/
+
+void __glFillMap1f(GLint k, GLint order, GLint stride,
+ const GLfloat *points, GLubyte *pc)
+{
+ if (stride == k) {
+ /* Just copy the data */
+ __GLX_PUT_FLOAT_ARRAY(0, points, order * k);
+ } else {
+ GLint i;
+
+ for (i = 0; i < order; i++) {
+ __GLX_PUT_FLOAT_ARRAY(0, points, k);
+ points += stride;
+ pc += k * __GLX_SIZE_FLOAT32;
+ }
+ }
+}
+
+void __glFillMap1d(GLint k, GLint order, GLint stride,
+ const GLdouble *points, GLubyte *pc)
+{
+ if (stride == k) {
+ /* Just copy the data */
+ __GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
+ } else {
+ GLint i;
+ for (i = 0; i < order; i++) {
+ __GLX_PUT_DOUBLE_ARRAY(0, points, k);
+ points += stride;
+ pc += k * __GLX_SIZE_FLOAT64;
+ }
+ }
+}
+
+void __glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
+ GLint majorStride, GLint minorStride,
+ const GLfloat *points, GLfloat *data)
+{
+ GLint i, j, x;
+
+ if ((minorStride == k) && (majorStride == minorOrder*k)) {
+ /* Just copy the data */
+ __GLX_MEM_COPY(data, points, majorOrder * majorStride *
+ __GLX_SIZE_FLOAT32);
+ return;
+ }
+ for (i = 0; i < majorOrder; i++) {
+ for (j = 0; j < minorOrder; j++) {
+ for (x = 0; x < k; x++) {
+ data[x] = points[x];
+ }
+ points += minorStride;
+ data += k;
+ }
+ points += majorStride - minorStride * minorOrder;
+ }
+}
+
+void __glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
+ GLint majorStride, GLint minorStride,
+ const GLdouble *points, GLdouble *data)
+{
+ int i,j,x;
+
+ if ((minorStride == k) && (majorStride == minorOrder*k)) {
+ /* Just copy the data */
+ __GLX_MEM_COPY(data, points, majorOrder * majorStride *
+ __GLX_SIZE_FLOAT64);
+ return;
+ }
+
+#ifdef __GLX_ALIGN64
+ x = k * __GLX_SIZE_FLOAT64;
+#endif
+ for (i = 0; i<majorOrder; i++) {
+ for (j = 0; j<minorOrder; j++) {
+#ifdef __GLX_ALIGN64
+ __GLX_MEM_COPY(data, points, x);
+#else
+ for (x = 0; x<k; x++) {
+ data[x] = points[x];
+ }
+#endif
+ points += minorStride;
+ data += k;
+ }
+ points += majorStride - minorStride * minorOrder;
+ }
+}
+
+GLint __glEvalComputeK(GLenum target)
+{
+ switch(target) {
+ case GL_MAP1_VERTEX_4:
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_4:
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_TEXTURE_COORD_4:
+ return 4;
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_NORMAL:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_NORMAL:
+ return 3;
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_2:
+ return 2;
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP1_INDEX:
+ case GL_MAP2_INDEX:
+ return 1;
+ default:
+ return 0;
+ }
+}
diff --git a/src/glx/x11/g_render.c b/src/glx/x11/g_render.c
new file mode 100644
index 0000000000..f632321a1d
--- /dev/null
+++ b/src/glx/x11/g_render.c
@@ -0,0 +1,819 @@
+/* $XFree86: xc/lib/GL/glx/g_render.c,v 1.8 2004/01/28 18:11:38 alanh Exp $ */
+/*
+** 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.1 (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-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: 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 "packrender.h"
+#include "size.h"
+
+#define GLdouble_SIZE 8
+#define GLclampd_SIZE 8
+#define GLfloat_SIZE 4
+#define GLclampf_SIZE 4
+#define GLint_SIZE 4
+#define GLuint_SIZE 4
+#define GLenum_SIZE 4
+#define GLbitfield_SIZE 4
+#define GLshort_SIZE 2
+#define GLushort_SIZE 2
+#define GLbyte_SIZE 1
+#define GLubyte_SIZE 1
+#define GLboolean_SIZE 1
+
+#define __GLX_PUT_GLdouble(offset,value) __GLX_PUT_DOUBLE(offset,value)
+#define __GLX_PUT_GLclampd(offset,value) __GLX_PUT_DOUBLE(offset,value)
+#define __GLX_PUT_GLfloat(offset,value) __GLX_PUT_FLOAT(offset,value)
+#define __GLX_PUT_GLclampf(offset,value) __GLX_PUT_FLOAT(offset,value)
+#define __GLX_PUT_GLint(offset,value) __GLX_PUT_LONG(offset,value)
+#define __GLX_PUT_GLuint(offset,value) __GLX_PUT_LONG(offset,value)
+#define __GLX_PUT_GLenum(offset,value) __GLX_PUT_LONG(offset,value)
+#define __GLX_PUT_GLbitfield(offset,value) __GLX_PUT_LONG(offset,value)
+#define __GLX_PUT_GLshort(offset,value) __GLX_PUT_SHORT(offset,value)
+#define __GLX_PUT_GLushort(offset,value) __GLX_PUT_SHORT(offset,value)
+#define __GLX_PUT_GLbyte(offset,value) __GLX_PUT_CHAR(offset,value)
+#define __GLX_PUT_GLubyte(offset,value) __GLX_PUT_CHAR(offset,value)
+#define __GLX_PUT_GLboolean(offset,value) __GLX_PUT_CHAR(offset,value)
+
+#define __GLX_PUT_GLdouble_ARRAY(offset,ptr,count) __GLX_PUT_DOUBLE_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLclampd_ARRAY(offset,ptr,count) __GLX_PUT_DOUBLE_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLfloat_ARRAY(offset,ptr,count) __GLX_PUT_FLOAT_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLclampf_ARRAY(offset,ptr,count) __GLX_PUT_FLOAT_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLint_ARRAY(offset,ptr,count) __GLX_PUT_LONG_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLuint_ARRAY(offset,ptr,count) __GLX_PUT_LONG_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLenum_ARRAY(offset,ptr,count) __GLX_PUT_LONG_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLshort_ARRAY(offset,ptr,count) __GLX_PUT_SHORT_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLushort_ARRAY(offset,ptr,count) __GLX_PUT_SHORT_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLbyte_ARRAY(offset,ptr,count) __GLX_PUT_CHAR_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLubyte_ARRAY(offset,ptr,count) __GLX_PUT_CHAR_ARRAY(offset,ptr,count)
+#define __GLX_PUT_GLboolean_ARRAY(offset,ptr,count) __GLX_PUT_CHAR_ARRAY(offset,ptr,count)
+
+#define RENDER_SIZE(t,c) (__GLX_PAD(4 + (t ## _SIZE * c)))
+
+/* GLX protocol templates are named in the following manner. All templates
+ * begin with the string 'glxproto_'. Following is an optional list of
+ * scalar parameters. The scalars are listed as type and number. The most
+ * common being \c enum1 (one scalar enum) and \c enum2 (two scalar enums).
+ *
+ * The final part of the name describes the number of named-type parameters
+ * and how they are passed.
+ * - One or more digits followed by the letter s means
+ * that the specified number of parameters are passed as scalars. The macro
+ * \c glxproto_3s generates a function that takes 3 scalars, such as
+ * \c glVertex3f.
+ * - A capital C follwed by a lower-case v means that a constant
+ * sized vector is passed. Macros of this type take an extra parameter,
+ * which is the size of the vector. The invocation
+ * 'glxproto_Cv(Vertex3fv, X_GLrop_Vertexfv, GLfloat, 3)' would generate the
+ * correct protocol for the \c glVertex3fv function.
+ * - A capital V followed by a lower-case v means that a variable sized
+ * vector is passed. The function generated by these macros will call
+ * a co-function to determine the size of the vector. The name of the
+ * co-function is generated by prepending \c __gl and appending \c _size
+ * to the base name of the function. The invocation
+ * 'glxproto_enum1_Vv(Fogiv, X_GLrop_Fogiv, GLint)' would generate the
+ * correct protocol for the \c glFogiv function.
+ * - One or more digits without a following letter means that a function
+ * taking the specified number of scalar parameters and a function with a
+ * vector parameter of the specified size should be generated. The letter
+ * v is automatically appended to the name of the vector-based function in
+ * this case. The invocation
+ * 'glxproto_3(Vertex3f, X_GLrop_Vertex3fv, GLfloat)' would generate the
+ * correct protocol for both \c glVertex3f and \c glVertex3fv.
+ *
+ * glxproto_void is a special case for functions that take no parameters
+ * (i.e., glEnd).
+ *
+ * An addition form is 'glxvendr_'. This is identical to the other forms
+ * with the exception of taking an additional parameter (to the macro) which
+ * is a vendor string to append to the function name. The invocation
+ * 'glxproto_3(Foo3f, X_GLrop_Foo3fv, GLfloat)' would generate the functions
+ * 'glFoo3fv' and 'glFoo3f', and the invocation
+ * 'glxvendr_3(Foo3f, X_GLrop_Foo3fv, GLfloat, EXT)' would generate the
+ * functions 'glFoo3fvEXT' and 'glFoo3fEXT'.
+ */
+
+#define glxproto_void(name, rop) \
+ void __indirect_gl ## name (void) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ __GLX_BEGIN(rop, 4); \
+ __GLX_END(4); \
+ }
+
+#define glxproto_Cv(name, rop, type, count) \
+ void __indirect_gl ## name (const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, count); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (count <= 4) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v[0]); \
+ if (count > 1) { __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v[1]); } \
+ if (count > 2) { __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v[2]); } \
+ if (count > 3) { __GLX_PUT_ ## type (4 + (3 * type ## _SIZE), v[3]); } \
+ } else { \
+ __GLX_PUT_ ## type ## _ARRAY(4, v, count); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_Cv_transpose(name, rop, type, w) \
+ void __indirect_gl ## name (const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ type t[ w * w ]; unsigned i, j; \
+ for (i = 0; i < w; i++) { \
+ for (j = 0; j < w; j++) { \
+ t[i*w+j] = v[j*w+i]; \
+ } \
+ } \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, (w * w)); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_ ## type ## _ARRAY(4, t, (w * w)); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_1s(name, rop, type) \
+ void __indirect_gl ## name (type v1) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, 1); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_2s(name, rop, type) \
+ void __indirect_gl ## name (type v1, type v2) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, 2); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_3s(name, rop, type) \
+ void __indirect_gl ## name (type v1, type v2, type v3) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, 3); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v3); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_4s(name, rop, type) \
+ void __indirect_gl ## name (type v1, type v2, type v3, type v4) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, 4); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v3); \
+ __GLX_PUT_ ## type (4 + (3 * type ## _SIZE), v4); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_6s(name, rop, type) \
+ void __indirect_gl ## name (type v1, type v2, type v3, type v4, type v5, type v6) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = RENDER_SIZE(type, 6); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v3); \
+ __GLX_PUT_ ## type (4 + (3 * type ## _SIZE), v4); \
+ __GLX_PUT_ ## type (4 + (4 * type ## _SIZE), v5); \
+ __GLX_PUT_ ## type (4 + (5 * type ## _SIZE), v6); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_1s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 1); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_LONG (4 + (1 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v1); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_1v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 1); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_LONG (4 + (1 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v[0]); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_2s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1, type v2) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 2); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_LONG (4 + (2 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (8 + (1 * type ## _SIZE), v2); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_2v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 2); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v[1]); \
+ __GLX_PUT_LONG (4 + (2 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_ ## type (8 + (1 * type ## _SIZE), v[1]); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_3s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1, type v2, type v3) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 3); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v3); \
+ __GLX_PUT_LONG (4 + (3 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (8 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (8 + (2 * type ## _SIZE), v3); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_3v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 3); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v[1]); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v[2]); \
+ __GLX_PUT_LONG (4 + (3 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_ ## type (8 + (1 * type ## _SIZE), v[1]); \
+ __GLX_PUT_ ## type (8 + (2 * type ## _SIZE), v[2]); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_4s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1, type v2, type v3, type v4) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 4); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v3); \
+ __GLX_PUT_ ## type (4 + (3 * type ## _SIZE), v4); \
+ __GLX_PUT_LONG (4 + (4 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_ ## type (8 + (1 * type ## _SIZE), v2); \
+ __GLX_PUT_ ## type (8 + (2 * type ## _SIZE), v3); \
+ __GLX_PUT_ ## type (8 + (3 * type ## _SIZE), v4); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_4v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 4 + RENDER_SIZE(type, 4); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_ ## type (4 + (1 * type ## _SIZE), v[1]); \
+ __GLX_PUT_ ## type (4 + (2 * type ## _SIZE), v[2]); \
+ __GLX_PUT_ ## type (4 + (3 * type ## _SIZE), v[3]); \
+ __GLX_PUT_LONG (4 + (4 * type ## _SIZE), e); \
+ } else { \
+ __GLX_PUT_LONG(4, e); \
+ __GLX_PUT_ ## type (8 + (0 * type ## _SIZE), v[0]); \
+ __GLX_PUT_ ## type (8 + (1 * type ## _SIZE), v[1]); \
+ __GLX_PUT_ ## type (8 + (2 * type ## _SIZE), v[2]); \
+ __GLX_PUT_ ## type (8 + (3 * type ## _SIZE), v[3]); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum1_Vv(name, rop, type) \
+ void __indirect_gl ## name (GLenum pname, const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ compsize = __gl ## name ## _size(pname); \
+ cmdlen = 4 + RENDER_SIZE(type, compsize); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_LONG(4, pname); \
+ __GLX_PUT_ ## type ## _ARRAY(8, v, compsize); \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum2_1s(name, rop, type) \
+ void __indirect_gl ## name (GLenum target, GLenum pname, type v1) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ cmdlen = 8 + RENDER_SIZE(type, 1); \
+ __GLX_BEGIN(rop, cmdlen); \
+ if (type ## _SIZE == 8) { \
+ __GLX_PUT_ ## type (4 + (0 * type ## _SIZE), v1); \
+ __GLX_PUT_LONG (4 + (1 * type ## _SIZE), target); \
+ __GLX_PUT_LONG (8 + (1 * type ## _SIZE), pname); \
+ } else { \
+ __GLX_PUT_LONG(4, target); \
+ __GLX_PUT_LONG(8, pname); \
+ __GLX_PUT_ ## type (12 + (0 * type ## _SIZE), v1); \
+ } \
+ __GLX_END(cmdlen); \
+ }
+
+#define glxproto_enum2_Vv(name, rop, type) \
+ void __indirect_gl ## name (GLenum target, GLenum pname, const type * v) \
+ { \
+ __GLX_DECLARE_VARIABLES(); \
+ __GLX_LOAD_VARIABLES(); \
+ compsize = __gl ## name ## _size(pname); \
+ cmdlen = 8 + RENDER_SIZE(type, compsize); \
+ __GLX_BEGIN(rop, cmdlen); \
+ __GLX_PUT_LONG(4, target); \
+ __GLX_PUT_LONG(8, pname); \
+ __GLX_PUT_ ## type ## _ARRAY(12, v, compsize); \
+ __GLX_END(cmdlen); \
+ }
+
+#define GENERATE_GLX_PROTOCOL_FUNCTIONS
+#include "indirect.h"
+
+void __indirect_glRectdv(const GLdouble *v1, const GLdouble *v2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Rectdv,36);
+ __GLX_PUT_DOUBLE(4,v1[0]);
+ __GLX_PUT_DOUBLE(12,v1[1]);
+ __GLX_PUT_DOUBLE(20,v2[0]);
+ __GLX_PUT_DOUBLE(28,v2[1]);
+ __GLX_END(36);
+}
+
+void __indirect_glRectfv(const GLfloat *v1, const GLfloat *v2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Rectfv,20);
+ __GLX_PUT_FLOAT(4,v1[0]);
+ __GLX_PUT_FLOAT(8,v1[1]);
+ __GLX_PUT_FLOAT(12,v2[0]);
+ __GLX_PUT_FLOAT(16,v2[1]);
+ __GLX_END(20);
+}
+
+void __indirect_glRectiv(const GLint *v1, const GLint *v2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Rectiv,20);
+ __GLX_PUT_LONG(4,v1[0]);
+ __GLX_PUT_LONG(8,v1[1]);
+ __GLX_PUT_LONG(12,v2[0]);
+ __GLX_PUT_LONG(16,v2[1]);
+ __GLX_END(20);
+}
+
+void __indirect_glRectsv(const GLshort *v1, const GLshort *v2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Rectsv,12);
+ __GLX_PUT_SHORT(4,v1[0]);
+ __GLX_PUT_SHORT(6,v1[1]);
+ __GLX_PUT_SHORT(8,v2[0]);
+ __GLX_PUT_SHORT(10,v2[1]);
+ __GLX_END(12);
+}
+
+void __indirect_glLineStipple(GLint factor, GLushort pattern)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_LineStipple,12);
+ __GLX_PUT_LONG(4,factor);
+ __GLX_PUT_SHORT(8,pattern);
+ __GLX_END(12);
+}
+
+void __indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Scissor,20);
+ __GLX_PUT_LONG(4,x);
+ __GLX_PUT_LONG(8,y);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_END(20);
+}
+
+void __indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_MapGrid1d,24);
+ __GLX_PUT_DOUBLE(4,u1);
+ __GLX_PUT_DOUBLE(12,u2);
+ __GLX_PUT_LONG(20,un);
+ __GLX_END(24);
+}
+
+void __indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_MapGrid1f,16);
+ __GLX_PUT_LONG(4,un);
+ __GLX_PUT_FLOAT(8,u1);
+ __GLX_PUT_FLOAT(12,u2);
+ __GLX_END(16);
+}
+
+void __indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_MapGrid2d,44);
+ __GLX_PUT_DOUBLE(4,u1);
+ __GLX_PUT_DOUBLE(12,u2);
+ __GLX_PUT_DOUBLE(20,v1);
+ __GLX_PUT_DOUBLE(28,v2);
+ __GLX_PUT_LONG(36,un);
+ __GLX_PUT_LONG(40,vn);
+ __GLX_END(44);
+}
+
+void __indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_MapGrid2f,28);
+ __GLX_PUT_LONG(4,un);
+ __GLX_PUT_FLOAT(8,u1);
+ __GLX_PUT_FLOAT(12,u2);
+ __GLX_PUT_LONG(16,vn);
+ __GLX_PUT_FLOAT(20,v1);
+ __GLX_PUT_FLOAT(24,v2);
+ __GLX_END(28);
+}
+
+void __indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_StencilFunc,16);
+ __GLX_PUT_LONG(4,func);
+ __GLX_PUT_LONG(8,ref);
+ __GLX_PUT_LONG(12,mask);
+ __GLX_END(16);
+}
+
+void __indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyPixels,24);
+ __GLX_PUT_LONG(4,x);
+ __GLX_PUT_LONG(8,y);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_PUT_LONG(20,type);
+ __GLX_END(24);
+}
+
+void __indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Viewport,20);
+ __GLX_PUT_LONG(4,x);
+ __GLX_PUT_LONG(8,y);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_END(20);
+}
+
+void __indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyTexImage1D,32);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,level);
+ __GLX_PUT_LONG(12,internalformat);
+ __GLX_PUT_LONG(16,x);
+ __GLX_PUT_LONG(20,y);
+ __GLX_PUT_LONG(24,width);
+ __GLX_PUT_LONG(28,border);
+ __GLX_END(32);
+}
+
+void __indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyTexImage2D,36);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,level);
+ __GLX_PUT_LONG(12,internalformat);
+ __GLX_PUT_LONG(16,x);
+ __GLX_PUT_LONG(20,y);
+ __GLX_PUT_LONG(24,width);
+ __GLX_PUT_LONG(28,height);
+ __GLX_PUT_LONG(32,border);
+ __GLX_END(36);
+}
+
+void __indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyTexSubImage1D,28);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,level);
+ __GLX_PUT_LONG(12,xoffset);
+ __GLX_PUT_LONG(16,x);
+ __GLX_PUT_LONG(20,y);
+ __GLX_PUT_LONG(24,width);
+ __GLX_END(28);
+}
+
+void __indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyTexSubImage2D,36);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,level);
+ __GLX_PUT_LONG(12,xoffset);
+ __GLX_PUT_LONG(16,yoffset);
+ __GLX_PUT_LONG(20,x);
+ __GLX_PUT_LONG(24,y);
+ __GLX_PUT_LONG(28,width);
+ __GLX_PUT_LONG(32,height);
+ __GLX_END(36);
+}
+
+void __indirect_glPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ if (n < 0) return;
+ cmdlen = 8+n*4+n*4;
+ __GLX_BEGIN(X_GLrop_PrioritizeTextures,cmdlen);
+ __GLX_PUT_LONG(4,n);
+ __GLX_PUT_LONG_ARRAY(8,textures,n);
+ __GLX_PUT_FLOAT_ARRAY(8+n*4,priorities,n);
+ __GLX_END(cmdlen);
+}
+
+void __indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyColorTable,24);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,internalformat);
+ __GLX_PUT_LONG(12,x);
+ __GLX_PUT_LONG(16,y);
+ __GLX_PUT_LONG(20,width);
+ __GLX_END(24);
+}
+
+void __indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyColorSubTable,24);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,start);
+ __GLX_PUT_LONG(12,x);
+ __GLX_PUT_LONG(16,y);
+ __GLX_PUT_LONG(20,width);
+ __GLX_END(24);
+}
+
+void __indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyConvolutionFilter1D,24);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,internalformat);
+ __GLX_PUT_LONG(12,x);
+ __GLX_PUT_LONG(16,y);
+ __GLX_PUT_LONG(20,width);
+ __GLX_END(24);
+}
+
+void __indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyConvolutionFilter2D,28);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,internalformat);
+ __GLX_PUT_LONG(12,x);
+ __GLX_PUT_LONG(16,y);
+ __GLX_PUT_LONG(20,width);
+ __GLX_PUT_LONG(24,height);
+ __GLX_END(28);
+}
+
+void __indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_Histogram,20);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,internalformat);
+ __GLX_PUT_CHAR(16,sink);
+ __GLX_END(20);
+}
+
+void __indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+ __GLX_BEGIN(X_GLrop_CopyTexSubImage3D,40);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_LONG(8,level);
+ __GLX_PUT_LONG(12,xoffset);
+ __GLX_PUT_LONG(16,yoffset);
+ __GLX_PUT_LONG(20,zoffset);
+ __GLX_PUT_LONG(24,x);
+ __GLX_PUT_LONG(28,y);
+ __GLX_PUT_LONG(32,width);
+ __GLX_PUT_LONG(36,height);
+ __GLX_END(40);
+}
+
+void __indirect_glWindowPos2dARB(GLdouble x, GLdouble y)
+{
+ __indirect_glWindowPos3fARB(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2iARB(GLint x, GLint y)
+{
+ __indirect_glWindowPos3fARB(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2fARB(GLfloat x, GLfloat y)
+{
+ __indirect_glWindowPos3fARB(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2sARB(GLshort x, GLshort y)
+{
+ __indirect_glWindowPos3fARB(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2dvARB(const GLdouble * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos2fvARB(const GLfloat * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos2ivARB(const GLint * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos2svARB(const GLshort * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos3dARB(GLdouble x, GLdouble y, GLdouble z)
+{
+ __indirect_glWindowPos3fARB(x, y, z);
+}
+
+void __indirect_glWindowPos3iARB(GLint x, GLint y, GLint z)
+{
+ __indirect_glWindowPos3fARB(x, y, z);
+}
+
+void __indirect_glWindowPos3sARB(GLshort x, GLshort y, GLshort z)
+{
+ __indirect_glWindowPos3fARB(x, y, z);
+}
+
+void __indirect_glWindowPos3dvARB(const GLdouble * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], p[2]);
+}
+
+void __indirect_glWindowPos3ivARB(const GLint * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], p[2]);
+}
+
+void __indirect_glWindowPos3svARB(const GLshort * p)
+{
+ __indirect_glWindowPos3fARB(p[0], p[1], p[2]);
+}
diff --git a/src/glx/x11/g_single.c b/src/glx/x11/g_single.c
new file mode 100644
index 0000000000..4d2ef45a3c
--- /dev/null
+++ b/src/glx/x11/g_single.c
@@ -0,0 +1,663 @@
+/* $XFree86$ */
+/*
+** 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.1 (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-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: 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 "packsingle.h"
+
+void glNewList(GLuint list, GLenum mode)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_NewList,8);
+ __GLX_SINGLE_PUT_LONG(0,list);
+ __GLX_SINGLE_PUT_LONG(4,mode);
+ __GLX_SINGLE_END();
+}
+
+void glEndList(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_EndList,0);
+ __GLX_SINGLE_END();
+}
+
+void glDeleteLists(GLuint list, GLsizei range)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_DeleteLists,8);
+ __GLX_SINGLE_PUT_LONG(0,list);
+ __GLX_SINGLE_PUT_LONG(4,range);
+ __GLX_SINGLE_END();
+}
+
+GLuint glGenLists(GLsizei range)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLuint retval = 0;
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GenLists,4);
+ __GLX_SINGLE_PUT_LONG(0,range);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLuint);
+ __GLX_SINGLE_END();
+ return retval;
+}
+
+void glGetLightfv(GLenum light, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetLightfv,8);
+ __GLX_SINGLE_PUT_LONG(0,light);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetLightiv(GLenum light, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetLightiv,8);
+ __GLX_SINGLE_PUT_LONG(0,light);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMapdv(GLenum target, GLenum query, GLdouble *v)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMapdv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,query);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_DOUBLE(v);
+ } else {
+ __GLX_SINGLE_GET_DOUBLE_ARRAY(v,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMapfv(GLenum target, GLenum query, GLfloat *v)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMapfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,query);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(v);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(v,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMapiv(GLenum target, GLenum query, GLint *v)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMapiv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,query);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(v);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(v,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMaterialfv,8);
+ __GLX_SINGLE_PUT_LONG(0,face);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMaterialiv(GLenum face, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMaterialiv,8);
+ __GLX_SINGLE_PUT_LONG(0,face);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetPixelMapfv(GLenum map, GLfloat *values)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetPixelMapfv,4);
+ __GLX_SINGLE_PUT_LONG(0,map);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(values);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(values,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetPixelMapuiv(GLenum map, GLuint *values)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetPixelMapuiv,4);
+ __GLX_SINGLE_PUT_LONG(0,map);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(values);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(values,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetPixelMapusv(GLenum map, GLushort *values)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetPixelMapusv,4);
+ __GLX_SINGLE_PUT_LONG(0,map);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_SHORT(values);
+ } else {
+ __GLX_SINGLE_GET_SHORT_ARRAY(values,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexEnvfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexEnviv(GLenum target, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexEnviv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexGendv(GLenum coord, GLenum pname, GLdouble *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexGendv,8);
+ __GLX_SINGLE_PUT_LONG(0,coord);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_DOUBLE(params);
+ } else {
+ __GLX_SINGLE_GET_DOUBLE_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexGenfv,8);
+ __GLX_SINGLE_PUT_LONG(0,coord);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexGeniv(GLenum coord, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexGeniv,8);
+ __GLX_SINGLE_PUT_LONG(0,coord);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexParameterfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexParameteriv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexLevelParameterfv,12);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,level);
+ __GLX_SINGLE_PUT_LONG(8,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexLevelParameteriv,12);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,level);
+ __GLX_SINGLE_PUT_LONG(8,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+GLboolean glIsList(GLuint list)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLboolean retval = 0;
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_IsList,4);
+ __GLX_SINGLE_PUT_LONG(0,list);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
+ __GLX_SINGLE_END();
+ return retval;
+}
+
+/*
+ * Somewhere between GLX 1.2 and 1.3 (in SGI's code anyway) the
+ * protocol for glAreTexturesResident, glDeleteTextures, glGenTextures,
+ * and glIsTexture() was changed. Before, calls to these functions
+ * generated protocol for the old GL_EXT_texture_object versions of those
+ * calls. In the newer code, this is actually corrected; calls to the
+ * 1.1 functions generate 1.1 protocol and calls to the EXT functions
+ * generate EXT protocol.
+ * Unfortunately, this correction causes an incompatibility. Specifically,
+ * an updated libGL.so will send protocol requests that the server won't
+ * be able to handle. For example, calling glGenTextures will generate a
+ * BadRequest error.
+ * For now, we'll keep generating EXT protocol from libGL. We'll update
+ * the server to understand both the 1.1 and EXT protocol ASAP. At some point
+ * in the future we'll correct libGL.so as well. That should be a smoother
+ * transition path.
+ */
+
+GLboolean glAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences)
+{
+#if 0 /* see comments above */
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLboolean retval = 0;
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ if (n < 0) return retval;
+ cmdlen = 4+n*4;
+ __GLX_SINGLE_BEGIN(X_GLsop_AreTexturesResident,cmdlen);
+ __GLX_SINGLE_PUT_LONG(0,n);
+ __GLX_PUT_LONG_ARRAY(4,textures,n);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
+ __GLX_SINGLE_GET_CHAR_ARRAY(residences,n);
+ __GLX_SINGLE_END();
+ return retval;
+#else
+ return glAreTexturesResidentEXT(n, textures, residences);
+#endif
+}
+
+void glDeleteTextures(GLsizei n, const GLuint *textures)
+{
+#if 0 /* see comments above */
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ if (n < 0) return;
+ cmdlen = 4+n*4;
+ __GLX_SINGLE_BEGIN(X_GLsop_DeleteTextures,cmdlen);
+ __GLX_SINGLE_PUT_LONG(0,n);
+ __GLX_PUT_LONG_ARRAY(4,textures,n);
+ __GLX_SINGLE_END();
+#else
+ glDeleteTexturesEXT(n, textures);
+#endif
+}
+
+void glGenTextures(GLsizei n, GLuint *textures)
+{
+#if 0 /* see comments above */
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GenTextures,4);
+ __GLX_SINGLE_PUT_LONG(0,n);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_LONG_ARRAY(textures,n);
+ __GLX_SINGLE_END();
+#else
+ glGenTexturesEXT(n, textures);
+#endif
+}
+
+GLboolean glIsTexture(GLuint texture)
+{
+#if 0 /* see comments above */
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLboolean retval = 0;
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_IsTexture,4);
+ __GLX_SINGLE_PUT_LONG(0,texture);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
+ __GLX_SINGLE_END();
+ return retval;
+#else
+ return glIsTextureEXT(texture);
+#endif
+}
+
+void glGetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetColorTableParameterfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetColorTableParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetColorTableParameteriv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetConvolutionParameterfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetConvolutionParameteriv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetHistogramParameterfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetHistogramParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetHistogramParameteriv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMinmaxParameterfv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(params);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMinmaxParameteriv,8);
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,pname);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(params);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(params,compsize);
+ }
+ __GLX_SINGLE_END();
+}
+
diff --git a/src/glx/x11/g_vendpriv.c b/src/glx/x11/g_vendpriv.c
new file mode 100644
index 0000000000..59734091e6
--- /dev/null
+++ b/src/glx/x11/g_vendpriv.c
@@ -0,0 +1,88 @@
+/* $XFree86$ */
+/*
+** 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.1 (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-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: 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 "packvendpriv.h"
+
+GLboolean glAreTexturesResidentEXT(GLsizei n, const GLuint *textures, GLboolean *residences)
+{
+ __GLX_VENDPRIV_DECLARE_VARIABLES();
+ GLboolean retval = 0;
+ xGLXVendorPrivReply reply;
+ __GLX_VENDPRIV_LOAD_VARIABLES();
+ if (n < 0) return retval;
+ cmdlen = 4+n*4;
+ __GLX_VENDPRIV_BEGIN(X_GLXVendorPrivateWithReply,X_GLvop_AreTexturesResidentEXT,cmdlen);
+ __GLX_VENDPRIV_PUT_LONG(0,n);
+ __GLX_PUT_LONG_ARRAY(4,textures,n);
+ __GLX_VENDPRIV_READ_XREPLY();
+ __GLX_VENDPRIV_GET_RETVAL(retval, GLboolean);
+ __GLX_VENDPRIV_GET_CHAR_ARRAY(residences,n);
+ __GLX_VENDPRIV_END();
+ return retval;
+}
+
+void glDeleteTexturesEXT(GLsizei n, const GLuint *textures)
+{
+ __GLX_VENDPRIV_DECLARE_VARIABLES();
+ __GLX_VENDPRIV_LOAD_VARIABLES();
+ if (n < 0) return;
+ cmdlen = 4+n*4;
+ __GLX_VENDPRIV_BEGIN(X_GLXVendorPrivate,X_GLvop_DeleteTexturesEXT,cmdlen);
+ __GLX_VENDPRIV_PUT_LONG(0,n);
+ __GLX_PUT_LONG_ARRAY(4,textures,n);
+ __GLX_VENDPRIV_END();
+}
+
+void glGenTexturesEXT(GLsizei n, GLuint *textures)
+{
+ __GLX_VENDPRIV_DECLARE_VARIABLES();
+ xGLXVendorPrivReply reply;
+ __GLX_VENDPRIV_LOAD_VARIABLES();
+ __GLX_VENDPRIV_BEGIN(X_GLXVendorPrivateWithReply,X_GLvop_GenTexturesEXT,4);
+ __GLX_VENDPRIV_PUT_LONG(0,n);
+ __GLX_VENDPRIV_READ_XREPLY();
+ __GLX_VENDPRIV_GET_LONG_ARRAY(textures,n);
+ __GLX_VENDPRIV_END();
+}
+
+GLboolean glIsTextureEXT(GLuint texture)
+{
+ __GLX_VENDPRIV_DECLARE_VARIABLES();
+ GLboolean retval = 0;
+ xGLXVendorPrivReply reply;
+ __GLX_VENDPRIV_LOAD_VARIABLES();
+ __GLX_VENDPRIV_BEGIN(X_GLXVendorPrivateWithReply,X_GLvop_IsTextureEXT,4);
+ __GLX_VENDPRIV_PUT_LONG(0,texture);
+ __GLX_VENDPRIV_READ_XREPLY();
+ __GLX_VENDPRIV_GET_RETVAL(retval, GLboolean);
+ __GLX_VENDPRIV_END();
+ return retval;
+}
+
diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c
new file mode 100644
index 0000000000..a03189ae3e
--- /dev/null
+++ b/src/glx/x11/glx_pbuffer.c
@@ -0,0 +1,556 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * All Rights Reserved.
+ *
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS 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 glx_pbuffer.c
+ * Implementation of pbuffer related functions.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <inttypes.h>
+#include "glxclient.h"
+#include <extutil.h>
+#include <Xext.h>
+#include <assert.h>
+#include <string.h>
+#include "glapi.h"
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+
+#ifdef IN_DOXYGEN
+#define GLX_PREFIX(x) x
+#endif /* IN_DOXYGEN */
+
+static void ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
+ const CARD32 * attribs, size_t num_attribs );
+
+static void DestroyPbuffer( Display * dpy, GLXDrawable drawable );
+
+static GLXDrawable CreatePbuffer( Display *dpy,
+ const __GLcontextModes * fbconfig, unsigned int width, unsigned int height,
+ const int *attrib_list, GLboolean size_in_attribs );
+
+static int GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value );
+
+
+/**
+ * Change a drawable's attribute.
+ *
+ * This function is used to implement \c glXSelectEvent and
+ * \c glXSelectEventSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static void
+ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
+ const CARD32 * attribs, size_t num_attribs )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ CARD32 * output;
+
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return;
+ }
+
+
+ LockDisplay(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXChangeDrawableAttributesReq *req;
+
+ GetReqExtra( GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req );
+ output = (CARD32 *) (req + 1);
+
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXChangeDrawableAttributes;
+ req->drawable = drawable;
+ req->numAttribs = (CARD32) num_attribs;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+
+ GetReqExtra( GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq );
+ output = (CARD32 *) (vpreq + 1);
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivateWithReply;
+ vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX;
+
+ output[0] = (CARD32) drawable;
+ output++;
+ }
+
+ (void) memcpy( output, attribs, sizeof( CARD32 ) * 2 * num_attribs );
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+/**
+ * Destroy a pbuffer.
+ *
+ * This function is used to implement \c glXDestroyPbuffer and
+ * \c glXDestroyGLXPbufferSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static void
+DestroyPbuffer( Display * dpy, GLXDrawable drawable )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return;
+ }
+
+
+ LockDisplay(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXDestroyPbufferReq * req;
+
+ GetReqExtra( GLXDestroyPbuffer, 4, req );
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXDestroyPbuffer;
+ req->pbuffer = (GLXPbuffer) drawable;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ CARD32 * data;
+
+ GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
+ data = (CARD32 *) (vpreq + 1);
+
+ data[0] = (CARD32) drawable;
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivateWithReply;
+ vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+/**
+ * Get a drawable's attribute.
+ *
+ * This function is used to implement \c glXGetSelectedEvent and
+ * \c glXGetSelectedEventSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * The number of attributes returned is likely to be small, probably less than
+ * 10. Given that, this routine should try to use an array on the stack to
+ * capture the reply rather than always calling Xmalloc.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static int
+GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ xGLXGetDrawableAttributesReply reply;
+ CARD32 * data;
+ unsigned int length;
+ unsigned int i;
+ unsigned int num_attributes;
+ GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
+ || (priv->minorVersion >= 3));
+
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return 0;
+ }
+
+
+ LockDisplay(dpy);
+
+ if ( use_glx_1_3 ) {
+ xGLXGetDrawableAttributesReq *req;
+
+ GetReqExtra( GLXGetDrawableAttributes, 4, req );
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXGetDrawableAttributes;
+ req->drawable = drawable;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+
+ GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
+ data = (CARD32 *) (vpreq + 1);
+ data[0] = (CARD32) drawable;
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivateWithReply;
+ vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
+ }
+
+ _XReply(dpy, (xReply*) &reply, 0, False);
+
+ length = reply.length;
+ num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
+ data = (CARD32 *) Xmalloc( length * sizeof(CARD32) );
+ if ( data == NULL ) {
+ /* Throw data on the floor */
+ _XEatData(dpy, length);
+ } else {
+ _XRead(dpy, (char *)data, length * sizeof(CARD32) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+
+ /* Search the set of returned attributes for the attribute requested by
+ * the caller.
+ */
+
+ for ( i = 0 ; i < num_attributes ; i++ ) {
+ if ( data[i*2] == attribute ) {
+ *value = data[ (i*2) + 1 ];
+ break;
+ }
+ }
+
+ Xfree( data );
+
+ return 0;
+}
+
+
+/**
+ * Create a non-pbuffer GLX drawable.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static GLXDrawable
+CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
+ Drawable drawable, const int *attrib_list,
+ CARD8 glxCode )
+{
+ xGLXCreateWindowReq * req;
+ CARD32 * data;
+ unsigned int i;
+
+
+ for ( i = 0 ; attrib_list[i * 2] != None ; i++ )
+ /* empty */ ;
+
+ LockDisplay(dpy);
+ GetReqExtra( GLXCreateWindow, 20 + (8 * i), req );
+ data = (CARD32 *) (req + 1);
+
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = glxCode;
+ req->screen = (CARD32) fbconfig->screen;
+ req->fbconfig = fbconfig->fbconfigID;
+ req->window = (GLXPbuffer) drawable;
+ req->numAttribs = (CARD32) i;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return drawable;
+}
+
+
+/**
+ * Destroy a non-pbuffer GLX drawable.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static void
+DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
+{
+ xGLXDestroyPbufferReq * req;
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return;
+ }
+
+
+ LockDisplay(dpy);
+
+ GetReqExtra( GLXDestroyPbuffer, 4, req );
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = glxCode;
+ req->pbuffer = (GLXPbuffer) drawable;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+/**
+ * Create a pbuffer.
+ *
+ * This function is used to implement \c glXCreatePbuffer and
+ * \c glXCreateGLXPbufferSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static GLXDrawable
+CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
+ unsigned int width, unsigned int height,
+ const int *attrib_list, GLboolean size_in_attribs )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ GLXDrawable id = 0;
+ CARD32 * data;
+ unsigned int i;
+
+
+ for ( i = 0 ; attrib_list[i * 2] != None ; i++ )
+ /* empty */ ;
+
+
+ LockDisplay(dpy);
+ id = XAllocID(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXCreatePbufferReq * req;
+ unsigned int extra = (size_in_attribs) ? 0 : 2;
+
+ GetReqExtra( GLXCreatePbuffer, (8 * (i + extra)), req );
+ data = (CARD32 *) (req + 1);
+
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXCreatePbuffer;
+ req->screen = (CARD32) fbconfig->screen;
+ req->fbconfig = fbconfig->fbconfigID;
+ req->pbuffer = (GLXPbuffer) id;
+ req->numAttribs = (CARD32) (i + extra);
+
+ if ( ! size_in_attribs ) {
+ data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
+ data[(2 * i) + 1] = width;
+ data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
+ data[(2 * i) + 3] = height;
+ data += 4;
+ }
+ }
+ else {
+ xGLXVendorPrivateReq *vpreq;
+
+ GetReqExtra( GLXVendorPrivate, 20 + (8 * i), vpreq );
+ data = (CARD32 *) (vpreq + 1);
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivate;
+ vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;
+
+ data[0] = (CARD32) fbconfig->screen;
+ data[1] = (CARD32) fbconfig->fbconfigID;
+ data[2] = (CARD32) id;
+ data[3] = (CARD32) width;
+ data[4] = (CARD32) height;
+ data += 5;
+ }
+
+ (void) memcpy( data, attrib_list, sizeof(CARD32) * 2 * i );
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return id;
+}
+
+
+/**
+ * Create a new pbuffer.
+ */
+GLXPbufferSGIX
+GLX_PREFIX(glXCreateGLXPbufferSGIX)(Display *dpy, GLXFBConfigSGIX config,
+ unsigned int width, unsigned int height,
+ int *attrib_list)
+{
+ return (GLXPbufferSGIX) CreatePbuffer( dpy, (__GLcontextModes *) config,
+ width, height,
+ attrib_list, GL_FALSE );
+}
+
+
+/**
+ * Create a new pbuffer.
+ */
+GLXPbuffer
+GLX_PREFIX(glXCreatePbuffer)(Display *dpy, GLXFBConfig config,
+ const int *attrib_list)
+{
+ return (GLXPbuffer) CreatePbuffer( dpy, (__GLcontextModes *) config,
+ 0, 0,
+ attrib_list, GL_TRUE );
+}
+
+
+/**
+ * Destroy an existing pbuffer.
+ */
+void
+GLX_PREFIX(glXDestroyPbuffer)(Display *dpy, GLXPbuffer pbuf)
+{
+ DestroyPbuffer( dpy, pbuf );
+}
+
+
+/**
+ * Query an attribute of a drawable.
+ */
+void
+GLX_PREFIX(glXQueryDrawable)(Display *dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value)
+{
+ GetDrawableAttribute( dpy, drawable, attribute, value );
+}
+
+
+/**
+ * Query an attribute of a pbuffer.
+ */
+int
+GLX_PREFIX(glXQueryGLXPbufferSGIX)(Display *dpy, GLXPbufferSGIX drawable,
+ int attribute, unsigned int *value)
+{
+ return GetDrawableAttribute( dpy, drawable, attribute, value );
+}
+
+
+/**
+ * Select the event mask for a drawable.
+ */
+void
+GLX_PREFIX(glXSelectEvent)(Display *dpy, GLXDrawable drawable,
+ unsigned long mask)
+{
+ CARD32 attribs[2];
+
+ attribs[0] = (CARD32) GLX_EVENT_MASK;
+ attribs[1] = (CARD32) mask;
+
+ ChangeDrawableAttribute( dpy, drawable, attribs, 1 );
+}
+
+
+/**
+ * Get the selected event mask for a drawable.
+ */
+void
+GLX_PREFIX(glXGetSelectedEvent)(Display *dpy, GLXDrawable drawable,
+ unsigned long *mask)
+{
+ unsigned int value;
+
+
+ /* The non-sense with value is required because on LP64 platforms
+ * sizeof(unsigned int) != sizeof(unsigned long). On little-endian
+ * we could just type-cast the pointer, but why?
+ */
+
+ GetDrawableAttribute( dpy, drawable, GLX_EVENT_MASK_SGIX, & value );
+ *mask = value;
+}
+
+
+GLXPixmap
+GLX_PREFIX(glXCreatePixmap)( Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attrib_list )
+{
+ return CreateDrawable( dpy, (__GLcontextModes *) config,
+ (Drawable) pixmap, attrib_list,
+ X_GLXCreatePixmap );
+}
+
+
+GLXWindow
+GLX_PREFIX(glXCreateWindow)( Display *dpy, GLXFBConfig config, Window win,
+ const int *attrib_list )
+{
+ return CreateDrawable( dpy, (__GLcontextModes *) config,
+ (Drawable) win, attrib_list,
+ X_GLXCreateWindow );
+}
+
+
+void
+GLX_PREFIX(glXDestroyPixmap)(Display *dpy, GLXPixmap pixmap)
+{
+ DestroyDrawable( dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap );
+}
+
+
+void
+GLX_PREFIX(glXDestroyWindow)(Display *dpy, GLXWindow win)
+{
+ DestroyDrawable( dpy, (GLXDrawable) win, X_GLXDestroyWindow );
+}
+
+
+GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
+ (Display *dpy, GLXPbufferSGIX pbuf),
+ (dpy, pbuf),
+ glXDestroyPbuffer)
+
+GLX_ALIAS_VOID(glXSelectEventSGIX,
+ (Display *dpy, GLXDrawable drawable, unsigned long mask),
+ (dpy, drawable, mask),
+ glXSelectEvent)
+
+GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
+ (Display *dpy, GLXDrawable drawable, unsigned long *mask),
+ (dpy, drawable, mask),
+ glXGetSelectedEvent)
diff --git a/src/glx/x11/glx_query.c b/src/glx/x11/glx_query.c
new file mode 100644
index 0000000000..e93cd2afd4
--- /dev/null
+++ b/src/glx/x11/glx_query.c
@@ -0,0 +1,102 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * All Rights Reserved.
+ *
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS 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 glx_query.c
+ * Generic utility functions to query internal data from the server.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "glxclient.h"
+
+/**
+ * GLX protocol structure for the ficticious "GXLGenericGetString" request.
+ *
+ * This is a non-existant protocol packet. It just so happens that all of
+ * the real protocol packets used to request a string from the server have
+ * an identical binary layout. The only difference between them is the
+ * meaning of the \c for_whom field and the value of the \c glxCode.
+ */
+typedef struct GLXGenericGetString {
+ CARD8 reqType;
+ CARD8 glxCode;
+ CARD16 length B16;
+ CARD32 for_whom B32;
+ CARD32 name B32;
+} xGLXGenericGetStringReq;
+
+/* These defines are only needed to make the GetReq macro happy.
+ */
+#define sz_xGLXGenericGetStringReq 12
+#define X_GLXGenericGetString 0
+
+/**
+ * Query the Server GLX string and cache it in the display private.
+ * This routine will allocate the necessay space for the string.
+ */
+char *
+__glXGetStringFromServer( Display * dpy, int opcode, CARD32 glxCode,
+ CARD32 for_whom, CARD32 name )
+{
+ xGLXGenericGetStringReq *req;
+ xGLXSingleReply reply;
+ int length;
+ int numbytes;
+ char * buf;
+
+
+ LockDisplay( dpy );
+
+
+ /* All of the GLX protocol requests for getting a string from the server
+ * look the same. The exact meaning of the for_whom field is usually
+ * either the screen number (for glXQueryServerString) or the context tag
+ * (for GLXSingle).
+ */
+
+ GetReq( GLXGenericGetString, req );
+ req->reqType = opcode;
+ req->glxCode = glxCode;
+ req->for_whom = for_whom;
+ req->name = name;
+
+ _XReply( dpy, (xReply *) & reply, 0, False );
+
+ length = reply.length * 4;
+ numbytes = reply.size;
+
+ buf = (char *) Xmalloc( numbytes );
+ if ( buf != NULL ) {
+ _XRead( dpy, buf, numbytes );
+ length -= numbytes;
+ }
+
+ _XEatData( dpy, length );
+
+ UnlockDisplay( dpy );
+ SyncHandle();
+
+ return buf;
+}
diff --git a/src/glx/x11/glx_texture_compression.c b/src/glx/x11/glx_texture_compression.c
new file mode 100644
index 0000000000..a478c194a9
--- /dev/null
+++ b/src/glx/x11/glx_texture_compression.c
@@ -0,0 +1,346 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * All Rights Reserved.
+ *
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS 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 glx_texture_compression.c
+ * Contains the routines required to implement GLX protocol for
+ * ARB_texture_compression and related extensions.
+ *
+ * \sa http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_compression.txt
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "packrender.h"
+#include "packsingle.h"
+
+#include <assert.h>
+
+
+void
+__indirect_glGetCompressedTexImage( GLenum target, GLint level,
+ GLvoid * img )
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXGetTexImageReply reply;
+ size_t image_bytes;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN( X_GLsop_GetCompressedTexImage, 8 );
+ __GLX_SINGLE_PUT_LONG( 0, target );
+ __GLX_SINGLE_PUT_LONG( 4, level );
+ __GLX_SINGLE_READ_XREPLY();
+
+ image_bytes = reply.width;
+ assert( image_bytes <= ((4 * reply.length) - 0) );
+ assert( image_bytes >= ((4 * reply.length) - 3) );
+
+ if ( image_bytes != 0 ) {
+ _XRead( dpy, (char *) img, image_bytes );
+ if ( image_bytes < (4 * reply.length) ) {
+ _XEatData( dpy, (4 * reply.length) - image_bytes );
+ }
+ }
+
+ __GLX_SINGLE_END();
+}
+
+
+/**
+ * Internal function used for \c glCompressedTexImage1D and
+ * \c glCompressedTexImage2D.
+ */
+static void
+CompressedTexImage1D2D( GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size,
+ const GLvoid *data, CARD32 rop )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ if ( (target == GL_PROXY_TEXTURE_1D)
+ || (target == GL_PROXY_TEXTURE_2D)
+ || (target == GL_PROXY_TEXTURE_CUBE_MAP) ) {
+ compsize = 0;
+ }
+ else {
+ compsize = image_size;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE
+ + compsize );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( rop, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, internal_format );
+ __GLX_PUT_LONG( 16, width );
+ __GLX_PUT_LONG( 20, height );
+ __GLX_PUT_LONG( 24, border );
+ __GLX_PUT_LONG( 28, image_size );
+ if ( compsize != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ assert( compsize != 0 );
+
+ __GLX_BEGIN_VARIABLE_LARGE( rop, cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, internal_format );
+ __GLX_PUT_LONG( 20, width );
+ __GLX_PUT_LONG( 24, height );
+ __GLX_PUT_LONG( 28, border );
+ __GLX_PUT_LONG( 32, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
+
+
+/**
+ * Internal function used for \c glCompressedTexSubImage1D and
+ * \c glCompressedTexSubImage2D.
+ */
+static void
+CompressedTexSubImage1D2D( GLenum target, GLint level,
+ GLsizei xoffset, GLsizei yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data, CARD32 rop )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ if ( target == GL_PROXY_TEXTURE_3D ) {
+ compsize = 0;
+ }
+ else {
+ compsize = image_size;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE
+ + compsize );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( rop, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, xoffset );
+ __GLX_PUT_LONG( 16, yoffset );
+ __GLX_PUT_LONG( 20, width );
+ __GLX_PUT_LONG( 24, height );
+ __GLX_PUT_LONG( 28, format );
+ __GLX_PUT_LONG( 32, image_size );
+ if ( compsize != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ assert( compsize != 0 );
+
+ __GLX_BEGIN_VARIABLE_LARGE( rop, cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, xoffset );
+ __GLX_PUT_LONG( 20, yoffset );
+ __GLX_PUT_LONG( 24, width );
+ __GLX_PUT_LONG( 28, height );
+ __GLX_PUT_LONG( 32, format );
+ __GLX_PUT_LONG( 36, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
+
+
+void
+__indirect_glCompressedTexImage1D( GLenum target, GLint level,
+ GLenum internal_format, GLsizei width,
+ GLint border, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexImage1D2D( target, level, internal_format, width, 0,
+ border, image_size, data,
+ X_GLrop_CompressedTexImage1D );
+}
+
+
+void
+__indirect_glCompressedTexImage2D( GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexImage1D2D( target, level, internal_format, width, height,
+ border, image_size, data,
+ X_GLrop_CompressedTexImage2D );
+}
+
+
+void
+__indirect_glCompressedTexImage3D( GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLsizei image_size,
+ const GLvoid *data )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE
+ + image_size );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( X_GLrop_CompressedTexImage3D, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, internal_format );
+ __GLX_PUT_LONG( 16, width );
+ __GLX_PUT_LONG( 20, height );
+ __GLX_PUT_LONG( 24, depth );
+ __GLX_PUT_LONG( 28, border );
+ __GLX_PUT_LONG( 32, image_size );
+ if ( image_size != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ __GLX_BEGIN_VARIABLE_LARGE( X_GLrop_CompressedTexImage3D,
+ cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, internal_format );
+ __GLX_PUT_LONG( 20, width );
+ __GLX_PUT_LONG( 24, height );
+ __GLX_PUT_LONG( 28, depth );
+ __GLX_PUT_LONG( 32, border );
+ __GLX_PUT_LONG( 36, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
+
+
+void
+__indirect_glCompressedTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexSubImage1D2D( target, level, xoffset, 0, width, 0,
+ format, image_size, data,
+ X_GLrop_CompressedTexSubImage1D );
+}
+
+
+void
+__indirect_glCompressedTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexSubImage1D2D( target, level, xoffset, yoffset, width, height,
+ format, image_size, data,
+ X_GLrop_CompressedTexSubImage2D );
+}
+
+
+void
+__indirect_glCompressedTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE
+ + image_size );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( X_GLrop_CompressedTexSubImage3D, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, xoffset );
+ __GLX_PUT_LONG( 16, yoffset );
+ __GLX_PUT_LONG( 20, zoffset );
+ __GLX_PUT_LONG( 24, width );
+ __GLX_PUT_LONG( 28, height );
+ __GLX_PUT_LONG( 32, depth );
+ __GLX_PUT_LONG( 36, format );
+ __GLX_PUT_LONG( 40, image_size );
+ if ( image_size != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ __GLX_BEGIN_VARIABLE_LARGE( X_GLrop_CompressedTexSubImage3D,
+ cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, xoffset );
+ __GLX_PUT_LONG( 20, yoffset );
+ __GLX_PUT_LONG( 24, zoffset );
+ __GLX_PUT_LONG( 28, width );
+ __GLX_PUT_LONG( 32, height );
+ __GLX_PUT_LONG( 36, depth );
+ __GLX_PUT_LONG( 40, format );
+ __GLX_PUT_LONG( 44, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
new file mode 100644
index 0000000000..7565760f0c
--- /dev/null
+++ b/src/glx/x11/glxclient.h
@@ -0,0 +1,833 @@
+/*
+** 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.1 (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-2000 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.
+*/
+/* $XFree86: xc/lib/GL/glx/glxclient.h,v 1.21 2004/02/09 23:46:31 alanh Exp $ */
+
+/**
+ * \file glxclient.h
+ * Direct rendering support added by Precision Insight, Inc.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ */
+
+#ifndef _GLX_client_h_
+#define _GLX_client_h_
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xlibint.h>
+#define GLX_GLXEXT_PROTOTYPES
+#include <GL/glx.h>
+#include <GL/glxext.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "GL/glxint.h"
+#include "GL/glxproto.h"
+#include "GL/internal/glcore.h"
+#include "glapitable.h"
+#ifdef NEED_GL_FUNCS_WRAPPED
+#include "indirect.h"
+#endif
+#ifdef XTHREADS
+#include "Xthreads.h"
+#endif
+#ifdef GLX_BUILT_IN_XMESA
+#include "realglx.h" /* just silences prototype warnings */
+#endif
+
+#define GLX_MAJOR_VERSION 1 /* current version numbers */
+#define GLX_MINOR_VERSION 4
+
+#define __GLX_MAX_TEXTURE_UNITS 32
+
+typedef struct __GLXcontextRec __GLXcontext;
+typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
+typedef struct _glapi_table __GLapi;
+
+/************************************************************************/
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <GL/internal/dri_interface.h>
+
+typedef void *(*CreateScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config);
+
+typedef void *(*CreateNewScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes, const __DRIversion * ddx_version,
+ const __DRIversion * dri_version, const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer, void * pSAREA,
+ int fd, int internal_api_version, __GLcontextModes ** driver_modes);
+
+
+/**
+ * Display dependent methods. This structure is initialized during the
+ * \c driCreateDisplay call.
+ */
+struct __DRIdisplayRec {
+ /**
+ * Method to destroy the private DRI display data.
+ */
+ void (*destroyDisplay)(Display *dpy, void *displayPrivate);
+
+ /**
+ * Methods to create the private DRI screen data and initialize the
+ * screen dependent methods.
+ * This is an array [indexed by screen number] of function pointers.
+ *
+ * \deprecated This array of function pointers has been replaced by
+ * \c __DRIdisplayRec::createNewScreen.
+ * \sa __DRIdisplayRec::createNewScreen
+ */
+ CreateScreenFunc * createScreen;
+
+ /**
+ * Opaque pointer to private per display direct rendering data.
+ * \c NULL if direct rendering is not supported on this display.
+ */
+ struct __DRIdisplayPrivateRec *private;
+
+ /**
+ * Array of pointers to methods to create and initialize the private DRI
+ * screen data.
+ *
+ * \sa __DRIdisplayRec::createScreen
+ */
+ CreateNewScreenFunc * createNewScreen;
+};
+
+
+/*
+** We keep a linked list of these structures, one per DRI device driver.
+*/
+struct __DRIdriverRec {
+ const char *name;
+ void *handle;
+ CreateScreenFunc createScreenFunc;
+ CreateNewScreenFunc createNewScreenFunc;
+ struct __DRIdriverRec *next;
+};
+
+/*
+** Function to create and DRI display data and initialize the display
+** dependent methods.
+*/
+extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp);
+
+extern __DRIdriver *driGetDriver(Display *dpy, int scrNum);
+
+extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
+
+/*
+** Functions to obtain driver configuration information from a direct
+** rendering client application
+*/
+extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
+
+extern const char *glXGetDriverConfig (const char *driverName);
+
+#endif
+
+/************************************************************************/
+
+#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
+
+typedef struct __GLXpixelStoreModeRec {
+ GLboolean swapEndian;
+ GLboolean lsbFirst;
+ GLuint rowLength;
+ GLuint imageHeight;
+ GLuint imageDepth;
+ GLuint skipRows;
+ GLuint skipPixels;
+ GLuint skipImages;
+ GLuint alignment;
+} __GLXpixelStoreMode;
+
+/* The next 3 structures are deprecated. Client state is no longer tracked
+ * using them. They only remain to maintain the layout / structure offset of
+ * __GLXcontextRec. In XFree86 5.0 they will be removed altogether.
+ */
+
+typedef struct __GLXvertexArrayPointerStateRecDEPRECATED {
+ GLboolean enable;
+ void (*proc)(const void *);
+ const GLubyte *ptr;
+ GLsizei skip;
+ GLint size;
+ GLenum type;
+ GLsizei stride;
+} __GLXvertexArrayPointerStateDEPRECATED;
+
+typedef struct __GLXvertArrayStateRecDEPRECATED {
+ __GLXvertexArrayPointerStateDEPRECATED vertex;
+ __GLXvertexArrayPointerStateDEPRECATED normal;
+ __GLXvertexArrayPointerStateDEPRECATED color;
+ __GLXvertexArrayPointerStateDEPRECATED index;
+ __GLXvertexArrayPointerStateDEPRECATED texCoord[__GLX_MAX_TEXTURE_UNITS];
+ __GLXvertexArrayPointerStateDEPRECATED edgeFlag;
+ GLint maxElementsVertices;
+ GLint maxElementsIndices;
+ GLint activeTexture;
+} __GLXvertArrayStateDEPRECATED;
+
+typedef struct __GLXattributeRecDEPRECATED {
+ GLuint mask;
+
+ /*
+ ** Pixel storage state. Most of the pixel store mode state is kept
+ ** here and used by the client code to manage the packing and
+ ** unpacking of data sent to/received from the server.
+ */
+ __GLXpixelStoreMode storePack, storeUnpack;
+
+ /*
+ ** Vertex Array storage state. The vertex array component
+ ** state is stored here and is used to manage the packing of
+ ** DrawArrays data sent to the server.
+ */
+ __GLXvertArrayStateDEPRECATED vertArray;
+} __GLXattributeDEPRECATED;
+
+typedef struct __GLXvertexArrayPointerStateRec {
+ void (*proc)(const void *);
+ void (*mtex_proc)(GLenum, const void *);
+ const GLubyte *ptr;
+ GLsizei skip;
+ GLint size;
+ GLenum type;
+ GLsizei stride;
+} __GLXvertexArrayPointerState;
+
+/**
+ * Define which entries of \c __GLXvertArrayState::arrays match which
+ * vertex arrays in the client-state vector. These are only the one-of
+ * arrays. See the \c __GLXvertArrayState::arrays documentation for more
+ * details.
+ *
+ * \sa __GLXvertArrayState
+ */
+enum {
+ edgeFlag_ARRAY, /**< \c GL_EDGE_FLAG_ARRAY */
+ index_ARRAY, /**< \c GL_INDEX_ARRAY */
+ fogCoord_ARRAY, /**< \c GL_FOG_COORD_ARRAY */
+ secondaryColor_ARRAY, /**< \c GL_SECONDARY_COLOR_ARRAY */
+ color_ARRAY, /**< \c GL_COLOR_ARRAY */
+ normal_ARRAY, /**< \c GL_NORMAL_ARRAY */
+
+ /**
+ * \c GL_VERTEX_ARRAY \b must be last! All of the code for emitting arrays
+ * and array elements is written based on the assumption that the vertex
+ * array is last.
+ */
+ vertex_ARRAY,
+
+ __GLX_MAX_ARRAYS /**< Place holder entry. */
+};
+
+#define ENABLE_ARRAY(state,a) \
+ do { (state)->vertArray.enables |= (1U << (a ## _ARRAY)); } while( 0 )
+#define DISABLE_ARRAY(state,a) \
+ do { (state)->vertArray.enables &= ~(1U << (a ## _ARRAY)); } while( 0 )
+#define IS_ARRAY_ENABLED_BY_INDEX(state, i) \
+ (((state)->vertArray.enables & (1U << (i))) != 0)
+#define IS_ARRAY_ENABLED(state, a) \
+ IS_ARRAY_ENABLED_BY_INDEX(state, a ## _ARRAY)
+
+#define ENABLE_TEXARRAY(state,a) \
+ do { (state)->vertArray.texture_enables |= (1U << a); } while( 0 )
+#define DISABLE_TEXARRAY(state,a) \
+ do { (state)->vertArray.texture_enables &= ~(1U << a); } while( 0 )
+#define IS_TEXARRAY_ENABLED(state, a) \
+ (((state)->vertArray.texture_enables & (1U << a)) != 0)
+
+/**
+ * Client-side vertex array state.
+ */
+typedef struct __GLXvertArrayStateRec {
+ /**
+ * Which client-side arrays are enabled? These are the flag bits for
+ * all of the non-texture coordinate arrays.
+ */
+ GLuint enables;
+
+ /**
+ * Which of the texture coordinate arrays are enabled?
+ */
+ GLuint texture_enables;
+
+ /**
+ * State for "one-of" arrays. These are the arrays, such as
+ * GL_COLOR_ARRAY or GL_FOG_COORD_ARRAY for which there is only one
+ * array. There are also "many-of" arrays, such as
+ * GL_TEXTURE_COORD_ARRAY.
+ */
+ __GLXvertexArrayPointerState arrays[__GLX_MAX_ARRAYS];
+
+ __GLXvertexArrayPointerState texCoord[__GLX_MAX_TEXTURE_UNITS];
+
+ GLint maxElementsVertices;
+ GLint maxElementsIndices;
+ GLint activeTexture;
+} __GLXvertArrayState;
+
+typedef struct __GLXattributeRec {
+ GLuint mask;
+
+ /*
+ ** Pixel storage state. Most of the pixel store mode state is kept
+ ** here and used by the client code to manage the packing and
+ ** unpacking of data sent to/received from the server.
+ */
+ __GLXpixelStoreMode storePack, storeUnpack;
+
+ /*
+ ** Vertex Array storage state. The vertex array component
+ ** state is stored here and is used to manage the packing of
+ ** DrawArrays data sent to the server.
+ */
+ __GLXvertArrayState vertArray;
+
+ /**
+ * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
+ * disabled?
+ */
+ GLboolean NoDrawArraysProtocol;
+} __GLXattribute;
+
+typedef struct __GLXattributeMachineRec {
+ __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
+ __GLXattribute **stackPointer;
+} __GLXattributeMachine;
+
+/**
+ * GLX state that needs to be kept on the client. One of these records
+ * exist for each context that has been made current by this client.
+ */
+struct __GLXcontextRec {
+ /**
+ * \name Drawing command buffer.
+ *
+ * Drawing commands are packed into this buffer before being sent as a
+ * single GLX protocol request. The buffer is sent when it overflows or
+ * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location
+ * in the buffer to be filled. \c limit is described above in the buffer
+ * slop discussion.
+ *
+ * Commands that require large amounts of data to be transfered will
+ * also use this buffer to hold a header that describes the large
+ * command.
+ *
+ * These must be the first 6 fields since they are static initialized
+ * in the dummy context in glxext.c
+ */
+ /*@{*/
+ GLubyte *buf;
+ GLubyte *pc;
+ GLubyte *limit;
+ GLubyte *bufEnd;
+ GLint bufSize;
+ /*@}*/
+
+ /**
+ * The XID of this rendering context. When the context is created a
+ * new XID is allocated. This is set to None when the context is
+ * destroyed but is still current to some thread. In this case the
+ * context will be freed on next MakeCurrent.
+ */
+ XID xid;
+
+ /**
+ * The XID of the \c shareList context.
+ */
+ XID share_xid;
+
+ /**
+ * Visual id.
+ *
+ * \deprecated
+ * This filed has been largely been replaced by the \c mode field, but
+ * the work is not quite done.
+ */
+ VisualID vid;
+
+ /**
+ * Screen number.
+ */
+ GLint screen;
+
+ /**
+ * \c GL_TRUE if the context was created with ImportContext, which
+ * means the server-side context was created by another X client.
+ */
+ GLboolean imported;
+
+ /**
+ * The context tag returned by MakeCurrent when this context is made
+ * current. This tag is used to identify the context that a thread has
+ * current so that proper server context management can be done. It is
+ * used for all context specific commands (i.e., \c Render, \c RenderLarge,
+ * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
+ * context)).
+ */
+ GLXContextTag currentContextTag;
+
+ /**
+ * \name Rendering mode
+ *
+ * The rendering mode is kept on the client as well as the server.
+ * When \c glRenderMode is called, the buffer associated with the
+ * previous rendering mode (feedback or select) is filled.
+ */
+ /*@{*/
+ GLenum renderMode;
+ GLfloat *feedbackBuf;
+ GLuint *selectBuf;
+ /*@}*/
+
+ /**
+ * This is \c GL_TRUE if the pixel unpack modes are such that an image
+ * can be unpacked from the clients memory by just copying. It may
+ * still be true that the server will have to do some work. This
+ * just promises that a straight copy will fetch the correct bytes.
+ */
+ GLboolean fastImageUnpack;
+
+ /**
+ * Fill newImage with the unpacked form of \c oldImage getting it
+ * ready for transport to the server.
+ */
+ void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
+ GLenum, const GLvoid*, GLubyte*, GLubyte*);
+
+ /**
+ * \name Client side attribs.
+ */
+ /*@{*/
+ __GLXattributeDEPRECATED stateDEPRECATED;
+ __GLXattributeMachine attributes;
+ /*@}*/
+
+ /**
+ * Client side error code. This is set when client side gl API
+ * routines need to set an error because of a bad enumerant or
+ * running out of memory, etc.
+ */
+ GLenum error;
+
+ /**
+ * Whether this context does direct rendering.
+ */
+ Bool isDirect;
+
+ /**
+ * \c dpy of current display for this context. Will be \c NULL if not
+ * current to any display, or if this is the "dummy context".
+ */
+ Display *currentDpy;
+
+ /**
+ * The current drawable for this context. Will be None if this
+ * context is not current to any drawable. currentReadable is below.
+ */
+ GLXDrawable currentDrawable;
+
+ /**
+ * \name GL Constant Strings
+ *
+ * Constant strings that describe the server implementation
+ * These pertain to GL attributes, not to be confused with
+ * GLX versioning attributes.
+ */
+ /*@{*/
+ GLubyte *vendor;
+ GLubyte *renderer;
+ GLubyte *version;
+ GLubyte *extensions;
+ /*@}*/
+
+ /**
+ * Record the dpy this context was created on for later freeing
+ */
+ Display *createDpy;
+
+ /**
+ * Maximum small render command size. This is the smaller of 64k and
+ * the size of the above buffer.
+ */
+ GLint maxSmallRenderCommandSize;
+
+ /**
+ * Major opcode for the extension. Copied here so a lookup isn't
+ * needed.
+ */
+ GLint majorOpcode;
+
+#ifdef GLX_DIRECT_RENDERING
+ /**
+ * Per context direct rendering interface functions and data.
+ */
+ __DRIcontext driContext;
+#endif
+
+ /**
+ * \c GLXFBConfigID used to create this context. May be \c None. This
+ * field has been replaced by the \c mode field.
+ *
+ * \since Internal API version 20030317.
+ *
+ * \deprecated
+ * This filed has been largely been replaced by the \c mode field, but
+ * the work is not quite done.
+ */
+ GLXFBConfigID fbconfigID;
+
+ /**
+ * The current read-drawable for this context. Will be None if this
+ * context is not current to any drawable.
+ *
+ * \since Internal API version 20030606.
+ */
+ GLXDrawable currentReadable;
+
+ /**
+ * Pointer to client-state data that is private to libGL. This is only
+ * used for indirect rendering contexts.
+ *
+ * No internal API version change was made for this change. Client-side
+ * drivers should NEVER use this data or even care that it exists.
+ */
+ void * client_state_private;
+
+ /**
+ * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
+ */
+ int renderType;
+
+ /**
+ * \name Raw server GL version
+ *
+ * True core GL version supported by the server. This is the raw value
+ * returned by the server, and it may not reflect what is actually
+ * supported (or reported) by the client-side library.
+ */
+ /*@{*/
+ int server_major; /**< Major version number. */
+ int server_minor; /**< Minor version number. */
+ /*@}*/
+};
+
+#define __glXSetError(gc,code) \
+ if (!(gc)->error) { \
+ (gc)->error = code; \
+ }
+
+extern void __glFreeAttributeState(__GLXcontext *);
+
+/************************************************************************/
+
+/**
+ * The size of the largest drawing command known to the implementation
+ * that will use the GLXRender GLX command. In this case it is
+ * \c glPolygonStipple.
+ */
+#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
+
+/**
+ * To keep the implementation fast, the code uses a "limit" pointer
+ * to determine when the drawing command buffer is too full to hold
+ * another fixed size command. This constant defines the amount of
+ * space that must always be available in the drawing command buffer
+ * at all times for the implementation to work. It is important that
+ * the number be just large enough, but not so large as to reduce the
+ * efficacy of the buffer. The "+32" is just to keep the code working
+ * in case somebody counts wrong.
+ */
+#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
+
+/**
+ * This implementation uses a smaller threshold for switching
+ * to the RenderLarge protocol than the protcol requires so that
+ * large copies don't occur.
+ */
+#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
+
+/**
+ * One of these records exists per screen of the display. It contains
+ * a pointer to the config data for that screen (if the screen supports GL).
+ */
+typedef struct __GLXscreenConfigsRec {
+ /**
+ * GLX visuals formated as \c __GLXvisualConfig structures.
+ */
+ /*@{*/
+ __GLXvisualConfig * old_configs;
+ int numOldConfigs;
+ /*@}*/
+
+ /**
+ * GLX extension string reported by the X-server.
+ */
+ const char *serverGLXexts;
+
+ /**
+ * GLX extension string to be reported to applications. This is the
+ * set of extensions that the application can actually use.
+ */
+ char *effectiveGLXexts;
+
+#ifdef GLX_DIRECT_RENDERING
+ /**
+ * Per screen direct rendering interface functions and data.
+ */
+ __DRIscreen driScreen;
+#endif
+
+ /**
+ * Linked list of configurations for this screen. This is intended to
+ * be a superset of \c old_configs.
+ */
+ __GLcontextModes *configs;
+ /**
+ * Per-screen dynamic GLX extension tracking. The \c direct_support
+ * field only contains enough bits for 64 extensions. Should libGL
+ * ever need to track more than 64 GLX extensions, we can safely grow
+ * this field. The \c __GLXscreenConfigs structure is not used outside
+ * libGL.
+ */
+ /*@{*/
+ unsigned char direct_support[8];
+ GLboolean ext_list_first_time;
+ /*@}*/
+
+} __GLXscreenConfigs;
+
+/**
+ * Per display private data. One of these records exists for each display
+ * that is using the OpenGL (GLX) extension.
+ */
+struct __GLXdisplayPrivateRec {
+ /**
+ * Back pointer to the display
+ */
+ Display *dpy;
+
+ /**
+ * The \c majorOpcode is common to all connections to the same server.
+ * It is also copied into the context structure.
+ */
+ int majorOpcode;
+
+ /**
+ * \name Server Version
+ *
+ * Major and minor version returned by the server during initialization.
+ */
+ /*@{*/
+ int majorVersion, minorVersion;
+ /*@}*/
+
+ /**
+ * \name Storage for the servers GLX vendor and versions strings.
+ *
+ * These are the same for all screens on this display. These fields will
+ * be filled in on demand.
+ */
+ /*@{*/
+ const char *serverGLXvendor;
+ const char *serverGLXversion;
+ /*@}*/
+
+ /**
+ * Configurations of visuals for all screens on this display.
+ * Also, per screen data which now includes the server \c GLX_EXTENSION
+ * string.
+ */
+ __GLXscreenConfigs *screenConfigs;
+
+#ifdef GLX_DIRECT_RENDERING
+ /**
+ * Per display direct rendering interface functions and data.
+ */
+ __DRIdisplay driDisplay;
+#endif
+};
+
+void __glXFreeContext(__GLXcontext*);
+
+extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
+
+extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
+ GLint totalRequests,
+ const GLvoid * data, GLint dataLen);
+
+extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
+ const GLvoid *, GLint);
+
+/* Initialize the GLX extension for dpy */
+extern __GLXdisplayPrivate *__glXInitialize(Display*);
+
+/************************************************************************/
+
+extern int __glXDebug;
+
+/* This is per-thread storage in an MT environment */
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+extern __GLXcontext *__glXGetCurrentContext(void);
+extern void __glXSetCurrentContext(__GLXcontext *c);
+#else
+extern __GLXcontext *__glXcurrentContext;
+#define __glXGetCurrentContext() __glXcurrentContext
+#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
+#endif
+
+
+/*
+** Global lock for all threads in this address space using the GLX
+** extension
+*/
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+extern xmutex_rec __glXmutex;
+#define __glXLock() xmutex_lock(&__glXmutex)
+#define __glXUnlock() xmutex_unlock(&__glXmutex)
+#else
+#define __glXLock()
+#define __glXUnlock()
+#endif
+
+/*
+** Setup for a command. Initialize the extension for dpy if necessary.
+*/
+extern CARD8 __glXSetupForCommand(Display *dpy);
+
+/************************************************************************/
+
+/*
+** Data conversion and packing support.
+*/
+
+/* Return the size, in bytes, of some pixel data */
+extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum);
+
+/* Return the number of elements per group of a specified format*/
+extern GLint __glElementsPerGroup(GLenum format, GLenum type);
+
+/* Return the number of bytes per element, based on the element type (other
+** than GL_BITMAP).
+*/
+extern GLint __glBytesPerElement(GLenum type);
+
+/* Return the k value for a given map target */
+extern GLint __glEvalComputeK(GLenum);
+
+/*
+** Fill the transport buffer with the data from the users buffer,
+** applying some of the pixel store modes (unpack modes) to the data
+** first. As a side effect of this call, the "modes" field is
+** updated to contain the modes needed by the server to decode the
+** sent data.
+*/
+extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
+ GLenum, const GLvoid*, GLubyte*, GLubyte*);
+
+/* Copy map data with a stride into a packed buffer */
+extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
+extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
+extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
+ const GLfloat *, GLfloat *);
+extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
+ const GLdouble *, GLdouble *);
+
+/*
+** Empty an image out of the reply buffer into the clients memory applying
+** the pack modes to pack back into the clients requested format.
+*/
+extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
+ GLenum, const GLubyte *, GLvoid *);
+
+
+/*
+** Allocate and Initialize Vertex Array client state
+*/
+extern void __glXInitVertexArrayState(__GLXcontext*);
+
+/*
+** Inform the Server of the major and minor numbers and of the client
+** libraries extension string.
+*/
+extern void __glXClientInfo ( Display *dpy, int opcode );
+
+/************************************************************************/
+
+/*
+** Declarations that should be in Xlib
+*/
+#ifdef __GL_USE_OUR_PROTOTYPES
+extern void _XFlush(Display*);
+extern Status _XReply(Display*, xReply*, int, Bool);
+extern void _XRead(Display*, void*, long);
+extern void _XSend(Display*, const void*, long);
+#endif
+
+
+/*
+** GLX_BUILT_IN_XMESA controls whether libGL has a built-in verions of
+** Mesa that can render to non-GLX displays.
+*/
+#ifdef GLX_BUILT_IN_XMESA
+#define GLX_PREFIX(function) _real_##function
+#else
+#define GLX_PREFIX(function) function
+#endif
+
+
+extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
+ int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
+
+extern char * __glXGetStringFromServer( Display * dpy, int opcode,
+ CARD32 glxCode, CARD32 for_whom, CARD32 name );
+
+extern char *__glXstrdup(const char *str);
+
+
+extern const char __glXGLClientVersion[];
+extern const char __glXGLClientExtensions[];
+
+/* Determine the internal API version */
+extern int __glXGetInternalVersion(void);
+
+/* Get the unadjusted system time */
+extern int __glXGetUST( int64_t * ust );
+
+#endif /* !__GLX_client_h__ */
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
new file mode 100644
index 0000000000..32560dca4a
--- /dev/null
+++ b/src/glx/x11/glxcmds.c
@@ -0,0 +1,3082 @@
+/* $XFree86: xc/lib/GL/glx/glxcmds.c,v 1.30 2004/01/30 20:33:06 alanh Exp $ */
+/*
+** 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.1 (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-2000 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.
+**
+*/
+
+/**
+ * \file glxcmds.c
+ * Client-side GLX interface.
+ */
+
+#include <inttypes.h>
+#include "glxclient.h"
+#include <extutil.h>
+#include <Xext.h>
+#include <assert.h>
+#include <string.h>
+#include "glapi.h"
+#ifdef GLX_DIRECT_RENDERING
+#include "indirect_init.h"
+#include "xf86vmode.h"
+#endif
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+#include <sys/time.h>
+
+#ifdef IN_DOXYGEN
+#define GLX_PREFIX(x) x
+#endif /* IN_DOXYGEN */
+
+static const char __glXGLXClientVendorName[] = "SGI";
+static const char __glXGLXClientVersion[] = "1.4";
+
+
+#if defined(GLX_DIRECT_RENDERING)
+#include "xf86dri.h"
+
+static Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
+
+static void * DriverCreateContextWrapper( const __GLXscreenConfigs *psc,
+ Display *dpy, XVisualInfo *vis, void *shared, __DRIcontext *ctx,
+ const __GLcontextModes *fbconfig, int render_type );
+
+static Bool dummyBindContext2( Display *dpy, int scrn,
+ GLXDrawable draw, GLXDrawable read, GLXContext gc );
+
+static Bool dummyUnbindContext2( Display *dpy, int scrn,
+ GLXDrawable draw, GLXDrawable read, GLXContext gc );
+
+/****************************************************************************/
+
+/**
+ * Used as glue when a driver does not support
+ * \c __DRIcontextRec::bindContext2.
+ *
+ * XXX .bindContext is only defined as a function pointer if
+ * !DRI_NEW_INTERFACE_ONLY.
+ *
+ * \sa DriverCreateContextWrapper, __DRIcontextRec::bindContext2
+ */
+static Bool dummyBindContext2( Display *dpy, int scrn,
+ GLXDrawable draw, GLXDrawable read,
+ GLXContext gc )
+{
+ assert( draw == read );
+ return (*gc->driContext.bindContext)( dpy, scrn, draw, gc );
+}
+
+/**
+ * Used as glue when a driver does not support
+ * \c __DRIcontextRec::unbindContext2.
+ *
+ * XXX .unbindContext is only defined as a function pointer if
+ * !DRI_NEW_INTERFACE_ONLY.
+ *
+ * \sa DriverCreateContextWrapper, __DRIcontextRec::unbindContext2
+ */
+static Bool dummyUnbindContext2( Display *dpy, int scrn,
+ GLXDrawable draw, GLXDrawable read,
+ GLXContext gc )
+{
+ assert( draw == read );
+ return (*gc->driContext.unbindContext)( dpy, scrn, draw, gc, GL_FALSE );
+}
+
+
+/****************************************************************************/
+/**
+ * Wrap the call to the driver's \c createContext function.
+ *
+ * The \c createContext function is wrapped because not all drivers support
+ * the "new" \c unbindContext2 and \c bindContext2 interfaces. libGL should
+ * not have to check to see which functions the driver supports. Instead,
+ * if either function is not supported it is wrapped. The wrappers test to
+ * make sure that both drawables are the same and pass control to the old
+ * interface.
+ *
+ * \sa dummyBindContext2, dummyUnbindContext2,
+ * __DRIcontextRec::bindContext2, __DRIcontextRec::unbindContext2
+ */
+
+static void * DriverCreateContextWrapper( const __GLXscreenConfigs *psc,
+ Display *dpy, XVisualInfo *vis,
+ void *shared,
+ __DRIcontext *ctx,
+ const __GLcontextModes *modes,
+ int render_type )
+{
+ void * ctx_priv = NULL;
+
+ if ( psc->driScreen.createNewContext != NULL ) {
+ assert( modes != NULL );
+ ctx_priv = (*psc->driScreen.createNewContext)(dpy, modes, render_type,
+ shared, ctx);
+
+ /* If the driver supports the createNewContext interface, then
+ * it MUST also support either the bindContext2 / unbindContext2
+ * interface or the bindContext3 / unbindContext3 interface.
+ */
+
+ assert( (ctx_priv == NULL) || (ctx->unbindContext2 != NULL)
+ || (ctx->unbindContext3 != NULL) );
+ assert( (ctx_priv == NULL) || (ctx->bindContext2 != NULL)
+ || (ctx->bindContext3 != NULL) );
+ }
+ else {
+ if ( vis != NULL ) {
+ ctx_priv = (*psc->driScreen.createContext)(dpy, vis, shared, ctx);
+
+ if ( ctx_priv != NULL ) {
+ if ( ctx->unbindContext2 == NULL ) {
+ ctx->unbindContext2 = dummyUnbindContext2;
+ }
+
+ if ( ctx->bindContext2 == NULL ) {
+ ctx->bindContext2 = dummyBindContext2;
+ }
+ }
+ }
+ }
+
+ return ctx_priv;
+}
+#endif
+
+
+/****************************************************************************/
+/**
+ * Get the __DRIdrawable for the drawable associated with a GLXContext
+ *
+ * \param dpy The display associated with \c drawable.
+ * \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved.
+ * \returns A pointer to the context's __DRIdrawable on success, or NULL if
+ * the drawable is not associated with a direct-rendering context.
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+static __DRIdrawable *
+GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num )
+{
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+ if ( (priv != NULL) && (priv->driDisplay.private != NULL) ) {
+ const unsigned screen_count = ScreenCount(dpy);
+ unsigned i;
+
+ for ( i = 0 ; i < screen_count ; i++ ) {
+ __DRIscreen * const psc = &priv->screenConfigs[i].driScreen;
+ __DRIdrawable * const pdraw = (psc->private != NULL)
+ ? (*psc->getDrawable)(dpy, drawable, psc->private) : NULL;
+
+ if ( pdraw != NULL ) {
+ if ( scrn_num != NULL ) {
+ *scrn_num = i;
+ }
+ return pdraw;
+ }
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+
+/**
+ * Get the GLX per-screen data structure associated with a GLX context.
+ *
+ * \param dpy Display for which the GLX per-screen information is to be
+ * retrieved.
+ * \param scrn Screen on \c dpy for which the GLX per-screen information is
+ * to be retrieved.
+ * \returns A pointer to the GLX per-screen data if \c dpy and \c scrn
+ * specify a valid GLX screen, or NULL otherwise.
+ *
+ * \todo Should this function validate that \c scrn is within the screen
+ * number range for \c dpy?
+ */
+
+static __GLXscreenConfigs *
+GetGLXScreenConfigs(Display *dpy, int scrn)
+{
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+ return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
+}
+
+
+static int
+GetGLXPrivScreenConfig( Display *dpy, int scrn, __GLXdisplayPrivate ** ppriv,
+ __GLXscreenConfigs ** ppsc )
+{
+ /* Initialize the extension, if needed . This has the added value
+ * of initializing/allocating the display private
+ */
+
+ if ( dpy == NULL ) {
+ return GLX_NO_EXTENSION;
+ }
+
+ *ppriv = __glXInitialize(dpy);
+ if ( *ppriv == NULL ) {
+ return GLX_NO_EXTENSION;
+ }
+
+ /* Check screen number to see if its valid */
+ if ((scrn < 0) || (scrn >= ScreenCount(dpy))) {
+ return GLX_BAD_SCREEN;
+ }
+
+ /* Check to see if the GL is supported on this screen */
+ *ppsc = &((*ppriv)->screenConfigs[scrn]);
+ if ( (*ppsc)->configs == NULL ) {
+ /* No support for GL on this screen regardless of visual */
+ return GLX_BAD_VISUAL;
+ }
+
+ return Success;
+}
+
+
+/**
+ * Determine if a \c GLXFBConfig supplied by the application is valid.
+ *
+ * \param dpy Application supplied \c Display pointer.
+ * \param config Application supplied \c GLXFBConfig.
+ *
+ * \returns If the \c GLXFBConfig is valid, the a pointer to the matching
+ * \c __GLcontextModes structure is returned. Otherwise, \c NULL
+ * is returned.
+ */
+static __GLcontextModes *
+ValidateGLXFBConfig( Display * dpy, GLXFBConfig config )
+{
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+ const unsigned num_screens = ScreenCount(dpy);
+ unsigned i;
+ const __GLcontextModes * modes;
+
+
+ if ( priv != NULL ) {
+ for ( i = 0 ; i < num_screens ; i++ ) {
+ for ( modes = priv->screenConfigs[i].configs
+ ; modes != NULL
+ ; modes = modes->next ) {
+ if ( modes == (__GLcontextModes *) config ) {
+ return (__GLcontextModes *) config;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ * \todo It should be possible to move the allocate of \c client_state_private
+ * later in the function for direct-rendering contexts. Direct-rendering
+ * contexts don't need to track client state, so they don't need that memory
+ * at all.
+ *
+ * \todo Eliminate \c __glXInitVertexArrayState. Replace it with a new
+ * function called \c __glXAllocateClientState that allocates the memory and
+ * does all the initialization (including the pixel pack / unpack).
+ */
+static
+GLXContext AllocateGLXContext( Display *dpy )
+{
+ GLXContext gc;
+ int bufSize;
+ CARD8 opcode;
+ __GLXattribute *state;
+
+ if (!dpy)
+ return NULL;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return NULL;
+ }
+
+ /* Allocate our context record */
+ gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec));
+ if (!gc) {
+ /* Out of memory */
+ return NULL;
+ }
+ memset(gc, 0, sizeof(struct __GLXcontextRec));
+
+ state = Xmalloc(sizeof(struct __GLXattributeRec));
+ if (state == NULL) {
+ /* Out of memory */
+ Xfree(gc);
+ return NULL;
+ }
+ gc->client_state_private = state;
+ memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec));
+ state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL);
+
+ /*
+ ** Create a temporary buffer to hold GLX rendering commands. The size
+ ** of the buffer is selected so that the maximum number of GLX rendering
+ ** commands can fit in a single X packet and still have room in the X
+ ** packet for the GLXRenderReq header.
+ */
+
+ bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq;
+ gc->buf = (GLubyte *) Xmalloc(bufSize);
+ if (!gc->buf) {
+ Xfree(gc->client_state_private);
+ Xfree(gc);
+ return NULL;
+ }
+ gc->bufSize = bufSize;
+
+ /* Fill in the new context */
+ gc->renderMode = GL_RENDER;
+
+ state->storePack.alignment = 4;
+ state->storeUnpack.alignment = 4;
+
+ __glXInitVertexArrayState(gc);
+
+ gc->attributes.stackPointer = &gc->attributes.stack[0];
+
+ /*
+ ** PERFORMANCE NOTE: A mode dependent fill image can speed things up.
+ ** Other code uses the fastImageUnpack bit, but it is never set
+ ** to GL_TRUE.
+ */
+ gc->fastImageUnpack = GL_FALSE;
+ gc->fillImage = __glFillImage;
+ gc->isDirect = GL_FALSE;
+ gc->pc = gc->buf;
+ gc->bufEnd = gc->buf + bufSize;
+ if (__glXDebug) {
+ /*
+ ** Set limit register so that there will be one command per packet
+ */
+ gc->limit = gc->buf;
+ } else {
+ gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
+ }
+ gc->createDpy = dpy;
+ gc->majorOpcode = opcode;
+
+ /*
+ ** Constrain the maximum drawing command size allowed to be
+ ** transfered using the X_GLXRender protocol request. First
+ ** constrain by a software limit, then constrain by the protocl
+ ** limit.
+ */
+ if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
+ bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
+ }
+ if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
+ bufSize = __GLX_MAX_RENDER_CMD_SIZE;
+ }
+ gc->maxSmallRenderCommandSize = bufSize;
+ return gc;
+}
+
+
+/**
+ * Create a new context. Exactly one of \c vis and \c fbconfig should be
+ * non-NULL.
+ *
+ * \param use_glx_1_3 For FBConfigs, should GLX 1.3 protocol or
+ * SGIX_fbconfig protocol be used?
+ * \param renderType For FBConfigs, what is the rendering type?
+ */
+
+static GLXContext
+CreateContext(Display *dpy, XVisualInfo *vis,
+ const __GLcontextModes * const fbconfig,
+ GLXContext shareList,
+ Bool allowDirect, GLXContextID contextID,
+ Bool use_glx_1_3, int renderType)
+{
+ GLXContext gc;
+
+ if ( dpy == NULL )
+ return NULL;
+
+ gc = AllocateGLXContext(dpy);
+ if (!gc)
+ return NULL;
+
+ if (None == contextID) {
+ if ( (vis == NULL) && (fbconfig == NULL) )
+ return NULL;
+
+#ifdef GLX_DIRECT_RENDERING
+ if (allowDirect) {
+ int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+ const __GLcontextModes * mode;
+
+ /* The value of fbconfig cannot change because it is tested
+ * later in the function.
+ */
+ if ( fbconfig == NULL ) {
+ /* FIXME: Is it possible for the __GLcontextModes structure
+ * FIXME: to not be found?
+ */
+ mode = _gl_context_modes_find_visual( psc->configs,
+ vis->visualid );
+ assert( mode != NULL );
+ assert( mode->screen == screen );
+ }
+ else {
+ mode = fbconfig;
+ }
+
+ if (psc && psc->driScreen.private) {
+ void * const shared = (shareList != NULL)
+ ? shareList->driContext.private : NULL;
+ gc->driContext.private =
+ DriverCreateContextWrapper( psc, dpy, vis, shared,
+ &gc->driContext, mode,
+ renderType );
+ if (gc->driContext.private) {
+ gc->isDirect = GL_TRUE;
+ gc->screen = mode->screen;
+ gc->vid = mode->visualID;
+ gc->fbconfigID = mode->fbconfigID;
+ gc->driContext.mode = mode;
+ }
+ }
+ }
+#endif
+
+ LockDisplay(dpy);
+ if ( fbconfig == NULL ) {
+ xGLXCreateContextReq *req;
+
+ /* Send the glXCreateContext request */
+ GetReq(GLXCreateContext,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXCreateContext;
+ req->context = gc->xid = XAllocID(dpy);
+ req->visual = vis->visualid;
+ req->screen = vis->screen;
+ req->shareList = shareList ? shareList->xid : None;
+ req->isDirect = gc->isDirect;
+ }
+ else if ( use_glx_1_3 ) {
+ xGLXCreateNewContextReq *req;
+
+ /* Send the glXCreateNewContext request */
+ GetReq(GLXCreateNewContext,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXCreateNewContext;
+ req->context = gc->xid = XAllocID(dpy);
+ req->fbconfig = fbconfig->fbconfigID;
+ req->screen = fbconfig->screen;
+ req->renderType = renderType;
+ req->shareList = shareList ? shareList->xid : None;
+ req->isDirect = gc->isDirect;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXCreateContextWithConfigSGIXReq *req;
+
+ /* Send the glXCreateNewContext request */
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXCreateContextWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ req = (xGLXCreateContextWithConfigSGIXReq *)vpreq;
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
+ req->context = gc->xid = XAllocID(dpy);
+ req->fbconfig = fbconfig->fbconfigID;
+ req->screen = fbconfig->screen;
+ req->renderType = renderType;
+ req->shareList = shareList ? shareList->xid : None;
+ req->isDirect = gc->isDirect;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ gc->imported = GL_FALSE;
+ }
+ else {
+ gc->xid = contextID;
+ gc->imported = GL_TRUE;
+ }
+
+ return gc;
+}
+
+
+GLXContext GLX_PREFIX(glXCreateContext)(Display *dpy, XVisualInfo *vis,
+ GLXContext shareList, Bool allowDirect)
+{
+ return CreateContext(dpy, vis, NULL, shareList, allowDirect, None,
+ False, 0);
+}
+
+void __glXFreeContext(__GLXcontext *gc)
+{
+ if (gc->vendor) XFree((char *) gc->vendor);
+ if (gc->renderer) XFree((char *) gc->renderer);
+ if (gc->version) XFree((char *) gc->version);
+ if (gc->extensions) XFree((char *) gc->extensions);
+ __glFreeAttributeState(gc);
+ XFree((char *) gc->buf);
+ Xfree((char *) gc->client_state_private);
+ XFree((char *) gc);
+
+}
+
+/*
+** Destroy the named context
+*/
+static void
+DestroyContext(Display *dpy, GLXContext gc)
+{
+ xGLXDestroyContextReq *req;
+ GLXContextID xid;
+ CARD8 opcode;
+ GLboolean imported;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode || !gc) {
+ return;
+ }
+
+ __glXLock();
+ xid = gc->xid;
+ imported = gc->imported;
+ gc->xid = None;
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Destroy the direct rendering context */
+ if (gc->isDirect) {
+ if (gc->driContext.private) {
+ (*gc->driContext.destroyContext)(dpy, gc->screen,
+ gc->driContext.private);
+ gc->driContext.private = NULL;
+ }
+ }
+#endif
+
+ if (gc->currentDpy) {
+ /* Have to free later cuz it's in use now */
+ __glXUnlock();
+ } else {
+ /* Destroy the handle if not current to anybody */
+ __glXUnlock();
+ __glXFreeContext(gc);
+ }
+
+ if (!imported) {
+ /*
+ ** This dpy also created the server side part of the context.
+ ** Send the glXDestroyContext request.
+ */
+ LockDisplay(dpy);
+ GetReq(GLXDestroyContext,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXDestroyContext;
+ req->context = xid;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+}
+void GLX_PREFIX(glXDestroyContext)(Display *dpy, GLXContext gc)
+{
+ DestroyContext(dpy, gc);
+}
+
+/*
+** Return the major and minor version #s for the GLX extension
+*/
+Bool GLX_PREFIX(glXQueryVersion)(Display *dpy, int *major, int *minor)
+{
+ __GLXdisplayPrivate *priv;
+
+ /* Init the extension. This fetches the major and minor version. */
+ priv = __glXInitialize(dpy);
+ if (!priv) return GL_FALSE;
+
+ if (major) *major = priv->majorVersion;
+ if (minor) *minor = priv->minorVersion;
+ return GL_TRUE;
+}
+
+/*
+** Query the existance of the GLX extension
+*/
+Bool GLX_PREFIX(glXQueryExtension)(Display *dpy, int *errorBase, int *eventBase)
+{
+ int major_op, erb, evb;
+ Bool rv;
+
+ rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb);
+ if (rv) {
+ if (errorBase) *errorBase = erb;
+ if (eventBase) *eventBase = evb;
+ }
+ return rv;
+}
+
+/*
+** Put a barrier in the token stream that forces the GL to finish its
+** work before X can proceed.
+*/
+void GLX_PREFIX(glXWaitGL)(void)
+{
+ xGLXWaitGLReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ /* Flush any pending commands out */
+ __glXFlushRenderBuffer(gc, gc->pc);
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+/* This bit of ugliness unwraps the glFinish function */
+#ifdef glFinish
+#undef glFinish
+#endif
+ glFinish();
+ return;
+ }
+#endif
+
+ /* Send the glXWaitGL request */
+ LockDisplay(dpy);
+ GetReq(GLXWaitGL,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXWaitGL;
+ req->contextTag = gc->currentContextTag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+/*
+** Put a barrier in the token stream that forces X to finish its
+** work before GL can proceed.
+*/
+void GLX_PREFIX(glXWaitX)(void)
+{
+ xGLXWaitXReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ /* Flush any pending commands out */
+ __glXFlushRenderBuffer(gc, gc->pc);
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+ XSync(dpy, False);
+ return;
+ }
+#endif
+
+ /*
+ ** Send the glXWaitX request.
+ */
+ LockDisplay(dpy);
+ GetReq(GLXWaitX,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXWaitX;
+ req->contextTag = gc->currentContextTag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void GLX_PREFIX(glXUseXFont)(Font font, int first, int count, int listBase)
+{
+ xGLXUseXFontReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ /* Flush any pending commands out */
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+ DRI_glXUseXFont(font, first, count, listBase);
+ return;
+ }
+#endif
+
+ /* Send the glXUseFont request */
+ LockDisplay(dpy);
+ GetReq(GLXUseXFont,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXUseXFont;
+ req->contextTag = gc->currentContextTag;
+ req->font = font;
+ req->first = first;
+ req->count = count;
+ req->listBase = listBase;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+/************************************************************************/
+
+/*
+** Copy the source context to the destination context using the
+** attribute "mask".
+*/
+void GLX_PREFIX(glXCopyContext)(Display *dpy, GLXContext source, GLXContext dest,
+ unsigned long mask)
+{
+ xGLXCopyContextReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ GLXContextTag tag;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return;
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+ /* NOT_DONE: This does not work yet */
+ }
+#endif
+
+ /*
+ ** If the source is the current context, send its tag so that the context
+ ** can be flushed before the copy.
+ */
+ if (source == gc && dpy == gc->currentDpy) {
+ tag = gc->currentContextTag;
+ } else {
+ tag = 0;
+ }
+
+ /* Send the glXCopyContext request */
+ LockDisplay(dpy);
+ GetReq(GLXCopyContext,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXCopyContext;
+ req->source = source ? source->xid : None;
+ req->dest = dest ? dest->xid : None;
+ req->mask = mask;
+ req->contextTag = tag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+/**
+ * Determine if a context uses direct rendering.
+ *
+ * \param dpy Display where the context was created.
+ * \param contextID ID of the context to be tested.
+ *
+ * \returns \c GL_TRUE if the context is direct rendering or not.
+ */
+static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
+{
+ xGLXIsDirectReq *req;
+ xGLXIsDirectReply reply;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return GL_FALSE;
+ }
+
+ /* Send the glXIsDirect request */
+ LockDisplay(dpy);
+ GetReq(GLXIsDirect,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXIsDirect;
+ req->context = contextID;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return reply.isDirect;
+}
+
+Bool GLX_PREFIX(glXIsDirect)(Display *dpy, GLXContext gc)
+{
+ if (!gc) {
+ return GL_FALSE;
+#ifdef GLX_DIRECT_RENDERING
+ } else if (gc->isDirect) {
+ return GL_TRUE;
+#endif
+ }
+ return __glXIsDirect(dpy, gc->xid);
+}
+
+GLXPixmap GLX_PREFIX(glXCreateGLXPixmap)(Display *dpy, XVisualInfo *vis, Pixmap pixmap)
+{
+ xGLXCreateGLXPixmapReq *req;
+ GLXPixmap xid;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return None;
+ }
+
+ /* Send the glXCreateGLXPixmap request */
+ LockDisplay(dpy);
+ GetReq(GLXCreateGLXPixmap,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXCreateGLXPixmap;
+ req->screen = vis->screen;
+ req->visual = vis->visualid;
+ req->pixmap = pixmap;
+ req->glxpixmap = xid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return xid;
+}
+
+/*
+** Destroy the named pixmap
+*/
+void GLX_PREFIX(glXDestroyGLXPixmap)(Display *dpy, GLXPixmap glxpixmap)
+{
+ xGLXDestroyGLXPixmapReq *req;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return;
+ }
+
+ /* Send the glXDestroyGLXPixmap request */
+ LockDisplay(dpy);
+ GetReq(GLXDestroyGLXPixmap,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXDestroyGLXPixmap;
+ req->glxpixmap = glxpixmap;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void GLX_PREFIX(glXSwapBuffers)(Display *dpy, GLXDrawable drawable)
+{
+ xGLXSwapBuffersReq *req;
+ GLXContext gc;
+ GLXContextTag tag;
+ CARD8 opcode;
+#ifdef GLX_DIRECT_RENDERING
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL );
+
+ if ( pdraw != NULL ) {
+ (*pdraw->swapBuffers)(dpy, pdraw->private);
+ return;
+ }
+#endif
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return;
+ }
+
+ /*
+ ** The calling thread may or may not have a current context. If it
+ ** does, send the context tag so the server can do a flush.
+ */
+ gc = __glXGetCurrentContext();
+ if ((gc != NULL) && (dpy == gc->currentDpy) &&
+ ((drawable == gc->currentDrawable) || (drawable == gc->currentReadable)) ) {
+ tag = gc->currentContextTag;
+ } else {
+ tag = 0;
+ }
+
+ /* Send the glXSwapBuffers request */
+ LockDisplay(dpy);
+ GetReq(GLXSwapBuffers,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXSwapBuffers;
+ req->drawable = drawable;
+ req->contextTag = tag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XFlush(dpy);
+}
+
+
+/*
+** Return configuration information for the given display, screen and
+** visual combination.
+*/
+int GLX_PREFIX(glXGetConfig)(Display *dpy, XVisualInfo *vis, int attribute,
+ int *value_return)
+{
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *psc;
+ int status;
+
+ status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc );
+ if ( status == Success ) {
+ const __GLcontextModes * const modes = _gl_context_modes_find_visual(
+ psc->configs, vis->visualid );
+
+ /* Lookup attribute after first finding a match on the visual */
+ if ( modes != NULL ) {
+ return _gl_get_context_mode_data( modes, attribute, value_return );
+ }
+
+ status = GLX_BAD_VISUAL;
+ }
+
+ /*
+ ** If we can't find the config for this visual, this visual is not
+ ** supported by the OpenGL implementation on the server.
+ */
+ if ( (status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL) ) {
+ *value_return = GL_FALSE;
+ status = Success;
+ }
+
+ return status;
+}
+
+/************************************************************************/
+
+static void
+init_fbconfig_for_chooser( __GLcontextModes * config,
+ GLboolean fbconfig_style_tags )
+{
+ memset( config, 0, sizeof( __GLcontextModes ) );
+ config->visualID = (XID) GLX_DONT_CARE;
+ config->visualType = GLX_DONT_CARE;
+
+ /* glXChooseFBConfig specifies different defaults for these two than
+ * glXChooseVisual.
+ */
+ if ( fbconfig_style_tags ) {
+ config->rgbMode = GL_TRUE;
+ config->doubleBufferMode = GLX_DONT_CARE;
+ }
+
+ config->visualRating = GLX_DONT_CARE;
+ config->transparentPixel = GLX_NONE;
+ config->transparentRed = GLX_DONT_CARE;
+ config->transparentGreen = GLX_DONT_CARE;
+ config->transparentBlue = GLX_DONT_CARE;
+ config->transparentAlpha = GLX_DONT_CARE;
+ config->transparentIndex = GLX_DONT_CARE;
+
+ config->drawableType = GLX_WINDOW_BIT;
+ config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+ config->xRenderable = GLX_DONT_CARE;
+ config->fbconfigID = (GLXFBConfigID)(GLX_DONT_CARE);
+
+ config->swapMethod = GLX_DONT_CARE;
+}
+
+#define MATCH_DONT_CARE( param ) \
+ do { \
+ if ( (a-> param != GLX_DONT_CARE) \
+ && (a-> param != b-> param) ) { \
+ return False; \
+ } \
+ } while ( 0 )
+
+#define MATCH_MINIMUM( param ) \
+ do { \
+ if ( (a-> param != GLX_DONT_CARE) \
+ && (a-> param > b-> param) ) { \
+ return False; \
+ } \
+ } while ( 0 )
+
+#define MATCH_EXACT( param ) \
+ do { \
+ if ( a-> param != b-> param) { \
+ return False; \
+ } \
+ } while ( 0 )
+
+/**
+ * Determine if two GLXFBConfigs are compatible.
+ *
+ * \param a Application specified config to test.
+ * \param b Server specified config to test against \c a.
+ */
+static Bool
+fbconfigs_compatible( const __GLcontextModes * const a,
+ const __GLcontextModes * const b )
+{
+ MATCH_DONT_CARE( doubleBufferMode );
+ MATCH_DONT_CARE( visualType );
+ MATCH_DONT_CARE( visualRating );
+ MATCH_DONT_CARE( xRenderable );
+ MATCH_DONT_CARE( fbconfigID );
+ MATCH_DONT_CARE( swapMethod );
+
+ MATCH_MINIMUM( rgbBits );
+ MATCH_MINIMUM( numAuxBuffers );
+ MATCH_MINIMUM( redBits );
+ MATCH_MINIMUM( greenBits );
+ MATCH_MINIMUM( blueBits );
+ MATCH_MINIMUM( alphaBits );
+ MATCH_MINIMUM( depthBits );
+ MATCH_MINIMUM( stencilBits );
+ MATCH_MINIMUM( accumRedBits );
+ MATCH_MINIMUM( accumGreenBits );
+ MATCH_MINIMUM( accumBlueBits );
+ MATCH_MINIMUM( accumAlphaBits );
+ MATCH_MINIMUM( sampleBuffers );
+ MATCH_MINIMUM( maxPbufferWidth );
+ MATCH_MINIMUM( maxPbufferHeight );
+ MATCH_MINIMUM( maxPbufferPixels );
+ MATCH_MINIMUM( samples );
+
+ MATCH_DONT_CARE( stereoMode );
+ MATCH_EXACT( level );
+
+ if ( ((a->drawableType & b->drawableType) == 0)
+ || ((a->renderType & b->renderType) == 0) ) {
+ return False;
+ }
+
+
+ /* There is a bug in a few of the XFree86 DDX drivers. They contain
+ * visuals with a "transparent type" of 0 when they really mean GLX_NONE.
+ * Technically speaking, it is a bug in the DDX driver, but there is
+ * enough of an installed base to work around the problem here. In any
+ * case, 0 is not a valid value of the transparent type, so we'll treat 0
+ * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and
+ * 0 from the server to be a match to maintain backward compatibility with
+ * the (broken) drivers.
+ */
+
+ if ( a->transparentPixel != GLX_DONT_CARE
+ && a->transparentPixel != 0 ) {
+ if ( a->transparentPixel == GLX_NONE ) {
+ if ( b->transparentPixel != GLX_NONE && b->transparentPixel != 0 )
+ return False;
+ } else {
+ MATCH_EXACT( transparentPixel );
+ }
+
+ switch ( a->transparentPixel ) {
+ case GLX_TRANSPARENT_RGB:
+ MATCH_DONT_CARE( transparentRed );
+ MATCH_DONT_CARE( transparentGreen );
+ MATCH_DONT_CARE( transparentBlue );
+ MATCH_DONT_CARE( transparentAlpha );
+ break;
+
+ case GLX_TRANSPARENT_INDEX:
+ MATCH_DONT_CARE( transparentIndex );
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return True;
+}
+
+
+/* There's some trickly language in the GLX spec about how this is supposed
+ * to work. Basically, if a given component size is either not specified
+ * or the requested size is zero, it is supposed to act like PERFER_SMALLER.
+ * Well, that's really hard to do with the code as-is. This behavior is
+ * closer to correct, but still not technically right.
+ */
+#define PREFER_LARGER_OR_ZERO(comp) \
+ do { \
+ if ( ((*a)-> comp) != ((*b)-> comp) ) { \
+ if ( ((*a)-> comp) == 0 ) { \
+ return -1; \
+ } \
+ else if ( ((*b)-> comp) == 0 ) { \
+ return 1; \
+ } \
+ else { \
+ return ((*b)-> comp) - ((*a)-> comp) ; \
+ } \
+ } \
+ } while( 0 )
+
+#define PREFER_LARGER(comp) \
+ do { \
+ if ( ((*a)-> comp) != ((*b)-> comp) ) { \
+ return ((*b)-> comp) - ((*a)-> comp) ; \
+ } \
+ } while( 0 )
+
+#define PREFER_SMALLER(comp) \
+ do { \
+ if ( ((*a)-> comp) != ((*b)-> comp) ) { \
+ return ((*a)-> comp) - ((*b)-> comp) ; \
+ } \
+ } while( 0 )
+
+/**
+ * Compare two GLXFBConfigs. This function is intended to be used as the
+ * compare function passed in to qsort.
+ *
+ * \returns If \c a is a "better" config, according to the specification of
+ * SGIX_fbconfig, a number less than zero is returned. If \c b is
+ * better, then a number greater than zero is return. If both are
+ * equal, zero is returned.
+ * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
+ */
+static int
+fbconfig_compare( const __GLcontextModes * const * const a,
+ const __GLcontextModes * const * const b )
+{
+ /* The order of these comparisons must NOT change. It is defined by
+ * the GLX 1.3 spec and ARB_multisample.
+ */
+
+ PREFER_SMALLER( visualSelectGroup );
+
+ /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and
+ * GLX_NON_CONFORMANT_CONFIG. It just so happens that this is the
+ * numerical sort order of the enums (0x8000, 0x8001, and 0x800D).
+ */
+ PREFER_SMALLER( visualRating );
+
+ /* This isn't quite right. It is supposed to compare the sum of the
+ * components the user specifically set minimums for.
+ */
+ PREFER_LARGER_OR_ZERO( redBits );
+ PREFER_LARGER_OR_ZERO( greenBits );
+ PREFER_LARGER_OR_ZERO( blueBits );
+ PREFER_LARGER_OR_ZERO( alphaBits );
+
+ PREFER_SMALLER( rgbBits );
+
+ if ( ((*a)->doubleBufferMode != (*b)->doubleBufferMode) ) {
+ /* Prefer single-buffer.
+ */
+ return ( !(*a)->doubleBufferMode ) ? -1 : 1;
+ }
+
+ PREFER_SMALLER( numAuxBuffers );
+
+ PREFER_LARGER_OR_ZERO( depthBits );
+ PREFER_SMALLER( stencilBits );
+
+ /* This isn't quite right. It is supposed to compare the sum of the
+ * components the user specifically set minimums for.
+ */
+ PREFER_LARGER_OR_ZERO( accumRedBits );
+ PREFER_LARGER_OR_ZERO( accumGreenBits );
+ PREFER_LARGER_OR_ZERO( accumBlueBits );
+ PREFER_LARGER_OR_ZERO( accumAlphaBits );
+
+ PREFER_SMALLER( visualType );
+
+ /* None of the multisample specs say where this comparison should happen,
+ * so I put it near the end.
+ */
+ PREFER_SMALLER( sampleBuffers );
+ PREFER_SMALLER( samples );
+
+ /* None of the pbuffer or fbconfig specs say that this comparison needs
+ * to happen at all, but it seems like it should.
+ */
+ PREFER_LARGER( maxPbufferWidth );
+ PREFER_LARGER( maxPbufferHeight );
+ PREFER_LARGER( maxPbufferPixels );
+
+ return 0;
+}
+
+
+/**
+ * Selects and sorts a subset of the supplied configs based on the attributes.
+ * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig,
+ * and \c glXChooseFBConfigSGIX.
+ *
+ * \param configs Array of pointers to possible configs. The elements of
+ * this array that do not meet the criteria will be set to
+ * NULL. The remaining elements will be sorted according to
+ * the various visual / FBConfig selection rules.
+ * \param num_configs Number of elements in the \c configs array.
+ * \param attribList Attributes used select from \c configs. This array is
+ * terminated by a \c None tag. The array can either take
+ * the form expected by \c glXChooseVisual (where boolean
+ * tags do not have a value) or by \c glXChooseFBConfig
+ * (where every tag has a value).
+ * \param fbconfig_style_tags Selects whether \c attribList is in
+ * \c glXChooseVisual style or
+ * \c glXChooseFBConfig style.
+ * \returns The number of valid elements left in \c configs.
+ *
+ * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
+ */
+static int
+choose_visual( __GLcontextModes ** configs, int num_configs,
+ const int *attribList, GLboolean fbconfig_style_tags )
+{
+ __GLcontextModes test_config;
+ int base;
+ int i;
+
+ /* This is a fairly direct implementation of the selection method
+ * described by GLX_SGIX_fbconfig. Start by culling out all the
+ * configs that are not compatible with the selected parameter
+ * list.
+ */
+
+ init_fbconfig_for_chooser( & test_config, fbconfig_style_tags );
+ __glXInitializeVisualConfigFromTags( & test_config, 512,
+ (const INT32 *) attribList,
+ GL_TRUE, fbconfig_style_tags );
+
+ base = 0;
+ for ( i = 0 ; i < num_configs ; i++ ) {
+ if ( fbconfigs_compatible( & test_config, configs[i] ) ) {
+ configs[ base ] = configs[ i ];
+ base++;
+ }
+ }
+
+ if ( base == 0 ) {
+ return 0;
+ }
+
+ if ( base < num_configs ) {
+ (void) memset( & configs[ base ], 0,
+ sizeof( void * ) * (num_configs - base) );
+ }
+
+ /* After the incompatible configs are removed, the resulting
+ * list is sorted according to the rules set out in the various
+ * specifications.
+ */
+
+ qsort( configs, base, sizeof( __GLcontextModes * ),
+ (int (*)(const void*, const void*)) fbconfig_compare );
+ return base;
+}
+
+
+
+
+/*
+** Return the visual that best matches the template. Return None if no
+** visual matches the template.
+*/
+XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, int *attribList)
+{
+ XVisualInfo *visualList = NULL;
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *psc;
+ __GLcontextModes test_config;
+ __GLcontextModes *modes;
+ const __GLcontextModes *best_config = NULL;
+
+ /*
+ ** Get a list of all visuals, return if list is empty
+ */
+ if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
+ return None;
+ }
+
+
+ /*
+ ** Build a template from the defaults and the attribute list
+ ** Free visual list and return if an unexpected token is encountered
+ */
+ init_fbconfig_for_chooser( & test_config, GL_FALSE );
+ __glXInitializeVisualConfigFromTags( & test_config, 512,
+ (const INT32 *) attribList,
+ GL_TRUE, GL_FALSE );
+
+ /*
+ ** Eliminate visuals that don't meet minimum requirements
+ ** Compute a score for those that do
+ ** Remember which visual, if any, got the highest score
+ */
+ for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) {
+ if ( fbconfigs_compatible( & test_config, modes )
+ && ((best_config == NULL)
+ || (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) {
+ best_config = modes;
+ }
+ }
+
+ /*
+ ** If no visual is acceptable, return None
+ ** Otherwise, create an XVisualInfo list with just the selected X visual
+ ** and return this.
+ */
+ if (best_config != NULL) {
+ XVisualInfo visualTemplate;
+ int i;
+
+ visualTemplate.screen = screen;
+ visualTemplate.visualid = best_config->visualID;
+ visualList = XGetVisualInfo( dpy, VisualScreenMask|VisualIDMask,
+ &visualTemplate, &i );
+ }
+
+ return visualList;
+}
+
+
+const char *GLX_PREFIX(glXQueryExtensionsString)( Display *dpy, int screen )
+{
+ __GLXscreenConfigs *psc;
+ __GLXdisplayPrivate *priv;
+
+ if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
+ return NULL;
+ }
+
+ if (!psc->effectiveGLXexts) {
+ if (!psc->serverGLXexts) {
+ psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ screen, GLX_EXTENSIONS);
+ }
+
+ __glXCalculateUsableExtensions(psc,
+#ifdef GLX_DIRECT_RENDERING
+ (priv->driDisplay.private != NULL),
+#else
+ GL_FALSE,
+#endif
+ priv->minorVersion);
+ }
+
+ return psc->effectiveGLXexts;
+}
+
+const char *GLX_PREFIX(glXGetClientString)( Display *dpy, int name )
+{
+ switch(name) {
+ case GLX_VENDOR:
+ return (__glXGLXClientVendorName);
+ case GLX_VERSION:
+ return (__glXGLXClientVersion);
+ case GLX_EXTENSIONS:
+ return (__glXGetClientExtensions());
+ default:
+ return NULL;
+ }
+}
+
+const char *GLX_PREFIX(glXQueryServerString)( Display *dpy, int screen, int name )
+{
+ __GLXscreenConfigs *psc;
+ __GLXdisplayPrivate *priv;
+ const char ** str;
+
+
+ if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
+ return NULL;
+ }
+
+ switch(name) {
+ case GLX_VENDOR:
+ str = & priv->serverGLXvendor;
+ break;
+ case GLX_VERSION:
+ str = & priv->serverGLXversion;
+ break;
+ case GLX_EXTENSIONS:
+ str = & psc->serverGLXexts;
+ break;
+ default:
+ return NULL;
+ }
+
+ if ( *str == NULL ) {
+ *str = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString, screen, name);
+ }
+
+ return *str;
+}
+
+void __glXClientInfo ( Display *dpy, int opcode )
+{
+ xGLXClientInfoReq *req;
+ int size;
+ char * ext_str = __glXGetClientGLExtensionString();
+
+ /* Send the glXClientInfo request */
+ LockDisplay(dpy);
+ GetReq(GLXClientInfo,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXClientInfo;
+ req->major = GLX_MAJOR_VERSION;
+ req->minor = GLX_MINOR_VERSION;
+
+ size = strlen( ext_str ) + 1;
+ req->length += (size + 3) >> 2;
+ req->numbytes = size;
+ Data(dpy, ext_str, size);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ Xfree( ext_str );
+}
+
+
+/*
+** EXT_import_context
+*/
+
+Display *glXGetCurrentDisplay(void)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ if (NULL == gc) return NULL;
+ return gc->currentDpy;
+}
+
+GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
+ glXGetCurrentDisplay)
+
+/**
+ * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests
+ * to the X-server.
+ *
+ * \param dpy Display where \c ctx was created.
+ * \param ctx Context to query.
+ * \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid,
+ * or zero if the request failed due to internal problems (i.e.,
+ * unable to allocate temporary memory, etc.)
+ *
+ * \note
+ * This function dynamically determines whether to use the EXT_import_context
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ */
+static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ xGLXQueryContextReply reply;
+ CARD8 opcode;
+ GLuint numValues;
+ int retval;
+
+ if (ctx == NULL) {
+ return GLX_BAD_CONTEXT;
+ }
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return 0;
+ }
+
+ /* Send the glXQueryContextInfoEXT request */
+ LockDisplay(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXQueryContextReq *req;
+
+ GetReq(GLXQueryContext, req);
+
+ req->reqType = opcode;
+ req->glxCode = X_GLXQueryContext;
+ req->context = (unsigned int)(ctx->xid);
+ }
+ else {
+ xGLXVendorPrivateReq *vpreq;
+ xGLXQueryContextInfoEXTReq *req;
+
+ GetReqExtra( GLXVendorPrivate,
+ sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
+ vpreq );
+ req = (xGLXQueryContextInfoEXTReq *)vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_QueryContextInfoEXT;
+ req->context = (unsigned int)(ctx->xid);
+ }
+
+ _XReply(dpy, (xReply*) &reply, 0, False);
+
+ numValues = reply.n;
+ if (numValues == 0)
+ retval = Success;
+ else if (numValues > __GLX_MAX_CONTEXT_PROPS)
+ retval = 0;
+ else
+ {
+ int *propList, *pProp;
+ int nPropListBytes;
+ int i;
+
+ nPropListBytes = numValues << 3;
+ propList = (int *) Xmalloc(nPropListBytes);
+ if (NULL == propList) {
+ retval = 0;
+ } else {
+ _XRead(dpy, (char *)propList, nPropListBytes);
+ pProp = propList;
+ for (i=0; i < numValues; i++) {
+ switch (*pProp++) {
+ case GLX_SHARE_CONTEXT_EXT:
+ ctx->share_xid = *pProp++;
+ break;
+ case GLX_VISUAL_ID_EXT:
+ ctx->vid = *pProp++;
+ break;
+ case GLX_SCREEN:
+ ctx->screen = *pProp++;
+ break;
+ case GLX_FBCONFIG_ID:
+ ctx->fbconfigID = *pProp++;
+ break;
+ case GLX_RENDER_TYPE:
+ ctx->renderType = *pProp++;
+ break;
+ default:
+ pProp++;
+ continue;
+ }
+ }
+ Xfree((char *)propList);
+ retval = Success;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return retval;
+}
+
+int
+GLX_PREFIX(glXQueryContext)(Display *dpy, GLXContext ctx,
+ int attribute, int *value)
+{
+ int retVal;
+
+ /* get the information from the server if we don't have it already */
+ if (!ctx->isDirect && (ctx->vid == None)) {
+ retVal = __glXQueryContextInfo(dpy, ctx);
+ if (Success != retVal) return retVal;
+ }
+ switch (attribute) {
+ case GLX_SHARE_CONTEXT_EXT:
+ *value = (int)(ctx->share_xid);
+ break;
+ case GLX_VISUAL_ID_EXT:
+ *value = (int)(ctx->vid);
+ break;
+ case GLX_SCREEN:
+ *value = (int)(ctx->screen);
+ break;
+ case GLX_FBCONFIG_ID:
+ *value = (int)(ctx->fbconfigID);
+ break;
+ case GLX_RENDER_TYPE:
+ *value = (int)(ctx->renderType);
+ break;
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+ return Success;
+}
+
+GLX_ALIAS( int, glXQueryContextInfoEXT,
+ (Display *dpy, GLXContext ctx, int attribute, int *value),
+ (dpy, ctx, attribute, value),
+ glXQueryContext )
+
+GLXContextID glXGetContextIDEXT(const GLXContext ctx)
+{
+ return ctx->xid;
+}
+
+GLXContext GLX_PREFIX(glXImportContextEXT)(Display *dpy, GLXContextID contextID)
+{
+ GLXContext ctx;
+
+ if (contextID == None) {
+ return NULL;
+ }
+ if (__glXIsDirect(dpy, contextID)) {
+ return NULL;
+ }
+
+ ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0);
+ if (NULL != ctx) {
+ if (Success != __glXQueryContextInfo(dpy, ctx)) {
+ return NULL;
+ }
+ }
+ return ctx;
+}
+
+void GLX_PREFIX(glXFreeContextEXT)(Display *dpy, GLXContext ctx)
+{
+ DestroyContext(dpy, ctx);
+}
+
+
+
+/*
+ * GLX 1.3 functions - these are just stubs for now!
+ */
+
+GLXFBConfig *GLX_PREFIX(glXChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems)
+{
+ __GLcontextModes ** config_list;
+ int list_size;
+
+
+ config_list = (__GLcontextModes **)
+ GLX_PREFIX(glXGetFBConfigs)( dpy, screen, & list_size );
+
+ if ( (config_list != NULL) && (list_size > 0) ) {
+ list_size = choose_visual( config_list, list_size, attribList,
+ GL_TRUE );
+ if ( list_size == 0 ) {
+ XFree( config_list );
+ config_list = NULL;
+ }
+ }
+
+ *nitems = list_size;
+ return (GLXFBConfig *) config_list;
+}
+
+
+GLXContext GLX_PREFIX(glXCreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool allowDirect)
+{
+ return CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,
+ allowDirect, None, True, renderType );
+}
+
+
+GLXDrawable GLX_PREFIX(glXGetCurrentReadDrawable)(void)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ return gc->currentReadable;
+}
+
+
+GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, int *nelements)
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ __GLcontextModes ** config = NULL;
+ int i;
+
+ if ( (priv->screenConfigs != NULL)
+ && (screen >= 0) && (screen <= ScreenCount(dpy))
+ && (priv->screenConfigs[screen].configs != NULL)
+ && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE) ) {
+ unsigned num_configs = 0;
+ __GLcontextModes * modes;
+
+
+ for ( modes = priv->screenConfigs[screen].configs
+ ; modes != NULL
+ ; modes = modes->next ) {
+ if ( modes->fbconfigID != GLX_DONT_CARE ) {
+ num_configs++;
+ }
+ }
+
+ config = (__GLcontextModes **) Xmalloc( sizeof(__GLcontextModes *)
+ * num_configs );
+ if ( config != NULL ) {
+ *nelements = num_configs;
+ i = 0;
+ for ( modes = priv->screenConfigs[screen].configs
+ ; modes != NULL
+ ; modes = modes->next ) {
+ config[i] = modes;
+ i++;
+ }
+ }
+ }
+ return (GLXFBConfig *) config;
+}
+
+
+int GLX_PREFIX(glXGetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value)
+{
+ __GLcontextModes * const modes = ValidateGLXFBConfig( dpy, config );
+
+ return (modes != NULL)
+ ? _gl_get_context_mode_data( modes, attribute, value )
+ : GLXBadFBConfig;
+}
+
+
+XVisualInfo *GLX_PREFIX(glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config)
+{
+ XVisualInfo visualTemplate;
+ __GLcontextModes * fbconfig = (__GLcontextModes *) config;
+ int count;
+
+ /*
+ ** Get a list of all visuals, return if list is empty
+ */
+ visualTemplate.visualid = fbconfig->visualID;
+ return XGetVisualInfo(dpy,VisualIDMask,&visualTemplate,&count);
+}
+
+
+/*
+** GLX_SGI_make_current_read
+*/
+
+GLX_ALIAS(GLXDrawable, glXGetCurrentReadDrawableSGI, (void), (),
+ glXGetCurrentReadDrawable)
+
+
+/*
+** GLX_SGI_swap_control
+*/
+int GLX_PREFIX(glXSwapIntervalSGI)(int interval)
+{
+ xGLXVendorPrivateReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display * dpy;
+ CARD32 * interval_ptr;
+ CARD8 opcode;
+
+ if ( gc == NULL ) {
+ return GLX_BAD_CONTEXT;
+ }
+
+ if ( interval <= 0 ) {
+ return GLX_BAD_VALUE;
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ if ( gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+ __DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy,
+ gc->currentDrawable,
+ NULL );
+ if ( __glXExtensionBitIsEnabled( psc, SGI_swap_control_bit )
+ && (pdraw != NULL) ) {
+ pdraw->swap_interval = interval;
+ return 0;
+ }
+ else {
+ return GLX_BAD_CONTEXT;
+ }
+ }
+#endif
+ dpy = gc->currentDpy;
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return 0;
+ }
+
+ /* Send the glXSwapIntervalSGI request */
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate,sizeof(CARD32),req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivate;
+ req->vendorCode = X_GLXvop_SwapIntervalSGI;
+ req->contextTag = gc->currentContextTag;
+
+ interval_ptr = (CARD32 *) req + 1;
+ *interval_ptr = interval;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XFlush(dpy);
+
+ return 0;
+}
+
+
+/*
+** GLX_MESA_swap_control
+*/
+GLint GLX_PREFIX(glXSwapIntervalMESA)(unsigned interval)
+{
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+ if ( interval < 0 ) {
+ return GLX_BAD_VALUE;
+ }
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+
+ if ( (psc != NULL) && (psc->driScreen.private != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) {
+ __DRIdrawable * const pdraw =
+ (*psc->driScreen.getDrawable)(gc->currentDpy,
+ gc->currentDrawable,
+ psc->driScreen.private);
+ if ( pdraw != NULL ) {
+ pdraw->swap_interval = interval;
+ return 0;
+ }
+ }
+ }
+#else
+ (void) interval;
+#endif
+
+ return GLX_BAD_CONTEXT;
+}
+
+GLint GLX_PREFIX(glXGetSwapIntervalMESA)( void )
+{
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+
+ if ( (psc != NULL) && (psc->driScreen.private != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) {
+ __DRIdrawable * const pdraw =
+ (*psc->driScreen.getDrawable)(gc->currentDpy,
+ gc->currentDrawable,
+ psc->driScreen.private);
+ if ( pdraw != NULL ) {
+ return pdraw->swap_interval;
+ }
+ }
+ }
+#endif
+
+ return 0;
+}
+
+
+/*
+** GLX_MESA_swap_frame_usage
+*/
+
+GLint GLX_PREFIX(glXBeginFrameTrackingMESA)(Display *dpy, GLXDrawable drawable)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL) && (pdraw->frameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ status = pdraw->frameTracking( dpy, pdraw->private, GL_TRUE );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+#endif
+ return status;
+}
+
+
+GLint GLX_PREFIX(glXEndFrameTrackingMESA)(Display *dpy, GLXDrawable drawable)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL) && (pdraw->frameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ status = pdraw->frameTracking( dpy, pdraw->private, GL_FALSE );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+#endif
+ return status;
+}
+
+
+GLint GLX_PREFIX(glXGetFrameUsageMESA)(Display *dpy, GLXDrawable drawable,
+ GLfloat *usage)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ int64_t sbc, missedFrames;
+ float lastMissedUsage;
+
+ status = pdraw->queryFrameTracking( dpy, pdraw->private, &sbc,
+ &missedFrames, &lastMissedUsage,
+ usage );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) usage;
+#endif
+ return status;
+}
+
+
+GLint GLX_PREFIX(glXQueryFrameTrackingMESA)(Display *dpy, GLXDrawable drawable,
+ int64_t *sbc, int64_t *missedFrames,
+ GLfloat *lastMissedUsage)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ float usage;
+
+ status = pdraw->queryFrameTracking( dpy, pdraw->private, sbc,
+ missedFrames, lastMissedUsage,
+ & usage );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) sbc;
+ (void) missedFrames;
+ (void) lastMissedUsage;
+#endif
+ return status;
+}
+
+
+/*
+** GLX_SGI_video_sync
+*/
+int GLX_PREFIX(glXGetVideoSyncSGI)(unsigned int *count)
+{
+ /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry,
+ * FIXME: there should be a GLX encoding for this call. I can find no
+ * FIXME: documentation for the GLX encoding.
+ */
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+ if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit )
+ && psc->driScreen.private && psc->driScreen.getMSC) {
+ int ret;
+ int64_t temp;
+
+ ret = psc->driScreen.getMSC( psc->driScreen.private, & temp );
+ *count = (unsigned) temp;
+ return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+ }
+ }
+#else
+ (void) count;
+#endif
+ return GLX_BAD_CONTEXT;
+}
+
+int GLX_PREFIX(glXWaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count)
+{
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+ if ( divisor <= 0 || remainder < 0 )
+ return GLX_BAD_VALUE;
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+ if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit )
+ && psc->driScreen.private ) {
+ __DRIdrawable * const pdraw =
+ (*psc->driScreen.getDrawable)(gc->currentDpy,
+ gc->currentDrawable,
+ psc->driScreen.private);
+ if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) ) {
+ int ret;
+ int64_t msc;
+ int64_t sbc;
+
+ ret = (*pdraw->waitForMSC)( gc->currentDpy, pdraw->private,
+ 0, divisor, remainder,
+ & msc, & sbc );
+ *count = (unsigned) msc;
+ return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+ }
+ }
+ }
+#else
+ (void) count;
+#endif
+ return GLX_BAD_CONTEXT;
+}
+
+
+/*
+** GLX_SGIS_video_source
+*/
+#if defined(_VL_H)
+
+GLXVideoSourceSGIX GLX_PREFIX(glXCreateGLXVideoSourceSGIX)(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
+{
+ (void) dpy;
+ (void) screen;
+ (void) server;
+ (void) path;
+ (void) nodeClass;
+ (void) drainNode;
+ return 0;
+}
+
+void GLX_PREFIX(glXDestroyGLXVideoSourceSGIX)(Display *dpy, GLXVideoSourceSGIX src)
+{
+ (void) dpy;
+ (void) src;
+}
+
+#endif
+
+
+/*
+** GLX_SGIX_fbconfig
+** Many of these functions are aliased to GLX 1.3 entry points in the
+** GLX_functions table.
+*/
+
+GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
+ (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value),
+ (dpy, config, attribute, value),
+ glXGetFBConfigAttrib)
+
+GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
+ (Display *dpy, int screen, int *attrib_list, int *nelements),
+ (dpy, screen, attrib_list, nelements),
+ glXChooseFBConfig)
+
+GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
+ (Display * dpy, GLXFBConfigSGIX config),
+ (dpy, config),
+ glXGetVisualFromFBConfig)
+
+GLXPixmap GLX_PREFIX(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
+{
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req;
+ GLXPixmap xid = None;
+ CARD8 opcode;
+ const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;
+ __GLXscreenConfigs * psc;
+
+
+ if ( (dpy == NULL) || (config == NULL) ) {
+ return None;
+ }
+
+ psc = GetGLXScreenConfigs( dpy, fbconfig->screen );
+ if ( (psc != NULL)
+ && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return None;
+ }
+
+ /* Send the glXCreateGLXPixmapWithConfigSGIX request */
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
+ req->screen = fbconfig->screen;
+ req->fbconfig = fbconfig->fbconfigID;
+ req->pixmap = pixmap;
+ req->glxpixmap = xid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return xid;
+}
+
+GLXContext GLX_PREFIX(glXCreateContextWithConfigSGIX)(Display *dpy, GLXFBConfigSGIX config, int renderType, GLXContext shareList, Bool allowDirect)
+{
+ GLXContext gc = NULL;
+ const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;
+ __GLXscreenConfigs * psc;
+
+
+ if ( (dpy == NULL) || (config == NULL) ) {
+ return None;
+ }
+
+ psc = GetGLXScreenConfigs( dpy, fbconfig->screen );
+ if ( (psc != NULL)
+ && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {
+ gc = CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,
+ allowDirect, None, False, renderType );
+ }
+
+ return gc;
+}
+
+
+GLXFBConfigSGIX GLX_PREFIX(glXGetFBConfigFromVisualSGIX)(Display *dpy, XVisualInfo *vis)
+{
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *psc;
+
+ if ( (GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ) != Success)
+ && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit )
+ && (psc->configs->fbconfigID != GLX_DONT_CARE) ) {
+ return (GLXFBConfigSGIX) _gl_context_modes_find_visual( psc->configs,
+ vis->visualid );
+ }
+
+ return NULL;
+}
+
+
+/*
+** GLX_SGI_cushion
+*/
+void GLX_PREFIX(glXCushionSGI)(Display *dpy, Window win, float cushion)
+{
+ (void) dpy;
+ (void) win;
+ (void) cushion;
+}
+
+
+/*
+** GLX_SGIX_video_resize
+*/
+int GLX_PREFIX(glXBindChannelToWindowSGIX)(Display *dpy, int screen, int channel , Window window)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) window;
+ return 0;
+}
+
+int GLX_PREFIX(glXChannelRectSGIX)(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+int GLX_PREFIX(glXQueryChannelRectSGIX)(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+int GLX_PREFIX(glXQueryChannelDeltasSGIX)(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) dx;
+ (void) dy;
+ (void) dw;
+ (void) dh;
+ return 0;
+}
+
+int GLX_PREFIX(glXChannelRectSyncSGIX)(Display *dpy, int screen, int channel, GLenum synctype)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) synctype;
+ return 0;
+}
+
+
+#if defined(_DM_BUFFER_H_)
+
+Bool GLX_PREFIX(glXAssociateDMPbufferSGIX)(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+{
+ (void) dpy;
+ (void) pbuffer;
+ (void) params;
+ (void) dmbuffer;
+ return False;
+}
+
+#endif
+
+
+/*
+** GLX_SGIX_swap_group
+*/
+void GLX_PREFIX(glXJoinSwapGroupSGIX)(Display *dpy, GLXDrawable drawable, GLXDrawable member)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) member;
+}
+
+
+/*
+** GLX_SGIX_swap_barrier
+*/
+void GLX_PREFIX(glXBindSwapBarrierSGIX)(Display *dpy, GLXDrawable drawable, int barrier)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) barrier;
+}
+
+Bool GLX_PREFIX(glXQueryMaxSwapBarriersSGIX)(Display *dpy, int screen, int *max)
+{
+ (void) dpy;
+ (void) screen;
+ (void) max;
+ return False;
+}
+
+
+/*
+** GLX_SUN_get_transparent_index
+*/
+Status GLX_PREFIX(glXGetTransparentIndexSUN)(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+{
+ (void) dpy;
+ (void) overlay;
+ (void) underlay;
+ (void) pTransparent;
+ return 0;
+}
+
+
+/*
+** GLX_OML_sync_control
+*/
+Bool GLX_PREFIX(glXGetSyncValuesOML)(Display *dpy, GLXDrawable drawable,
+ int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+ if ( priv != NULL ) {
+ int i;
+ __DRIdrawable * const pdraw = GetDRIDrawable( dpy, drawable, & i );
+ __GLXscreenConfigs * const psc = &priv->screenConfigs[i];
+
+ assert( (pdraw == NULL) || (i != -1) );
+ return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )
+ && ((*psc->driScreen.getMSC)( psc->driScreen.private, msc ) == 0)
+ && ((*pdraw->getSBC)( dpy, psc->driScreen.private, sbc ) == 0)
+ && (__glXGetUST( ust ) == 0) );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) ust;
+ (void) msc;
+ (void) sbc;
+#endif
+ return False;
+}
+
+
+/**
+ * Determine the refresh rate of the specified drawable and display.
+ *
+ * \param dpy Display whose refresh rate is to be determined.
+ * \param drawable Drawable whose refresh rate is to be determined.
+ * \param numerator Numerator of the refresh rate.
+ * \param demoninator Denominator of the refresh rate.
+ * \return If the refresh rate for the specified display and drawable could
+ * be calculated, True is returned. Otherwise False is returned.
+ *
+ * \note This function is implemented entirely client-side. A lot of other
+ * functionality is required to export GLX_OML_sync_control, so on
+ * XFree86 this function can be called for direct-rendering contexts
+ * when GLX_OML_sync_control appears in the client extension string.
+ */
+
+Bool GLX_PREFIX(glXGetMscRateOML)(Display * dpy, GLXDrawable drawable,
+ int32_t * numerator, int32_t * denominator)
+{
+#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+
+ if ( priv != NULL ) {
+ XF86VidModeModeLine mode_line;
+ int dot_clock;
+ int screen_num;
+ int i;
+
+
+ GetDRIDrawable( dpy, drawable, & screen_num );
+ if ( (screen_num != -1)
+ && XF86VidModeQueryVersion( dpy, & i, & i )
+ && XF86VidModeGetModeLine( dpy, screen_num, & dot_clock,
+ & mode_line ) ) {
+ unsigned n = dot_clock * 1000;
+ unsigned d = mode_line.vtotal * mode_line.htotal;
+
+# define V_INTERLACE 0x010
+# define V_DBLSCAN 0x020
+
+ if ( (mode_line.flags & V_INTERLACE) ) {
+ n *= 2;
+ }
+ else if ( (mode_line.flags & V_DBLSCAN) ) {
+ d *= 2;
+ }
+
+ /* The OML_sync_control spec requires that if the refresh rate is a
+ * whole number, that the returned numerator be equal to the refresh
+ * rate and the denominator be 1.
+ */
+
+ if ( (n % d) == 0 ) {
+ n /= d;
+ d = 1;
+ }
+ else {
+ static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 };
+
+
+ /* This is a poor man's way to reduce a fraction. It's far from
+ * perfect, but it will work well enough for this situation.
+ */
+
+ for ( i = 0 ; f[i] != 0 ; i++ ) {
+ while ( ((n % f[i]) == 0) && ((d % f[i]) == 0) ) {
+ d /= f[i];
+ n /= f[i];
+ }
+ }
+ }
+
+ *numerator = n;
+ *denominator = d;
+
+ (void) drawable;
+ return True;
+ }
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) numerator;
+ (void) denominator;
+#endif
+ return False;
+}
+
+
+int64_t GLX_PREFIX(glXSwapBuffersMscOML)(Display *dpy, GLXDrawable drawable,
+ int64_t target_msc,
+ int64_t divisor, int64_t remainder)
+{
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+
+ /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
+ * error", but it also says "It [glXSwapBuffersMscOML] will return a value
+ * of -1 if the function failed because of errors detected in the input
+ * parameters"
+ */
+ if ( divisor < 0 || remainder < 0 || target_msc < 0 )
+ return -1;
+ if ( divisor > 0 && remainder >= divisor )
+ return -1;
+
+ if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {
+ return (*pdraw->swapBuffersMSC)(dpy, pdraw->private, target_msc,
+ divisor, remainder);
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) target_msc;
+ (void) divisor;
+ (void) remainder;
+#endif
+ return 0;
+}
+
+
+Bool GLX_PREFIX(glXWaitForMscOML)(Display * dpy, GLXDrawable drawable,
+ int64_t target_msc,
+ int64_t divisor, int64_t remainder,
+ int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+ int ret;
+
+ /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
+ * error", but the return type in the spec is Bool.
+ */
+ if ( divisor < 0 || remainder < 0 || target_msc < 0 )
+ return False;
+ if ( divisor > 0 && remainder >= divisor )
+ return False;
+
+ if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {
+ ret = (*pdraw->waitForMSC)( dpy, pdraw->private, target_msc,
+ divisor, remainder, msc, sbc );
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return ( (ret == 0) && (__glXGetUST( ust ) == 0) );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) target_msc;
+ (void) divisor;
+ (void) remainder;
+ (void) ust;
+ (void) msc;
+ (void) sbc;
+#endif
+ return False;
+}
+
+
+Bool GLX_PREFIX(glXWaitForSbcOML)(Display * dpy, GLXDrawable drawable,
+ int64_t target_sbc,
+ int64_t *ust, int64_t *msc, int64_t *sbc )
+{
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+ int ret;
+
+ /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE
+ * error", but the return type in the spec is Bool.
+ */
+ if ( target_sbc < 0 )
+ return False;
+
+ if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) {
+ ret = (*pdraw->waitForSBC)( dpy, pdraw->private, target_sbc, msc, sbc );
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return( (ret == 0) && (__glXGetUST( ust ) == 0) );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) target_sbc;
+ (void) ust;
+ (void) msc;
+ (void) sbc;
+#endif
+ return False;
+}
+
+
+/**
+ * GLX_MESA_allocate_memory
+ */
+/*@{*/
+
+void *GLX_PREFIX(glXAllocateMemoryMESA)(Display *dpy, int scrn,
+ size_t size,
+ float readFreq,
+ float writeFreq,
+ float priority)
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+
+ if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {
+ if (psc && psc->driScreen.private && psc->driScreen.allocateMemory) {
+ return (*psc->driScreen.allocateMemory)( dpy, scrn, size,
+ readFreq, writeFreq,
+ priority );
+ }
+ }
+#else
+ (void) dpy;
+ (void) scrn;
+ (void) size;
+ (void) readFreq;
+ (void) writeFreq;
+ (void) priority;
+#endif /* GLX_DIRECT_RENDERING */
+
+ return NULL;
+}
+
+
+void GLX_PREFIX(glXFreeMemoryMESA)(Display *dpy, int scrn, void *pointer)
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+
+ if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {
+ if (psc && psc->driScreen.private && psc->driScreen.freeMemory) {
+ (*psc->driScreen.freeMemory)( dpy, scrn, pointer );
+ }
+ }
+#else
+ (void) dpy;
+ (void) scrn;
+ (void) pointer;
+#endif /* GLX_DIRECT_RENDERING */
+}
+
+
+GLuint GLX_PREFIX(glXGetMemoryOffsetMESA)( Display *dpy, int scrn,
+ const void *pointer )
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+
+ if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {
+ if (psc && psc->driScreen.private && psc->driScreen.memoryOffset) {
+ return (*psc->driScreen.memoryOffset)( dpy, scrn, pointer );
+ }
+ }
+#else
+ (void) dpy;
+ (void) scrn;
+ (void) pointer;
+#endif /* GLX_DIRECT_RENDERING */
+
+ return ~0L;
+}
+/*@}*/
+
+
+/**
+ * Mesa extension stubs. These will help reduce portability problems.
+ */
+/*@{*/
+
+/**
+ * Release all buffers associated with the specified GLX drawable.
+ *
+ * \todo
+ * This function was intended for stand-alone Mesa. The issue there is that
+ * the library doesn't get any notification when a window is closed. In
+ * DRI there is a similar but slightly different issue. When GLX 1.3 is
+ * supported, there are 3 different functions to destroy a drawable. It
+ * should be possible to create GLX protocol (or have it determine which
+ * protocol to use based on the type of the drawable) to have one function
+ * do the work of 3. For the direct-rendering case, this function could
+ * just call the driver's \c __DRIdrawableRec::destroyDrawable function.
+ * This would reduce the frequency with which \c __driGarbageCollectDrawables
+ * would need to be used. This really should be done as part of the new DRI
+ * interface work.
+ *
+ * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt
+ * __driGarbageCollectDrawables
+ * glXDestroyGLXPixmap
+ * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow
+ * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX
+ */
+Bool GLX_PREFIX(glXReleaseBuffersMESA)( Display *dpy, GLXDrawable d )
+{
+ (void) dpy;
+ (void) d;
+ return False;
+}
+
+
+GLXPixmap GLX_PREFIX(glXCreateGLXPixmapMESA)( Display *dpy,
+ XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap )
+{
+ (void) dpy;
+ (void) visual;
+ (void) pixmap;
+ (void) cmap;
+ return 0;
+}
+
+
+void GLX_PREFIX(glXCopySubBufferMESA)( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height )
+{
+ (void) dpy;
+ (void) drawable;
+ (void) x;
+ (void) y;
+ (void) width;
+ (void) height;
+}
+
+
+Bool GLX_PREFIX(glXSet3DfxModeMESA)( int mode )
+{
+ (void) mode;
+ return GL_FALSE;
+}
+/*@}*/
+
+
+
+/**
+ * \c strdup is actually not a standard ANSI C or POSIX routine.
+ * Irix will not define it if ANSI mode is in effect.
+ *
+ * \sa strdup
+ */
+char *
+__glXstrdup(const char *str)
+{
+ char *copy;
+ copy = (char *) Xmalloc(strlen(str) + 1);
+ if (!copy)
+ return NULL;
+ strcpy(copy, str);
+ return copy;
+}
+
+/*
+** glXGetProcAddress support
+*/
+
+struct name_address_pair {
+ const char *Name;
+ GLvoid *Address;
+};
+
+#define GLX_FUNCTION(f) { # f, (GLvoid *) f }
+#define GLX_FUNCTION2(n,f) { # n, (GLvoid *) f }
+
+static const struct name_address_pair GLX_functions[] = {
+ /*** GLX_VERSION_1_0 ***/
+ GLX_FUNCTION( glXChooseVisual ),
+ GLX_FUNCTION( glXCopyContext ),
+ GLX_FUNCTION( glXCreateContext ),
+ GLX_FUNCTION( glXCreateGLXPixmap ),
+ GLX_FUNCTION( glXDestroyContext ),
+ GLX_FUNCTION( glXDestroyGLXPixmap ),
+ GLX_FUNCTION( glXGetConfig ),
+ GLX_FUNCTION( glXGetCurrentContext ),
+ GLX_FUNCTION( glXGetCurrentDrawable ),
+ GLX_FUNCTION( glXIsDirect ),
+ GLX_FUNCTION( glXMakeCurrent ),
+ GLX_FUNCTION( glXQueryExtension ),
+ GLX_FUNCTION( glXQueryVersion ),
+ GLX_FUNCTION( glXSwapBuffers ),
+ GLX_FUNCTION( glXUseXFont ),
+ GLX_FUNCTION( glXWaitGL ),
+ GLX_FUNCTION( glXWaitX ),
+
+ /*** GLX_VERSION_1_1 ***/
+ GLX_FUNCTION( glXGetClientString ),
+ GLX_FUNCTION( glXQueryExtensionsString ),
+ GLX_FUNCTION( glXQueryServerString ),
+
+ /*** GLX_VERSION_1_2 ***/
+ GLX_FUNCTION( glXGetCurrentDisplay ),
+
+ /*** GLX_VERSION_1_3 ***/
+ GLX_FUNCTION( glXChooseFBConfig ),
+ GLX_FUNCTION( glXCreateNewContext ),
+ GLX_FUNCTION( glXCreatePbuffer ),
+ GLX_FUNCTION( glXCreatePixmap ),
+ GLX_FUNCTION( glXCreateWindow ),
+ GLX_FUNCTION( glXDestroyPbuffer ),
+ GLX_FUNCTION( glXDestroyPixmap ),
+ GLX_FUNCTION( glXDestroyWindow ),
+ GLX_FUNCTION( glXGetCurrentReadDrawable ),
+ GLX_FUNCTION( glXGetFBConfigAttrib ),
+ GLX_FUNCTION( glXGetFBConfigs ),
+ GLX_FUNCTION( glXGetSelectedEvent ),
+ GLX_FUNCTION( glXGetVisualFromFBConfig ),
+ GLX_FUNCTION( glXMakeContextCurrent ),
+ GLX_FUNCTION( glXQueryContext ),
+ GLX_FUNCTION( glXQueryDrawable ),
+ GLX_FUNCTION( glXSelectEvent ),
+
+ /*** GLX_SGI_swap_control ***/
+ GLX_FUNCTION( glXSwapIntervalSGI ),
+
+ /*** GLX_SGI_video_sync ***/
+ GLX_FUNCTION( glXGetVideoSyncSGI ),
+ GLX_FUNCTION( glXWaitVideoSyncSGI ),
+
+ /*** GLX_SGI_make_current_read ***/
+ GLX_FUNCTION2( glXMakeCurrentReadSGI, glXMakeContextCurrent ),
+ GLX_FUNCTION2( glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable ),
+
+ /*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ GLX_FUNCTION( glXCreateGLXVideoSourceSGIX ),
+ GLX_FUNCTION( glXDestroyGLXVideoSourceSGIX ),
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ GLX_FUNCTION( glXFreeContextEXT ),
+ GLX_FUNCTION( glXGetContextIDEXT ),
+ GLX_FUNCTION2( glXGetCurrentDisplayEXT, glXGetCurrentDisplay ),
+ GLX_FUNCTION( glXImportContextEXT ),
+ GLX_FUNCTION2( glXQueryContextInfoEXT, glXQueryContext ),
+
+ /*** GLX_SGIX_fbconfig ***/
+ GLX_FUNCTION2( glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib ),
+ GLX_FUNCTION2( glXChooseFBConfigSGIX, glXChooseFBConfig ),
+ GLX_FUNCTION( glXCreateGLXPixmapWithConfigSGIX ),
+ GLX_FUNCTION( glXCreateContextWithConfigSGIX ),
+ GLX_FUNCTION2( glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig ),
+ GLX_FUNCTION( glXGetFBConfigFromVisualSGIX ),
+
+ /*** GLX_SGIX_pbuffer ***/
+ GLX_FUNCTION( glXCreateGLXPbufferSGIX ),
+ GLX_FUNCTION( glXDestroyGLXPbufferSGIX ),
+ GLX_FUNCTION( glXQueryGLXPbufferSGIX ),
+ GLX_FUNCTION( glXSelectEventSGIX ),
+ GLX_FUNCTION( glXGetSelectedEventSGIX ),
+
+ /*** GLX_SGI_cushion ***/
+ GLX_FUNCTION( glXCushionSGI ),
+
+ /*** GLX_SGIX_video_resize ***/
+ GLX_FUNCTION( glXBindChannelToWindowSGIX ),
+ GLX_FUNCTION( glXChannelRectSGIX ),
+ GLX_FUNCTION( glXQueryChannelRectSGIX ),
+ GLX_FUNCTION( glXQueryChannelDeltasSGIX ),
+ GLX_FUNCTION( glXChannelRectSyncSGIX ),
+
+ /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+ GLX_FUNCTION( glXAssociateDMPbufferSGIX ),
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ GLX_FUNCTION( glXJoinSwapGroupSGIX ),
+
+ /*** GLX_SGIX_swap_barrier ***/
+ GLX_FUNCTION( glXBindSwapBarrierSGIX ),
+ GLX_FUNCTION( glXQueryMaxSwapBarriersSGIX ),
+
+ /*** GLX_SUN_get_transparent_index ***/
+ GLX_FUNCTION( glXGetTransparentIndexSUN ),
+
+ /*** GLX_MESA_allocate_memory ***/
+ GLX_FUNCTION( glXAllocateMemoryMESA ),
+ GLX_FUNCTION( glXFreeMemoryMESA ),
+ GLX_FUNCTION( glXGetMemoryOffsetMESA ),
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ GLX_FUNCTION( glXCopySubBufferMESA ),
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ GLX_FUNCTION( glXCreateGLXPixmapMESA ),
+
+ /*** GLX_MESA_release_buffers ***/
+ GLX_FUNCTION( glXReleaseBuffersMESA ),
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ GLX_FUNCTION( glXSet3DfxModeMESA ),
+
+ /*** GLX_MESA_swap_control ***/
+ GLX_FUNCTION( glXSwapIntervalMESA ),
+ GLX_FUNCTION( glXGetSwapIntervalMESA ),
+
+ /*** GLX_MESA_swap_frame_usage ***/
+ GLX_FUNCTION( glXBeginFrameTrackingMESA ),
+ GLX_FUNCTION( glXEndFrameTrackingMESA ),
+ GLX_FUNCTION( glXGetFrameUsageMESA ),
+ GLX_FUNCTION( glXQueryFrameTrackingMESA ),
+
+ /*** GLX_ARB_get_proc_address ***/
+ GLX_FUNCTION( glXGetProcAddressARB ),
+
+ /*** GLX 1.4 ***/
+ GLX_FUNCTION2( glXGetProcAddress, glXGetProcAddressARB ),
+
+ /*** GLX_OML_sync_control ***/
+ GLX_FUNCTION( glXWaitForSbcOML ),
+ GLX_FUNCTION( glXWaitForMscOML ),
+ GLX_FUNCTION( glXSwapBuffersMscOML ),
+ GLX_FUNCTION( glXGetMscRateOML ),
+ GLX_FUNCTION( glXGetSyncValuesOML ),
+
+#ifdef GLX_DIRECT_RENDERING
+ /***
+ *** Internal functions useful to DRI drivers
+ *** With this, the DRI drivers shouldn't need dlopen()/dlsym() to
+ *** access internal libGL functions which may or may not exist.
+ ***/
+ GLX_FUNCTION( __glXInitialize ),
+ GLX_FUNCTION( __glXFindDRIScreen ),
+ GLX_FUNCTION( __glXGetInternalVersion ),
+ GLX_FUNCTION( __glXWindowExists ),
+ GLX_FUNCTION2( __glXCreateContextWithConfig, XF86DRICreateContextWithConfig ),
+ GLX_FUNCTION2( __glXGetDrawableInfo, XF86DRIGetDrawableInfo ),
+
+ /*** DRI configuration ***/
+ GLX_FUNCTION( glXGetScreenDriver ),
+ GLX_FUNCTION( glXGetDriverConfig ),
+
+ GLX_FUNCTION( __glXScrEnableExtension ),
+
+ GLX_FUNCTION( __glXGetUST ),
+
+ GLX_FUNCTION2( __glXCreateContextModes, _gl_context_modes_create ),
+ GLX_FUNCTION2( __glXDestroyContextModes, _gl_context_modes_destroy ),
+#endif
+
+ { NULL, NULL } /* end of list */
+};
+
+
+static const GLvoid *
+get_glx_proc_address(const char *funcName)
+{
+ GLuint i;
+
+ /* try static functions */
+ for (i = 0; GLX_functions[i].Name; i++) {
+ if (strcmp(GLX_functions[i].Name, funcName) == 0)
+ return GLX_functions[i].Address;
+ }
+
+ return NULL;
+}
+
+
+#ifndef GLX_BUILT_IN_XMESA
+/**
+ * Get the address of a named GL function. This is the pre-GLX 1.4 name for
+ * \c glXGetProcAddress.
+ *
+ * \param procName Name of a GL or GLX function.
+ * \returns A pointer to the named function
+ *
+ * \sa glXGetProcAddress
+ */
+void (*glXGetProcAddressARB(const GLubyte *procName))( void )
+{
+ typedef void (*gl_function)( void );
+ gl_function f;
+
+
+ /* Search the table of GLX and internal functions first. If that
+ * fails and the supplied name could be a valid core GL name, try
+ * searching the core GL function table. This check is done to prevent
+ * DRI based drivers from searching the core GL function table for
+ * internal API functions.
+ */
+
+ f = (gl_function) get_glx_proc_address((const char *) procName);
+ if ( (f == NULL) && (procName[0] == 'g') && (procName[1] == 'l')
+ && (procName[2] != 'X') ) {
+ f = (gl_function) _glapi_get_proc_address((const char *) procName);
+ }
+
+ return f;
+}
+
+/**
+ * Get the address of a named GL function. This is the GLX 1.4 name for
+ * \c glXGetProcAddressARB.
+ *
+ * \param procName Name of a GL or GLX function.
+ * \returns A pointer to the named function
+ *
+ * \sa glXGetProcAddressARB
+ */
+void (*glXGetProcAddress(const GLubyte *procName))( void )
+#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
+ __attribute__ ((alias ("glXGetProcAddressARB")));
+#else
+{
+ return glXGetProcAddressARB(procName);
+}
+#endif /* __GNUC__ */
+#endif /* GLX_BUILT_IN_XMESA */
+
+
+#ifdef GLX_DIRECT_RENDERING
+/**
+ * Retrieves the verion of the internal libGL API in YYYYMMDD format. This
+ * might be used by the DRI drivers to determine how new libGL is at runtime.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \returns An 8-digit decimal number representing the internal libGL API in
+ * YYYYMMDD format.
+ *
+ * \sa glXGetProcAddress, PFNGLXGETINTERNALVERSIONPROC
+ *
+ * \since Internal API version 20021121.
+ */
+int __glXGetInternalVersion(void)
+{
+ /* History:
+ * 20021121 - Initial version
+ * 20021128 - Added __glXWindowExists() function
+ * 20021207 - Added support for dynamic GLX extensions,
+ * GLX_SGI_swap_control, GLX_SGI_video_sync,
+ * GLX_OML_sync_control, and GLX_MESA_swap_control.
+ * Never officially released. Do NOT test against
+ * this version. Use 20030317 instead.
+ * 20030317 - Added support GLX_SGIX_fbconfig,
+ * GLX_MESA_swap_frame_usage, GLX_OML_swap_method,
+ * GLX_{ARB,SGIS}_multisample, and
+ * GLX_SGIX_visual_select_group.
+ * 20030606 - Added support for GLX_SGI_make_current_read.
+ * 20030813 - Made support for dynamic extensions multi-head aware.
+ * 20030818 - Added support for GLX_MESA_allocate_memory in place of the
+ * deprecated GLX_NV_vertex_array_range & GLX_MESA_agp_offset
+ * interfaces.
+ * 20031201 - Added support for the first round of DRI interface changes.
+ * Do NOT test against this version! It has binary
+ * compatibility bugs, use 20040317 instead.
+ * 20040317 - Added the 'mode' field to __DRIcontextRec.
+ * 20040415 - Added support for bindContext3 and unbindContext3.
+ * 20040602 - Add __glXGetDrawableInfo. I though that was there
+ * months ago. :(
+ */
+ return 20040602;
+}
+
+
+
+static Bool windowExistsFlag;
+
+static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+ if (xerr->error_code == BadWindow) {
+ windowExistsFlag = GL_FALSE;
+ }
+ return 0;
+}
+
+/**
+ * Determine if a window associated with a \c GLXDrawable exists on the
+ * X-server. This function is not used internally by libGL. It is provided
+ * as a utility function for DRI drivers.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param dpy Display associated with the drawable to be queried.
+ * \param draw \c GLXDrawable to test.
+ *
+ * \returns \c GL_TRUE if a window exists that is associated with \c draw,
+ * otherwise \c GL_FALSE is returned.
+ *
+ * \warning This function is not currently thread-safe.
+ *
+ * \sa glXGetProcAddress
+ *
+ * \since Internal API version 20021128.
+ */
+static Bool __glXWindowExists(Display *dpy, GLXDrawable draw)
+{
+ XWindowAttributes xwa;
+ int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+ XSync(dpy, GL_FALSE);
+ windowExistsFlag = GL_TRUE;
+ oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
+ XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+ XSetErrorHandler(oldXErrorHandler);
+ return windowExistsFlag;
+}
+
+
+/**
+ * Get the unadjusted system time (UST). Currently, the UST is measured in
+ * microseconds since Epoc. The actual resolution of the UST may vary from
+ * system to system, and the units may vary from release to release.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param ust Location to store the 64-bit UST
+ * \returns Zero on success or a negative errno value on failure.
+ *
+ * \sa glXGetProcAddress, PFNGLXGETUSTPROC
+ *
+ * \since Internal API version 20030317.
+ */
+int __glXGetUST( int64_t * ust )
+{
+ struct timeval tv;
+
+ if ( ust == NULL ) {
+ return -EFAULT;
+ }
+
+ if ( gettimeofday( & tv, NULL ) == 0 ) {
+ ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+ return 0;
+ } else {
+ return -errno;
+ }
+}
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
new file mode 100644
index 0000000000..5a11c91589
--- /dev/null
+++ b/src/glx/x11/glxext.c
@@ -0,0 +1,1872 @@
+/* $XFree86: xc/lib/GL/glx/glxext.c,v 1.22 2003/12/08 17:35:28 dawes Exp $ */
+
+/*
+** 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.1 (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-2000 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.
+**
+*/
+
+/**
+ * \file glxext.c
+ * GLX protocol interface boot-strap code.
+ *
+ * Direct rendering support added by Precision Insight, Inc.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ */
+
+#include "packrender.h"
+#include <stdio.h>
+#include <Xext.h>
+#include <extutil.h>
+#include <assert.h>
+#include "indirect_init.h"
+#include "glapi.h"
+#ifdef XTHREADS
+#include "Xthreads.h"
+#endif
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+
+#ifdef GLX_DIRECT_RENDERING
+#include <inttypes.h>
+#include <sys/mman.h>
+#include "xf86dri.h"
+#include "sarea.h"
+#include "dri_glx.h"
+#endif
+
+#include <assert.h>
+
+#ifdef DEBUG
+void __glXDumpDrawBuffer(__GLXcontext *ctx);
+#endif
+
+#ifdef USE_SPARC_ASM
+/*
+ * This is where our dispatch table's bounds are.
+ * And the static mesa_init is taken directly from
+ * Mesa's 'sparc.c' initializer.
+ *
+ * We need something like this here, because this version
+ * of openGL/glx never initializes a Mesa context, and so
+ * the address of the dispatch table pointer never gets stuffed
+ * into the dispatch jump table otherwise.
+ *
+ * It matters only on SPARC, and only if you are using assembler
+ * code instead of C-code indirect dispatch.
+ *
+ * -- FEM, 04.xii.03
+ */
+extern unsigned int _mesa_sparc_glapi_begin;
+extern unsigned int _mesa_sparc_glapi_end;
+extern void __glapi_sparc_icache_flush(unsigned int *);
+static void _glx_mesa_init_sparc_glapi_relocs(void);
+static int _mesa_sparc_needs_init = 1;
+#define INIT_MESA_SPARC { \
+ if(_mesa_sparc_needs_init) { \
+ _glx_mesa_init_sparc_glapi_relocs(); \
+ _mesa_sparc_needs_init = 0; \
+ } \
+}
+#else
+#define INIT_MESA_SPARC
+#endif
+
+static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext gc);
+
+/*
+** We setup some dummy structures here so that the API can be used
+** even if no context is current.
+*/
+
+static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
+
+/*
+** Dummy context used by small commands when there is no current context.
+** All the
+** gl and glx entry points are designed to operate as nop's when using
+** the dummy context structure.
+*/
+static __GLXcontext dummyContext = {
+ &dummyBuffer[0],
+ &dummyBuffer[0],
+ &dummyBuffer[0],
+ &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
+ sizeof(dummyBuffer),
+};
+
+
+/*
+** All indirect rendering contexts will share the same indirect dispatch table.
+*/
+static __GLapi *IndirectAPI = NULL;
+
+
+/*
+ * Current context management and locking
+ */
+
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+
+/* thread safe */
+static GLboolean TSDinitialized = GL_FALSE;
+static xthread_key_t ContextTSD;
+
+__GLXcontext *__glXGetCurrentContext(void)
+{
+ if (!TSDinitialized) {
+ xthread_key_create(&ContextTSD, NULL);
+ TSDinitialized = GL_TRUE;
+ return &dummyContext;
+ }
+ else {
+ void *p;
+ xthread_get_specific(ContextTSD, &p);
+ if (!p)
+ return &dummyContext;
+ else
+ return (__GLXcontext *) p;
+ }
+}
+
+void __glXSetCurrentContext(__GLXcontext *c)
+{
+ if (!TSDinitialized) {
+ xthread_key_create(&ContextTSD, NULL);
+ TSDinitialized = GL_TRUE;
+ }
+ xthread_set_specific(ContextTSD, c);
+}
+
+
+/* Used by the __glXLock() and __glXUnlock() macros */
+xmutex_rec __glXmutex;
+
+#else
+
+/* not thread safe */
+__GLXcontext *__glXcurrentContext = &dummyContext;
+
+#endif
+
+
+/*
+** You can set this cell to 1 to force the gl drawing stuff to be
+** one command per packet
+*/
+int __glXDebug = 0;
+
+/*
+** forward prototype declarations
+*/
+int __glXCloseDisplay(Display *dpy, XExtCodes *codes);
+
+static GLboolean FillInVisuals( __GLXscreenConfigs * psc );
+
+/************************************************************************/
+
+/* Extension required boiler plate */
+
+static char *__glXExtensionName = GLX_EXTENSION_NAME;
+XExtensionInfo *__glXExtensionInfo = NULL;
+
+static /* const */ char *error_list[] = {
+ "GLXBadContext",
+ "GLXBadContextState",
+ "GLXBadDrawable",
+ "GLXBadPixmap",
+ "GLXBadContextTag",
+ "GLXBadCurrentWindow",
+ "GLXBadRenderRequest",
+ "GLXBadLargeRequest",
+ "GLXUnsupportedPrivateRequest",
+};
+
+int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
+{
+ GLXContext gc;
+
+ gc = __glXGetCurrentContext();
+ if (dpy == gc->currentDpy) {
+ __glXSetCurrentContext(&dummyContext);
+#ifdef GLX_DIRECT_RENDERING
+ _glapi_set_dispatch(NULL); /* no-op functions */
+#endif
+ __glXFreeContext(gc);
+ }
+
+ return XextRemoveDisplay(__glXExtensionInfo, dpy);
+}
+
+
+static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
+ __GLX_NUMBER_ERRORS, error_list)
+
+static /* const */ XExtensionHooks __glXExtensionHooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ __glXCloseDisplay, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ __glXErrorString, /* error_string */
+};
+
+static
+XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
+ __glXExtensionName, &__glXExtensionHooks,
+ __GLX_NUMBER_EVENTS, NULL)
+
+/************************************************************************/
+
+/*
+** Free the per screen configs data as well as the array of
+** __glXScreenConfigs.
+*/
+static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
+{
+ __GLXscreenConfigs *psc;
+ GLint i, screens;
+
+ /* Free screen configuration information */
+ psc = priv->screenConfigs;
+ screens = ScreenCount(priv->dpy);
+ for (i = 0; i < screens; i++, psc++) {
+ if (psc->configs) {
+ _gl_context_modes_destroy( psc->configs );
+ if(psc->effectiveGLXexts)
+ Xfree(psc->effectiveGLXexts);
+
+ if ( psc->old_configs != NULL ) {
+ Xfree( psc->old_configs );
+ psc->old_configs = NULL;
+ psc->numOldConfigs = 0;
+ }
+
+ psc->configs = NULL; /* NOTE: just for paranoia */
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Free the direct rendering per screen data */
+ if (psc->driScreen.private)
+ (*psc->driScreen.destroyScreen)(priv->dpy, i,
+ psc->driScreen.private);
+ psc->driScreen.private = NULL;
+#endif
+ }
+ XFree((char*) priv->screenConfigs);
+}
+
+/*
+** Release the private memory referred to in a display private
+** structure. The caller will free the extension structure.
+*/
+static int __glXFreeDisplayPrivate(XExtData *extension)
+{
+ __GLXdisplayPrivate *priv;
+
+ priv = (__GLXdisplayPrivate*) extension->private_data;
+ FreeScreenConfigs(priv);
+ if(priv->serverGLXvendor) {
+ Xfree((char*)priv->serverGLXvendor);
+ priv->serverGLXvendor = 0x0; /* to protect against double free's */
+ }
+ if(priv->serverGLXversion) {
+ Xfree((char*)priv->serverGLXversion);
+ priv->serverGLXversion = 0x0; /* to protect against double free's */
+ }
+
+#if 0 /* GLX_DIRECT_RENDERING */
+ /* Free the direct rendering per display data */
+ if (priv->driDisplay.private)
+ (*priv->driDisplay.destroyDisplay)(priv->dpy,
+ priv->driDisplay.private);
+ priv->driDisplay.private = NULL;
+#endif
+
+#ifdef GLX_DIRECT_RENDERING
+ XFree(priv->driDisplay.createScreen);
+#endif
+
+ Xfree((char*) priv);
+ return 0;
+}
+
+/************************************************************************/
+
+/*
+** Query the version of the GLX extension. This procedure works even if
+** the client extension is not completely set up.
+*/
+static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor)
+{
+ xGLXQueryVersionReq *req;
+ xGLXQueryVersionReply reply;
+
+ /* Send the glXQueryVersion request */
+ LockDisplay(dpy);
+ GetReq(GLXQueryVersion,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXQueryVersion;
+ req->majorVersion = GLX_MAJOR_VERSION;
+ req->minorVersion = GLX_MINOR_VERSION;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (reply.majorVersion != GLX_MAJOR_VERSION) {
+ /*
+ ** The server does not support the same major release as this
+ ** client.
+ */
+ return GL_FALSE;
+ }
+ *major = reply.majorVersion;
+ *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
+ return GL_TRUE;
+}
+
+
+/**
+ * Determine if a \c __GLcontextModes structure has the right mojo to be
+ * converted to a \c __GLXvisualConfig to be sent to an "old" style DRI
+ * driver.
+ */
+#define MODE_HAS_MOJO(m) \
+ ((m)->visualID != GLX_DONT_CARE) \
+ && ((m)->sampleBuffers == 0) \
+ && ((m)->samples == 0) \
+ && (((m)->drawableType & GLX_WINDOW_BIT) != 0) \
+ && (((m)->xRenderable == GL_TRUE) \
+ || ((m)->xRenderable == GLX_DONT_CARE))
+
+
+/**
+ * Convert the FBConfigs associated with a screen into an array of
+ * \c __GLXvisualConfig structures. These structures are passed into DRI
+ * drivers that use the "old" interface. The old-style drivers had a fairly
+ * strict set of visual types that could be supported. FBConfigs that
+ * cannot be supported are not converted.
+ *
+ * \param psc Screen whose FBConfigs need to be swizzled.
+ *
+ * \returns
+ * If memory could be allocated and at least one FBConfig could be converted
+ * to a \c __GLXvisualConfig structure, \c GL_TRUE is returned. Otherwise,
+ * \c GL_FALSE is returned.
+ *
+ * \todo
+ * When the old DRI driver interface is no longer supported, this function
+ * can be removed.
+ */
+static GLboolean
+FillInVisuals( __GLXscreenConfigs * psc )
+{
+ __GLcontextModes *modes;
+ int glx_visual_count;
+
+
+ glx_visual_count = 0;
+ for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) {
+ if ( MODE_HAS_MOJO( modes ) ) {
+ glx_visual_count++;
+ }
+ }
+
+ psc->old_configs = (__GLXvisualConfig *)
+ Xmalloc( sizeof( __GLXvisualConfig ) * glx_visual_count );
+ if ( psc->old_configs == NULL ) {
+ return GL_FALSE;
+ }
+
+ glx_visual_count = 0;
+ for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) {
+ if ( MODE_HAS_MOJO( modes ) ) {
+
+#define COPY_VALUE(src_tag,dst_tag) \
+ psc->old_configs[glx_visual_count]. dst_tag = modes-> src_tag
+
+ COPY_VALUE( visualID, vid );
+ COPY_VALUE( rgbMode, rgba );
+ COPY_VALUE( stereoMode, stereo );
+ COPY_VALUE( doubleBufferMode, doubleBuffer );
+
+ psc->old_configs[glx_visual_count].class =
+ _gl_convert_to_x_visual_type( modes->visualType );
+
+ COPY_VALUE( level, level );
+ COPY_VALUE( numAuxBuffers, auxBuffers );
+
+ COPY_VALUE( redBits, redSize );
+ COPY_VALUE( greenBits, greenSize );
+ COPY_VALUE( blueBits, blueSize );
+ COPY_VALUE( alphaBits, alphaSize );
+ COPY_VALUE( rgbBits, bufferSize );
+ COPY_VALUE( accumRedBits, accumRedSize );
+ COPY_VALUE( accumGreenBits, accumGreenSize );
+ COPY_VALUE( accumBlueBits, accumBlueSize );
+ COPY_VALUE( accumAlphaBits, accumAlphaSize );
+ COPY_VALUE( depthBits, depthSize );
+ COPY_VALUE( stencilBits, stencilSize );
+
+ COPY_VALUE( visualRating, visualRating );
+ COPY_VALUE( transparentPixel, transparentPixel );
+ COPY_VALUE( transparentRed, transparentRed );
+ COPY_VALUE( transparentGreen, transparentGreen );
+ COPY_VALUE( transparentBlue, transparentBlue );
+ COPY_VALUE( transparentAlpha, transparentAlpha );
+ COPY_VALUE( transparentIndex, transparentIndex );
+
+#undef COPY_VALUE
+
+ glx_visual_count++;
+ }
+ }
+
+ psc->numOldConfigs = glx_visual_count;
+ if ( glx_visual_count == 0 ) {
+ Xfree( psc->old_configs );
+ psc->old_configs = NULL;
+ }
+
+ return (glx_visual_count != 0);
+}
+
+
+void
+__glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
+ const INT32 *bp, Bool tagged_only,
+ Bool fbconfig_style_tags )
+{
+ int i;
+
+ if (!tagged_only) {
+ /* Copy in the first set of properties */
+ config->visualID = *bp++;
+
+ config->visualType = _gl_convert_from_x_visual_type( *bp++ );
+
+ config->rgbMode = *bp++;
+
+ config->redBits = *bp++;
+ config->greenBits = *bp++;
+ config->blueBits = *bp++;
+ config->alphaBits = *bp++;
+ config->accumRedBits = *bp++;
+ config->accumGreenBits = *bp++;
+ config->accumBlueBits = *bp++;
+ config->accumAlphaBits = *bp++;
+
+ config->doubleBufferMode = *bp++;
+ config->stereoMode = *bp++;
+
+ config->rgbBits = *bp++;
+ config->depthBits = *bp++;
+ config->stencilBits = *bp++;
+ config->numAuxBuffers = *bp++;
+ config->level = *bp++;
+
+ count -= __GLX_MIN_CONFIG_PROPS;
+ }
+
+ /*
+ ** Additional properties may be in a list at the end
+ ** of the reply. They are in pairs of property type
+ ** and property value.
+ */
+
+#define FETCH_OR_SET(tag) \
+ config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1
+
+ for (i = 0; i < count; i += 2 ) {
+ switch(*bp++) {
+ case GLX_RGBA:
+ FETCH_OR_SET( rgbMode );
+ break;
+ case GLX_BUFFER_SIZE:
+ config->rgbBits = *bp++;
+ break;
+ case GLX_LEVEL:
+ config->level = *bp++;
+ break;
+ case GLX_DOUBLEBUFFER:
+ FETCH_OR_SET( doubleBufferMode );
+ break;
+ case GLX_STEREO:
+ FETCH_OR_SET( stereoMode );
+ break;
+ case GLX_AUX_BUFFERS:
+ config->numAuxBuffers = *bp++;
+ break;
+ case GLX_RED_SIZE:
+ config->redBits = *bp++;
+ break;
+ case GLX_GREEN_SIZE:
+ config->greenBits = *bp++;
+ break;
+ case GLX_BLUE_SIZE:
+ config->blueBits = *bp++;
+ break;
+ case GLX_ALPHA_SIZE:
+ config->alphaBits = *bp++;
+ break;
+ case GLX_DEPTH_SIZE:
+ config->depthBits = *bp++;
+ break;
+ case GLX_STENCIL_SIZE:
+ config->stencilBits = *bp++;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ config->accumRedBits = *bp++;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ config->accumGreenBits = *bp++;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ config->accumBlueBits = *bp++;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ config->accumAlphaBits = *bp++;
+ break;
+ case GLX_VISUAL_CAVEAT_EXT:
+ config->visualRating = *bp++;
+ break;
+ case GLX_X_VISUAL_TYPE:
+ config->visualType = *bp++;
+ break;
+ case GLX_TRANSPARENT_TYPE:
+ config->transparentPixel = *bp++;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ config->transparentIndex = *bp++;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE:
+ config->transparentRed = *bp++;
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ config->transparentGreen = *bp++;
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ config->transparentBlue = *bp++;
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ config->transparentAlpha = *bp++;
+ break;
+ case GLX_VISUAL_ID:
+ config->visualID = *bp++;
+ break;
+ case GLX_DRAWABLE_TYPE:
+ config->drawableType = *bp++;
+ break;
+ case GLX_RENDER_TYPE:
+ config->renderType = *bp++;
+ break;
+ case GLX_X_RENDERABLE:
+ config->xRenderable = *bp++;
+ break;
+ case GLX_FBCONFIG_ID:
+ config->fbconfigID = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ config->maxPbufferWidth = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ config->maxPbufferHeight = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ config->maxPbufferPixels = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ config->optimalPbufferWidth = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ config->optimalPbufferHeight = *bp++;
+ break;
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ config->visualSelectGroup = *bp++;
+ break;
+ case GLX_SWAP_METHOD_OML:
+ config->swapMethod = *bp++;
+ break;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ config->sampleBuffers = *bp++;
+ break;
+ case GLX_SAMPLES_SGIS:
+ config->samples = *bp++;
+ break;
+ case None:
+ i = count;
+ break;
+ default:
+ break;
+ }
+ }
+
+ config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ config->haveAccumBuffer = ((config->accumRedBits +
+ config->accumGreenBits +
+ config->accumBlueBits +
+ config->accumAlphaBits) > 0);
+ config->haveDepthBuffer = (config->depthBits > 0);
+ config->haveStencilBuffer = (config->stencilBits > 0);
+}
+
+
+#ifdef GLX_DIRECT_RENDERING
+static unsigned
+filter_modes( __GLcontextModes ** server_modes,
+ const __GLcontextModes * driver_modes )
+{
+ __GLcontextModes * m;
+ __GLcontextModes ** prev_next;
+ const __GLcontextModes * check;
+ unsigned modes_count = 0;
+
+ if ( driver_modes == NULL ) {
+ fprintf(stderr, "libGL warning: 3D driver returned no fbconfigs.\n");
+ return 0;
+ }
+
+ /* For each mode in server_modes, check to see if a matching mode exists
+ * in driver_modes. If not, then the mode is not available.
+ */
+
+ prev_next = server_modes;
+ for ( m = *prev_next ; m != NULL ; m = *prev_next ) {
+ GLboolean do_delete = GL_TRUE;
+
+ for ( check = driver_modes ; check != NULL ; check = check->next ) {
+ if ( _gl_context_modes_are_same( m, check ) ) {
+ do_delete = GL_FALSE;
+ break;
+ }
+ }
+
+ /* The 3D has to support all the modes that match the GLX visuals
+ * sent from the X server.
+ */
+ if ( do_delete && (m->visualID != 0) ) {
+ do_delete = GL_FALSE;
+
+ fprintf(stderr, "libGL warning: 3D driver claims to not support "
+ "visual 0x%02x\n", m->visualID);
+ }
+
+ if ( do_delete ) {
+ *prev_next = m->next;
+
+ m->next = NULL;
+ _gl_context_modes_destroy( m );
+ }
+ else {
+ modes_count++;
+ prev_next = & m->next;
+ }
+ }
+
+ return modes_count;
+}
+
+
+
+/**
+ * Perform the required libGL-side initialization and call the client-side
+ * driver's \c __driCreateNewScreen function.
+ *
+ * \param dpy Display pointer.
+ * \param scrn Screen number on the display.
+ * \param psc DRI screen information.
+ * \param driDpy DRI display information.
+ * \param createNewScreen Pointer to the client-side driver's
+ * \c __driCreateNewScreen function.
+ * \returns A pointer to the \c __DRIscreenPrivate structure returned by
+ * the client-side driver on success, or \c NULL on failure.
+ *
+ * \todo This function needs to be modified to remove context-modes from the
+ * list stored in the \c __GLXscreenConfigsRec to match the list
+ * returned by the client-side driver.
+ */
+static void *
+CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ __DRIdisplay * driDpy,
+ CreateNewScreenFunc createNewScreen)
+{
+ __DRIscreenPrivate *psp = NULL;
+#ifndef GLX_USE_APPLEGL
+ drm_handle_t hSAREA;
+ drmAddress pSAREA;
+ char *BusID;
+ __DRIversion ddx_version;
+ __DRIversion dri_version;
+ __DRIversion drm_version;
+ __DRIframebuffer framebuffer;
+ int fd = -1;
+ int status;
+ const char * err_msg;
+ const char * err_extra;
+ int api_ver = __glXGetInternalVersion();
+
+
+ dri_version.major = driDpy->private->driMajor;
+ dri_version.minor = driDpy->private->driMinor;
+ dri_version.patch = driDpy->private->driPatch;
+
+
+ err_msg = "XF86DRIOpenConnection";
+ err_extra = NULL;
+
+ framebuffer.dev_priv = NULL;
+
+ if (XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
+ fd = drmOpen(NULL,BusID);
+ Xfree(BusID); /* No longer needed */
+
+ err_msg = "open DRM";
+ err_extra = strerror( -fd );
+
+ if (fd >= 0) {
+ drm_magic_t magic;
+
+ err_msg = "drmGetMagic";
+ err_extra = NULL;
+
+ if (!drmGetMagic(fd, &magic)) {
+ drmVersionPtr version = drmGetVersion(fd);
+ if (version) {
+ drm_version.major = version->version_major;
+ drm_version.minor = version->version_minor;
+ drm_version.patch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
+ else {
+ drm_version.major = -1;
+ drm_version.minor = -1;
+ drm_version.patch = -1;
+ }
+
+ err_msg = "XF86DRIAuthConnection";
+ if (XF86DRIAuthConnection(dpy, scrn, magic)) {
+ char *driverName;
+
+ /*
+ * Get device name (like "tdfx") and the ddx version numbers.
+ * We'll check the version in each DRI driver's "createScreen"
+ * function.
+ */
+ err_msg = "XF86DRIGetClientDriverName";
+ if (XF86DRIGetClientDriverName(dpy, scrn,
+ &ddx_version.major,
+ &ddx_version.minor,
+ &ddx_version.patch,
+ &driverName)) {
+ drm_handle_t hFB;
+ int junk;
+
+ /* No longer needed. */
+ Xfree( driverName );
+
+
+ /*
+ * Get device-specific info. pDevPriv will point to a struct
+ * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h)
+ * that has information about the screen size, depth, pitch,
+ * ancilliary buffers, DRM mmap handles, etc.
+ */
+ err_msg = "XF86DRIGetDeviceInfo";
+ if (XF86DRIGetDeviceInfo(dpy, scrn,
+ &hFB,
+ &junk,
+ &framebuffer.size,
+ &framebuffer.stride,
+ &framebuffer.dev_priv_size,
+ &framebuffer.dev_priv)) {
+ framebuffer.width = DisplayWidth(dpy, scrn);
+ framebuffer.height = DisplayHeight(dpy, scrn);
+
+ /*
+ * Map the framebuffer region.
+ */
+ status = drmMap(fd, hFB, framebuffer.size,
+ (drmAddressPtr)&framebuffer.base);
+
+ err_msg = "drmMap of framebuffer";
+ err_extra = strerror( -status );
+
+ if ( status == 0 ) {
+ /*
+ * Map the SAREA region. Further mmap regions may be setup in
+ * each DRI driver's "createScreen" function.
+ */
+ status = drmMap(fd, hSAREA, SAREA_MAX,
+ &pSAREA);
+
+ err_msg = "drmMap of sarea";
+ err_extra = strerror( -status );
+
+ if ( status == 0 ) {
+ __GLcontextModes * driver_modes = NULL;
+ __GLXscreenConfigs *configs = psc->screenConfigs;
+
+ err_msg = "InitDriver";
+ err_extra = NULL;
+ psp = (*createNewScreen)(dpy, scrn,
+ psc,
+ configs->configs,
+ & ddx_version,
+ & dri_version,
+ & drm_version,
+ & framebuffer,
+ pSAREA,
+ fd,
+ api_ver,
+ & driver_modes );
+
+ filter_modes( & configs->configs,
+ driver_modes );
+ _gl_context_modes_destroy( driver_modes );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if ( psp == NULL ) {
+ if ( pSAREA != MAP_FAILED ) {
+ (void)drmUnmap(pSAREA, SAREA_MAX);
+ }
+
+ if ( framebuffer.base != MAP_FAILED ) {
+ (void)drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
+ }
+
+ if ( framebuffer.dev_priv != NULL ) {
+ Xfree(framebuffer.dev_priv);
+ }
+
+ if ( fd >= 0 ) {
+ (void)drmClose(fd);
+ }
+
+ (void)XF86DRICloseConnection(dpy, scrn);
+
+ if ( err_extra != NULL ) {
+ fprintf(stderr, "libGL error: %s failed (%s)\n", err_msg,
+ err_extra);
+ }
+ else {
+ fprintf(stderr, "libGL error: %s failed\n", err_msg );
+ }
+
+ fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
+ }
+#endif /* !GLX_USE_APPLEGL */
+
+ return psp;
+}
+#endif /* GLX_DIRECT_RENDERING */
+
+
+/*
+** Allocate the memory for the per screen configs for each screen.
+** If that works then fetch the per screen configs data.
+*/
+static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
+{
+ xGLXGetVisualConfigsReq *req;
+ xGLXGetFBConfigsReq *fb_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXGetFBConfigsSGIXReq *sgi_req;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenConfigs *psc;
+ __GLcontextModes *config;
+ GLint i, j, nprops, screens;
+ INT32 buf[__GLX_TOTAL_CONFIG], *props;
+ unsigned supported_request = 0;
+ unsigned prop_size;
+
+ /*
+ ** First allocate memory for the array of per screen configs.
+ */
+ screens = ScreenCount(dpy);
+ psc = (__GLXscreenConfigs*) Xmalloc(screens * sizeof(__GLXscreenConfigs));
+ if (!psc) {
+ return GL_FALSE;
+ }
+ memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
+ priv->screenConfigs = psc;
+
+ priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ 0, GLX_VERSION);
+ if ( priv->serverGLXversion == NULL ) {
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ if ( atof( priv->serverGLXversion ) >= 1.3 ) {
+ supported_request = 1;
+ }
+
+ /*
+ ** Now fetch each screens configs structures. If a screen supports
+ ** GL (by returning a numVisuals > 0) then allocate memory for our
+ ** config structure and then fill it in.
+ */
+ for (i = 0; i < screens; i++, psc++) {
+ if ( supported_request != 1 ) {
+ psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ i, GLX_EXTENSIONS);
+ if ( strstr( psc->serverGLXexts, "GLX_SGIX_fbconfig" ) != NULL ) {
+ supported_request = 2;
+ }
+ else {
+ supported_request = 3;
+ }
+ }
+
+
+ LockDisplay(dpy);
+ switch( supported_request ) {
+ case 1:
+ GetReq(GLXGetFBConfigs,fb_req);
+ fb_req->reqType = priv->majorOpcode;
+ fb_req->glxCode = X_GLXGetFBConfigs;
+ fb_req->screen = i;
+ break;
+
+ case 2:
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXGetFBConfigsSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+ sgi_req->reqType = priv->majorOpcode;
+ sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+ sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+ sgi_req->screen = i;
+ break;
+
+ case 3:
+ GetReq(GLXGetVisualConfigs,req);
+ req->reqType = priv->majorOpcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = i;
+ break;
+ }
+
+ if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
+ /* Something is busted. Punt. */
+ UnlockDisplay(dpy);
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ UnlockDisplay(dpy);
+ if (!reply.numVisuals) {
+ /* This screen does not support GL rendering */
+ UnlockDisplay(dpy);
+ continue;
+ }
+
+ /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for
+ * FIXME: FBconfigs?
+ */
+ /* Check number of properties */
+ nprops = reply.numProps;
+ if ((nprops < __GLX_MIN_CONFIG_PROPS) ||
+ (nprops > __GLX_MAX_CONFIG_PROPS)) {
+ /* Huh? Not in protocol defined limits. Punt */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ /* Allocate memory for our config structure */
+ psc->configs = _gl_context_modes_create(reply.numVisuals,
+ sizeof(__GLcontextModes));
+ if (!psc->configs) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ /* Allocate memory for the properties, if needed */
+ if ( supported_request != 3 ) {
+ nprops *= 2;
+ }
+
+ prop_size = nprops * __GLX_SIZE_INT32;
+
+ if (prop_size <= sizeof(buf)) {
+ props = buf;
+ } else {
+ props = (INT32 *) Xmalloc(prop_size);
+ }
+
+ /* Read each config structure and convert it into our format */
+ config = psc->configs;
+ for (j = 0; j < reply.numVisuals; j++) {
+ assert( config != NULL );
+ _XRead(dpy, (char *)props, prop_size);
+
+ if ( supported_request != 3 ) {
+ config->rgbMode = GL_TRUE;
+ config->drawableType = GLX_WINDOW_BIT;
+ }
+ else {
+ config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+ }
+
+ __glXInitializeVisualConfigFromTags( config, nprops, props,
+ (supported_request != 3),
+ GL_TRUE );
+ if ( config->fbconfigID == GLX_DONT_CARE ) {
+ config->fbconfigID = config->visualID;
+ }
+ config->screen = i;
+ config = config->next;
+ }
+ if (props != buf) {
+ Xfree((char *)props);
+ }
+ UnlockDisplay(dpy);
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Initialize per screen dynamic client GLX extensions */
+ psc->ext_list_first_time = GL_TRUE;
+ /* Initialize the direct rendering per screen data and functions */
+ if (priv->driDisplay.private != NULL) {
+ if (priv->driDisplay.createNewScreen &&
+ priv->driDisplay.createNewScreen[i]) {
+
+ psc->driScreen.screenConfigs = (void *)psc;
+ psc->driScreen.private =
+ CallCreateNewScreen(dpy, i, & psc->driScreen,
+ & priv->driDisplay,
+ priv->driDisplay.createNewScreen[i] );
+ }
+ else if (priv->driDisplay.createScreen &&
+ priv->driDisplay.createScreen[i]) {
+ /* screen initialization (bootstrap the driver) */
+ if ( (psc->old_configs == NULL)
+ && !FillInVisuals(psc) ) {
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ psc->driScreen.screenConfigs = (void *)psc;
+ psc->driScreen.private =
+ (*(priv->driDisplay.createScreen[i]))(dpy, i, &psc->driScreen,
+ psc->numOldConfigs,
+ psc->old_configs);
+ }
+ }
+#endif
+ }
+ SyncHandle();
+ return GL_TRUE;
+}
+
+/*
+** Initialize the client side extension code.
+*/
+__GLXdisplayPrivate *__glXInitialize(Display* dpy)
+{
+ XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtData **privList, *private, *found;
+ __GLXdisplayPrivate *dpyPriv;
+ XEDataObject dataObj;
+ int major, minor;
+
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+ {
+ static int firstCall = 1;
+ if (firstCall) {
+ /* initialize the GLX mutexes */
+ xmutex_init(&__glXmutex);
+ firstCall = 0;
+ }
+ }
+#endif
+
+ INIT_MESA_SPARC
+ /* The one and only long long lock */
+ __glXLock();
+
+ if (!XextHasExtension(info)) {
+ /* No GLX extension supported by this server. Oh well. */
+ __glXUnlock();
+ XMissingExtension(dpy, __glXExtensionName);
+ return 0;
+ }
+
+ /* See if a display private already exists. If so, return it */
+ dataObj.display = dpy;
+ privList = XEHeadOfExtensionList(dataObj);
+ found = XFindOnExtensionList(privList, info->codes->extension);
+ if (found) {
+ __glXUnlock();
+ return (__GLXdisplayPrivate *) found->private_data;
+ }
+
+ /* See if the versions are compatible */
+ if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
+ /* The client and server do not agree on versions. Punt. */
+ __glXUnlock();
+ return 0;
+ }
+
+ /*
+ ** Allocate memory for all the pieces needed for this buffer.
+ */
+ private = (XExtData *) Xmalloc(sizeof(XExtData));
+ if (!private) {
+ __glXUnlock();
+ return 0;
+ }
+ dpyPriv = (__GLXdisplayPrivate *) Xmalloc(sizeof(__GLXdisplayPrivate));
+ if (!dpyPriv) {
+ __glXUnlock();
+ Xfree((char*) private);
+ return 0;
+ }
+
+ /*
+ ** Init the display private and then read in the screen config
+ ** structures from the server.
+ */
+ dpyPriv->majorOpcode = info->codes->major_opcode;
+ dpyPriv->majorVersion = major;
+ dpyPriv->minorVersion = minor;
+ dpyPriv->dpy = dpy;
+
+ dpyPriv->serverGLXvendor = 0x0;
+ dpyPriv->serverGLXversion = 0x0;
+
+#ifdef GLX_DIRECT_RENDERING
+ /*
+ ** Initialize the direct rendering per display data and functions.
+ ** Note: This _must_ be done before calling any other DRI routines
+ ** (e.g., those called in AllocAndFetchScreenConfigs).
+ */
+ if (getenv("LIBGL_ALWAYS_INDIRECT")) {
+ /* Assinging zero here assures we'll never go direct */
+ dpyPriv->driDisplay.private = 0;
+ dpyPriv->driDisplay.destroyDisplay = 0;
+ dpyPriv->driDisplay.createScreen = 0;
+ }
+ else {
+ dpyPriv->driDisplay.private =
+ driCreateDisplay(dpy, &dpyPriv->driDisplay);
+ }
+#endif
+
+ if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+ __glXUnlock();
+ Xfree((char*) dpyPriv);
+ Xfree((char*) private);
+ return 0;
+ }
+
+ /*
+ ** Fill in the private structure. This is the actual structure that
+ ** hangs off of the Display structure. Our private structure is
+ ** referred to by this structure. Got that?
+ */
+ private->number = info->codes->extension;
+ private->next = 0;
+ private->free_private = __glXFreeDisplayPrivate;
+ private->private_data = (char *) dpyPriv;
+ XAddToExtensionList(privList, private);
+
+ if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
+ __glXClientInfo(dpy, dpyPriv->majorOpcode);
+ }
+ __glXUnlock();
+
+ return dpyPriv;
+}
+
+/*
+** Setup for sending a GLX command on dpy. Make sure the extension is
+** initialized. Try to avoid calling __glXInitialize as its kinda slow.
+*/
+CARD8 __glXSetupForCommand(Display *dpy)
+{
+ GLXContext gc;
+ __GLXdisplayPrivate *priv;
+
+ /* If this thread has a current context, flush its rendering commands */
+ gc = __glXGetCurrentContext();
+ if (gc->currentDpy) {
+ /* Flush rendering buffer of the current context, if any */
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+
+ if (gc->currentDpy == dpy) {
+ /* Use opcode from gc because its right */
+ INIT_MESA_SPARC
+ return gc->majorOpcode;
+ } else {
+ /*
+ ** Have to get info about argument dpy because it might be to
+ ** a different server
+ */
+ }
+ }
+
+ /* Forced to lookup extension via the slow initialize route */
+ priv = __glXInitialize(dpy);
+ if (!priv) {
+ return 0;
+ }
+ return priv->majorOpcode;
+}
+
+/*
+** Flush the drawing command transport buffer.
+*/
+GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
+{
+ Display *dpy;
+ xGLXRenderReq *req;
+ GLint size;
+
+ if (!(dpy = ctx->currentDpy)) {
+ /* Using the dummy context */
+ ctx->pc = ctx->buf;
+ return ctx->pc;
+ }
+
+ size = pc - ctx->buf;
+ if (size) {
+ /* Send the entire buffer as an X request */
+ LockDisplay(dpy);
+ GetReq(GLXRender,req);
+ req->reqType = ctx->majorOpcode;
+ req->glxCode = X_GLXRender;
+ req->contextTag = ctx->currentContextTag;
+ req->length += (size + 3) >> 2;
+ _XSend(dpy, (char *)ctx->buf, size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ /* Reset pointer and return it */
+ ctx->pc = ctx->buf;
+ return ctx->pc;
+}
+
+
+/**
+ * Send a portion of a GLXRenderLarge command to the server. The advantage of
+ * this function over \c __glXSendLargeCommand is that callers can use the
+ * data buffer in the GLX context and may be able to avoid allocating an
+ * extra buffer. The disadvantage is the clients will have to do more
+ * GLX protocol work (i.e., calculating \c totalRequests, etc.).
+ *
+ * \sa __glXSendLargeCommand
+ *
+ * \param gc GLX context
+ * \param requestNumber Which part of the whole command is this? The first
+ * request is 1.
+ * \param totalRequests How many requests will there be?
+ * \param data Command data.
+ * \param dataLen Size, in bytes, of the command data.
+ */
+void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
+ GLint totalRequests,
+ const GLvoid * data, GLint dataLen)
+{
+ Display *dpy = gc->currentDpy;
+ xGLXRenderLargeReq *req;
+
+ if ( requestNumber == 1 ) {
+ LockDisplay(dpy);
+ }
+
+ GetReq(GLXRenderLarge,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXRenderLarge;
+ req->contextTag = gc->currentContextTag;
+ req->length += (dataLen + 3) >> 2;
+ req->requestNumber = requestNumber;
+ req->requestTotal = totalRequests;
+ req->dataBytes = dataLen;
+ Data(dpy, data, dataLen);
+
+ if ( requestNumber == totalRequests ) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+}
+
+
+/**
+ * Send a command that is too large for the GLXRender protocol request.
+ *
+ * Send a large command, one that is too large for some reason to
+ * send using the GLXRender protocol request. One reason to send
+ * a large command is to avoid copying the data.
+ *
+ * \param ctx GLX context
+ * \param header Header data.
+ * \param headerLen Size, in bytes, of the header data. It is assumed that
+ * the header data will always be small enough to fit in
+ * a single X protocol packet.
+ * \param data Command data.
+ * \param dataLen Size, in bytes, of the command data.
+ */
+void __glXSendLargeCommand(__GLXcontext *ctx,
+ const GLvoid *header, GLint headerLen,
+ const GLvoid *data, GLint dataLen)
+{
+ GLint maxSize;
+ GLint totalRequests, requestNumber;
+
+ /*
+ ** Calculate the maximum amount of data can be stuffed into a single
+ ** packet. sz_xGLXRenderReq is added because bufSize is the maximum
+ ** packet size minus sz_xGLXRenderReq.
+ */
+ maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
+ totalRequests = 1 + (dataLen / maxSize);
+ if (dataLen % maxSize) totalRequests++;
+
+ /*
+ ** Send all of the command, except the large array, as one request.
+ */
+ assert( headerLen <= maxSize );
+ __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
+
+ /*
+ ** Send enough requests until the whole array is sent.
+ */
+ for ( requestNumber = 2 ; requestNumber <= (totalRequests - 1) ; requestNumber++ ) {
+ __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
+ data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
+ dataLen -= maxSize;
+ assert( dataLen > 0 );
+ }
+
+ assert( dataLen <= maxSize );
+ __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
+}
+
+/************************************************************************/
+
+GLXContext glXGetCurrentContext(void)
+{
+ GLXContext cx = __glXGetCurrentContext();
+
+ if (cx == &dummyContext) {
+ return NULL;
+ } else {
+ return cx;
+ }
+}
+
+GLXDrawable glXGetCurrentDrawable(void)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ return gc->currentDrawable;
+}
+
+
+/************************************************************************/
+
+#ifdef GLX_DIRECT_RENDERING
+/* Return the DRI per screen structure */
+__DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn)
+{
+ __DRIscreen *pDRIScreen = NULL;
+ XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtData **privList, *found;
+ __GLXdisplayPrivate *dpyPriv;
+ XEDataObject dataObj;
+
+ __glXLock();
+ dataObj.display = dpy;
+ privList = XEHeadOfExtensionList(dataObj);
+ found = XFindOnExtensionList(privList, info->codes->extension);
+ __glXUnlock();
+
+ if (found) {
+ dpyPriv = (__GLXdisplayPrivate *)found->private_data;
+ pDRIScreen = &dpyPriv->screenConfigs[scrn].driScreen;
+ }
+
+ return pDRIScreen;
+}
+#endif
+
+/************************************************************************/
+
+static Bool SendMakeCurrentRequest( Display *dpy, CARD8 opcode,
+ GLXContextID gc, GLXContextTag old_gc, GLXDrawable draw, GLXDrawable read,
+ xGLXMakeCurrentReply * reply );
+
+/**
+ * Sends a GLX protocol message to the specified display to make the context
+ * and the drawables current.
+ *
+ * \param dpy Display to send the message to.
+ * \param opcode Major opcode value for the display.
+ * \param gc_id Context tag for the context to be made current.
+ * \param draw Drawable ID for the "draw" drawable.
+ * \param read Drawable ID for the "read" drawable.
+ * \param reply Space to store the X-server's reply.
+ *
+ * \warning
+ * This function assumes that \c dpy is locked with \c LockDisplay on entry.
+ */
+static Bool SendMakeCurrentRequest( Display *dpy, CARD8 opcode,
+ GLXContextID gc_id, GLXContextTag gc_tag,
+ GLXDrawable draw, GLXDrawable read,
+ xGLXMakeCurrentReply * reply )
+{
+ if ( draw == read ) {
+ xGLXMakeCurrentReq *req;
+
+ GetReq(GLXMakeCurrent,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXMakeCurrent;
+ req->drawable = draw;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ else {
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+
+ /* If the server can support the GLX 1.3 version, we should
+ * perfer that. Not only that, some servers support GLX 1.3 but
+ * not the SGI extension.
+ */
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXMakeContextCurrentReq *req;
+
+ GetReq(GLXMakeContextCurrent,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXMakeContextCurrent;
+ req->drawable = draw;
+ req->readdrawable = read;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXMakeCurrentReadSGIReq *req;
+
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXMakeCurrentReadSGIReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ req = (xGLXMakeCurrentReadSGIReq *)vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
+ req->drawable = draw;
+ req->readable = read;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ }
+
+ return _XReply(dpy, (xReply*) reply, 0, False);
+}
+
+
+static Bool BindContextWrapper( Display *dpy, GLXContext gc,
+ GLXDrawable draw, GLXDrawable read )
+{
+#ifdef GLX_DIRECT_RENDERING
+ if ( gc->driContext.bindContext3 != NULL ) {
+ return (*gc->driContext.bindContext3)(dpy, gc->screen, draw, read,
+ & gc->driContext);
+ }
+ else {
+ return (*gc->driContext.bindContext2)(dpy, gc->screen, draw, read,
+ gc);
+ }
+#else
+ return GL_FALSE;
+#endif
+}
+
+
+static Bool UnbindContextWrapper( Display *dpy, GLXContext gc )
+{
+#ifdef GLX_DIRECT_RENDERING
+ if ( gc->driContext.unbindContext3 != NULL ) {
+ return (*gc->driContext.unbindContext3)(dpy, gc->screen,
+ gc->currentDrawable,
+ gc->currentReadable,
+ & gc->driContext );
+ }
+ else {
+ return (*gc->driContext.unbindContext2)(dpy, gc->screen,
+ gc->currentDrawable,
+ gc->currentReadable, gc);
+ }
+#else
+ return GL_FALSE;
+#endif
+}
+
+
+/*
+** Make a particular context current.
+** NOTE: this is in this file so that it can access dummyContext.
+*/
+static Bool MakeContextCurrent(Display *dpy,
+ GLXDrawable draw, GLXDrawable read,
+ GLXContext gc)
+{
+ xGLXMakeCurrentReply reply;
+ GLXContext oldGC;
+ CARD8 opcode, oldOpcode;
+ Bool sentRequestToOldDpy = False;
+ Bool bindReturnValue = True;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return GL_FALSE;
+ }
+
+ /*
+ ** Make sure that the new context has a nonzero ID. In the request,
+ ** a zero context ID is used only to mean that we bind to no current
+ ** context.
+ */
+ if ((gc != NULL) && (gc->xid == None)) {
+ return GL_FALSE;
+ }
+
+ oldGC = __glXGetCurrentContext();
+ oldOpcode = (gc == oldGC) ? opcode : __glXSetupForCommand(dpy);
+ if (!oldOpcode) {
+ return GL_FALSE;
+ }
+
+ if ((dpy != oldGC->currentDpy || (gc && gc->isDirect)) &&
+ !oldGC->isDirect && oldGC != &dummyContext) {
+ /*
+ ** We are either switching from one dpy to another and have to
+ ** send a request to the previous dpy to unbind the previous
+ ** context, or we are switching away from a indirect context to
+ ** a direct context and have to send a request to the dpy to
+ ** unbind the previous context.
+ */
+ sentRequestToOldDpy = True;
+ LockDisplay(oldGC->currentDpy);
+ if ( ! SendMakeCurrentRequest( oldGC->currentDpy, oldOpcode, None,
+ oldGC->currentContextTag, None, None,
+ &reply ) ) {
+ /* The make current failed. Just return GL_FALSE. */
+ UnlockDisplay(oldGC->currentDpy);
+ SyncHandle();
+ return GL_FALSE;
+ }
+
+ oldGC->currentContextTag = 0;
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Unbind the old direct rendering context */
+ if (oldGC->isDirect) {
+ if (oldGC->driContext.private) {
+ if (! UnbindContextWrapper( oldGC->currentDpy, oldGC )) {
+ /* The make current failed. Just return GL_FALSE. */
+ return GL_FALSE;
+ }
+ }
+ oldGC->currentContextTag = 0;
+ }
+
+ /* Bind the direct rendering context to the drawable */
+ if (gc && gc->isDirect) {
+ if (gc->driContext.private) {
+ bindReturnValue = BindContextWrapper( dpy, gc, draw, read );
+ }
+ } else {
+#endif
+ _glapi_check_multithread();
+ /* Send a glXMakeCurrent request to bind the new context. */
+ LockDisplay(dpy);
+
+ bindReturnValue = SendMakeCurrentRequest( dpy, opcode,
+ gc ? gc->xid : None,
+ oldGC->currentContextTag,
+ draw, read, &reply );
+ UnlockDisplay(dpy);
+#ifdef GLX_DIRECT_RENDERING
+ }
+#endif
+
+
+ if (!bindReturnValue) {
+ /* The make current failed. */
+ if (gc && !gc->isDirect) {
+ SyncHandle();
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ /* If the old context was direct rendering, then re-bind to it. */
+ if (oldGC->isDirect) {
+ if (oldGC->driContext.private) {
+ if (! BindContextWrapper( oldGC->currentDpy, oldGC,
+ oldGC->currentDrawable,
+ oldGC->currentReadable )) {
+ /*
+ ** The request failed; this cannot happen with the
+ ** current API. If in the future the API is
+ ** extended to allow context sharing between
+ ** clients, then this may fail (because another
+ ** client may have grabbed the context); in that
+ ** case, we cannot undo the previous request, and
+ ** cannot adhere to the "no-op" behavior.
+ */
+ }
+ }
+ } else
+#endif
+ /*
+ ** If we had just sent a request to a previous dpy, we have to
+ ** undo that request (because if a command fails, it should act
+ ** like a no-op) by making current to the previous context and
+ ** drawable.
+ */
+ if (sentRequestToOldDpy) {
+ if ( !SendMakeCurrentRequest( oldGC->currentDpy, oldOpcode,
+ oldGC->xid, 0,
+ oldGC->currentDrawable,
+ oldGC->currentReadable, &reply ) ) {
+ UnlockDisplay(oldGC->currentDpy);
+ SyncHandle();
+ /*
+ ** The request failed; this cannot happen with the
+ ** current API. If in the future the API is extended to
+ ** allow context sharing between clients, then this may
+ ** fail (because another client may have grabbed the
+ ** context); in that case, we cannot undo the previous
+ ** request, and cannot adhere to the "no-op" behavior.
+ */
+ }
+ else {
+ UnlockDisplay(oldGC->currentDpy);
+ }
+ oldGC->currentContextTag = reply.contextTag;
+ }
+ return GL_FALSE;
+ }
+
+ /* Update our notion of what is current */
+ __glXLock();
+ if (gc == oldGC) {
+ /*
+ ** Even though the contexts are the same the drawable might have
+ ** changed. Note that gc cannot be the dummy, and that oldGC
+ ** cannot be NULL, therefore if they are the same, gc is not
+ ** NULL and not the dummy.
+ */
+ gc->currentDrawable = draw;
+ gc->currentReadable = read;
+ } else {
+ if (oldGC != &dummyContext) {
+ /* Old current context is no longer current to anybody */
+ oldGC->currentDpy = 0;
+ oldGC->currentDrawable = None;
+ oldGC->currentReadable = None;
+ oldGC->currentContextTag = 0;
+
+ if (oldGC->xid == None) {
+ /*
+ ** We are switching away from a context that was
+ ** previously destroyed, so we need to free the memory
+ ** for the old handle.
+ */
+#ifdef GLX_DIRECT_RENDERING
+ /* Destroy the old direct rendering context */
+ if (oldGC->isDirect) {
+ if (oldGC->driContext.private) {
+ (*oldGC->driContext.destroyContext)
+ (dpy, oldGC->screen, oldGC->driContext.private);
+ oldGC->driContext.private = NULL;
+ }
+ }
+#endif
+ __glXFreeContext(oldGC);
+ }
+ }
+ if (gc) {
+ __glXSetCurrentContext(gc);
+#ifdef GLX_DIRECT_RENDERING
+ if (!gc->isDirect) {
+ if (!IndirectAPI)
+ IndirectAPI = __glXNewIndirectAPI();
+ _glapi_set_dispatch(IndirectAPI);
+# ifdef GLX_USE_APPLEGL
+ do {
+ extern void XAppleDRIUseIndirectDispatch(void);
+ XAppleDRIUseIndirectDispatch();
+ } while (0);
+# endif
+ }
+#else
+ /* if not direct rendering, always need indirect dispatch */
+ if (!IndirectAPI)
+ IndirectAPI = __glXNewIndirectAPI();
+ _glapi_set_dispatch(IndirectAPI);
+#endif
+ gc->currentDpy = dpy;
+ gc->currentDrawable = draw;
+ gc->currentReadable = read;
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) reply.contextTag = -1;
+#endif
+ gc->currentContextTag = reply.contextTag;
+ } else {
+ __glXSetCurrentContext(&dummyContext);
+#ifdef GLX_DIRECT_RENDERING
+ _glapi_set_dispatch(NULL); /* no-op functions */
+#endif
+ }
+ }
+ __glXUnlock();
+ return GL_TRUE;
+}
+
+
+Bool GLX_PREFIX(glXMakeCurrent)(Display *dpy, GLXDrawable draw, GLXContext gc)
+{
+ return MakeContextCurrent( dpy, draw, draw, gc );
+}
+
+GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
+ (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+ (dpy, d, r, ctx), MakeContextCurrent)
+
+GLX_ALIAS(Bool, glXMakeContextCurrent,
+ (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+ (dpy, d, r, ctx), MakeContextCurrent)
+
+
+#ifdef DEBUG
+void __glXDumpDrawBuffer(__GLXcontext *ctx)
+{
+ GLubyte *p = ctx->buf;
+ GLubyte *end = ctx->pc;
+ GLushort opcode, length;
+
+ while (p < end) {
+ /* Fetch opcode */
+ opcode = *((GLushort*) p);
+ length = *((GLushort*) (p + 2));
+ printf("%2x: %5d: ", opcode, length);
+ length -= 4;
+ p += 4;
+ while (length > 0) {
+ printf("%08x ", *((unsigned *) p));
+ p += 4;
+ length -= 4;
+ }
+ printf("\n");
+ }
+}
+#endif
+
+#ifdef USE_SPARC_ASM
+/*
+ * Used only when we are sparc, using sparc assembler.
+ *
+ */
+
+static void
+_glx_mesa_init_sparc_glapi_relocs(void)
+{
+ unsigned int *insn_ptr, *end_ptr;
+ unsigned long disp_addr;
+
+ insn_ptr = &_mesa_sparc_glapi_begin;
+ end_ptr = &_mesa_sparc_glapi_end;
+ disp_addr = (unsigned long) &_glapi_Dispatch;
+
+ /*
+ * Verbatim from Mesa sparc.c. It's needed because there doesn't
+ * seem to be a better way to do this:
+ *
+ * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset )
+ *
+ * This code is patching in the ADDRESS of the pointer to the
+ * dispatch table. Hence, it must be called exactly once, because
+ * that address is not going to change.
+ *
+ * What it points to can change, but Mesa (and hence, we) assume
+ * that there is only one pointer.
+ *
+ */
+ while (insn_ptr < end_ptr) {
+#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) )
+/*
+ This code patches for 64-bit addresses. This had better
+ not happen for Sparc/Linux, no matter what architecture we
+ are building for. So, don't do this.
+
+ The 'defined(__linux_64__)' is used here as a placeholder for
+ when we do do 64-bit usermode on sparc linux.
+ */
+ insn_ptr[0] |= (disp_addr >> (32 + 10));
+ insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
+ insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[2]);
+ insn_ptr += 11;
+#else
+ insn_ptr[0] |= (disp_addr >> 10);
+ insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr += 5;
+#endif
+ }
+}
+#endif /* sparc ASM in use */
+
diff --git a/src/glx/x11/glxextensions.c b/src/glx/x11/glxextensions.c
new file mode 100644
index 0000000000..8e7afa6b4b
--- /dev/null
+++ b/src/glx/x11/glxextensions.c
@@ -0,0 +1,710 @@
+/*
+ * (C) Copyright IBM Corporation 2002, 2004
+ * All Rights Reserved.
+ *
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS 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 glxextensions.c
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+/* $XFree86: xc/lib/GL/glx/glxextensions.c,v 1.1 2003/09/28 20:15:03 alanh Exp $ */
+
+#include "glxclient.h"
+#include <extutil.h>
+#include <Xext.h>
+#include <string.h>
+#include "glapi.h"
+#include "glxextensions.h"
+#include "simple_list.h"
+
+#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8)))
+#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
+#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0)
+#define CONCAT(a,b) a ## b
+#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit)
+#define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit
+#define VER(a,b) a, b
+#define Y 1
+#define N 0
+#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit ))
+
+
+struct extension_info {
+ const char * const name;
+ unsigned name_len;
+
+ unsigned char bit;
+
+ /* This is the lowest version of GLX that "requires" this extension.
+ * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
+ * SGI_make_current_read. If the extension is not required by any known
+ * version of GLX, use 0, 0.
+ */
+ unsigned char version_major;
+ unsigned char version_minor;
+ unsigned char client_support;
+ unsigned char direct_support;
+ unsigned char client_only; /** Is the extension client-side only? */
+ unsigned char direct_only; /** Is the extension for direct
+ * contexts only?
+ */
+};
+
+static const struct extension_info known_glx_extensions[] = {
+ { GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N },
+ { GLX(ARB_multisample), VER(1,4), Y, Y, N, N },
+ { GLX(ARB_render_texture), VER(0,0), N, N, N, N },
+ { GLX(ATI_pixel_format_float), VER(0,0), N, N, N, N },
+ { GLX(EXT_import_context), VER(0,0), Y, Y, N, N },
+ { GLX(EXT_visual_info), VER(0,0), Y, Y, N, N },
+ { GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N },
+ { GLX(MESA_agp_offset), VER(0,0), N, N, N, Y }, /* Deprecated */
+ { GLX(MESA_allocate_memory), VER(0,0), Y, N, N, Y },
+ { GLX(MESA_copy_sub_buffer), VER(0,0), N, N, N, N }, /* Deprecated? */
+ { GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */
+ { GLX(MESA_release_buffers), VER(0,0), N, N, N, N }, /* Deprecated */
+ { GLX(MESA_set_3dfx_mode), VER(0,0), N, N, N, N }, /* Deprecated */
+ { GLX(MESA_swap_control), VER(0,0), Y, N, N, Y },
+ { GLX(MESA_swap_frame_usage), VER(0,0), Y, N, N, Y },
+ { GLX(NV_float_buffer), VER(0,0), N, N, N, N },
+ { GLX(NV_render_depth_texture), VER(0,0), N, N, N, N },
+ { GLX(NV_render_texture_rectangle), VER(0,0), N, N, N, N },
+ { GLX(NV_vertex_array_range), VER(0,0), N, N, N, Y }, /* Deprecated */
+ { GLX(OML_swap_method), VER(0,0), Y, N, N, N },
+ { GLX(OML_sync_control), VER(0,0), Y, N, N, Y },
+ { GLX(SGI_cushion), VER(0,0), N, N, N, N },
+ { GLX(SGI_make_current_read), VER(1,3), Y, N, N, N },
+ { GLX(SGI_swap_control), VER(0,0), Y, N, N, N },
+ { GLX(SGI_video_sync), VER(0,0), Y, N, N, Y },
+ { GLX(SGIS_blended_overlay), VER(0,0), N, N, N, N },
+ { GLX(SGIS_color_range), VER(0,0), N, N, N, N },
+ { GLX(SGIS_multisample), VER(0,0), Y, Y, N, N },
+ { GLX(SGIX_dm_buffer), VER(0,0), N, N, N, N },
+ { GLX(SGIX_fbconfig), VER(1,3), Y, N, N, N },
+ { GLX(SGIX_pbuffer), VER(1,3), Y, N, N, N },
+ { GLX(SGIX_swap_barrier), VER(0,0), N, N, N, N },
+ { GLX(SGIX_swap_group), VER(0,0), N, N, N, N },
+ { GLX(SGIX_video_resize), VER(0,0), N, N, N, N },
+ { GLX(SGIX_video_source), VER(0,0), N, N, N, N },
+ { GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N },
+ { GLX(SUN_get_transparent_index), VER(0,0), N, N, N, N },
+ { NULL }
+};
+
+static const struct extension_info known_gl_extensions[] = {
+ { GL(ARB_depth_texture), VER(1,4), Y, N, N, N },
+ { GL(ARB_fragment_program), VER(0,0), N, N, N, N },
+ { GL(ARB_imaging), VER(0,0), Y, N, N, N },
+ { GL(ARB_multisample), VER(1,3), Y, N, N, N },
+ { GL(ARB_multitexture), VER(1,3), Y, N, N, N },
+ { GL(ARB_occlusion_query), VER(1,5), N, N, N, N },
+ { GL(ARB_point_parameters), VER(1,4), Y, N, N, N },
+ { GL(ARB_point_sprite), VER(0,0), Y, N, N, N },
+ { GL(ARB_shadow), VER(1,4), Y, N, N, N },
+ { GL(ARB_shadow_ambient), VER(0,0), Y, N, N, N },
+ { GL(ARB_texture_border_clamp), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_compression), VER(1,3), N, N, N, N },
+ { GL(ARB_texture_cube_map), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_env_add), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_env_combine), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_env_crossbar), VER(1,4), Y, N, N, N },
+ { GL(ARB_texture_env_dot3), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_mirrored_repeat), VER(1,4), Y, N, N, N },
+ { GL(ARB_texture_non_power_of_two), VER(1,5), Y, N, N, N },
+ { GL(ARB_transpose_matrix), VER(1,3), Y, N, Y, N },
+ { GL(ARB_vertex_buffer_object), VER(1,5), N, N, N, N },
+ { GL(ARB_window_pos), VER(1,4), Y, N, N, N },
+ { GL(EXT_abgr), VER(0,0), Y, N, N, N },
+ { GL(EXT_bgra), VER(1,2), Y, N, N, N },
+ { GL(EXT_blend_color), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_equation_separate), VER(0,0), N, N, N, N },
+ { GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_minmax), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_subtract), VER(1,4), Y, N, N, N },
+ { GL(EXT_clip_volume_hint), VER(0,0), Y, N, N, N },
+ { GL(EXT_compiled_vertex_array), VER(0,0), N, N, N, N },
+ { GL(EXT_convolution), VER(0,0), N, N, N, N },
+ { GL(EXT_copy_texture), VER(1,1), Y, N, N, N },
+ { GL(EXT_cull_vertex), VER(0,0), N, N, N, N },
+ { GL(EXT_depth_bounds_test), VER(0,0), N, N, N, N },
+ { GL(EXT_draw_range_elements), VER(1,2), Y, N, Y, N },
+ { GL(EXT_fog_coord), VER(1,4), Y, N, N, N },
+ { GL(EXT_multi_draw_arrays), VER(1,4), Y, N, Y, N },
+ { GL(EXT_packed_pixels), VER(1,2), Y, N, N, N },
+ { GL(EXT_paletted_texture), VER(0,0), Y, N, N, N },
+ { GL(EXT_pixel_buffer_object), VER(0,0), N, N, N, N },
+ { GL(EXT_point_parameters), VER(1,4), Y, N, N, N },
+ { GL(EXT_polygon_offset), VER(1,1), Y, N, N, N },
+ { GL(EXT_rescale_normal), VER(1,2), Y, N, N, N },
+ { GL(EXT_secondary_color), VER(1,4), Y, N, N, N },
+ { GL(EXT_separate_specular_color), VER(1,2), Y, N, N, N },
+ { GL(EXT_shadow_funcs), VER(1,5), Y, N, N, N },
+ { GL(EXT_shared_texture_palette), VER(0,0), Y, N, N, N },
+ { GL(EXT_stencil_two_side), VER(0,0), Y, N, N, N },
+ { GL(EXT_stencil_wrap), VER(1,4), Y, N, N, N },
+ { GL(EXT_subtexture), VER(1,1), Y, N, N, N },
+ { GL(EXT_texture), VER(1,1), Y, N, N, N },
+ { GL(EXT_texture3D), VER(1,2), Y, N, N, N },
+ { GL(EXT_texture_compression_s3tc), VER(0,0), N, N, N, N },
+ { GL(EXT_texture_edge_clamp), VER(1,2), Y, N, N, N },
+ { GL(EXT_texture_env_add), VER(1,3), Y, N, N, N },
+ { GL(EXT_texture_env_combine), VER(1,3), Y, N, N, N },
+ { GL(EXT_texture_env_dot3), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_filter_anisotropic), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_lod), VER(1,2), Y, N, N, N },
+ { GL(EXT_texture_lod_bias), VER(1,4), Y, N, N, N },
+ { GL(EXT_texture_mirror_clamp), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_object), VER(1,1), Y, N, N, N },
+ { GL(EXT_texture_rectangle), VER(0,0), Y, N, N, N },
+ { GL(EXT_vertex_array), VER(0,0), Y, N, N, N },
+ { GL(3DFX_texture_compression_FXT1), VER(0,0), N, N, N, N },
+ { GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N },
+ { GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N },
+ { GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N },
+ { GL(ATI_texture_float), VER(0,0), Y, N, N, N },
+ { GL(ATI_texture_mirror_once), VER(0,0), Y, N, N, N },
+ { GL(ATIX_texture_env_combine3), VER(0,0), Y, N, N, N },
+ { GL(HP_convolution_border_modes), VER(0,0), Y, N, N, N },
+
+ /* This is currently removed because there seem to be some problems with
+ * it and the software-only indirect rendering path. At this point, I'm
+ * not sure which side (client or server) has the problem. - idr
+ */
+ { GL(HP_occlusion_test), VER(0,0), N, N, N, N },
+
+ { GL(IBM_cull_vertex), VER(0,0), Y, N, N, N },
+ { GL(IBM_pixel_filter_hint), VER(0,0), Y, N, N, N },
+ { GL(IBM_rasterpos_clip), VER(0,0), Y, N, N, N },
+ { GL(IBM_texture_clamp_nodraw), VER(0,0), Y, N, N, N },
+ { GL(IBM_texture_mirrored_repeat), VER(0,0), Y, N, N, N },
+ { GL(INGR_blend_func_separate), VER(0,0), Y, N, N, N },
+ { GL(INGR_interlace_read), VER(0,0), Y, N, N, N },
+ { GL(MESA_pack_invert), VER(0,0), Y, N, N, N },
+ { GL(MESA_ycbcr_texture), VER(0,0), Y, N, N, N },
+ { GL(NV_blend_square), VER(1,4), Y, N, N, N },
+ { GL(NV_copy_depth_to_color), VER(0,0), Y, N, N, N },
+ { GL(NV_depth_clamp), VER(0,0), Y, N, N, N },
+ { GL(NV_fog_distance), VER(0,0), Y, N, N, N },
+ { GL(NV_light_max_exponent), VER(0,0), Y, N, N, N },
+ { GL(NV_multisample_filter_hint), VER(0,0), Y, N, N, N },
+ { GL(NV_point_sprite), VER(0,0), Y, N, N, N },
+ { GL(NV_texgen_reflection), VER(0,0), Y, N, N, N },
+ { GL(NV_texture_compression_vtc), VER(0,0), N, N, N, N },
+ { GL(NV_texture_env_combine4), VER(0,0), Y, N, N, N },
+ { GL(NV_texture_rectangle), VER(0,0), Y, N, N, N },
+ { GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N },
+ { GL(SGIS_multisample), VER(0,0), Y, N, N, N },
+ { GL(SGIS_texture_border_clamp), VER(1,3), Y, N, N, N },
+ { GL(SGIS_texture_edge_clamp), VER(1,2), Y, N, N, N },
+ { GL(SGIS_texture_lod), VER(1,2), Y, N, N, N },
+ { GL(SGIX_blend_alpha_minmax), VER(0,0), Y, N, N, N },
+ { GL(SGIX_clipmap), VER(0,0), Y, N, N, N },
+ { GL(SGIX_depth_texture), VER(0,0), Y, N, N, N },
+ { GL(SGIX_fog_offset), VER(0,0), Y, N, N, N },
+ { GL(SGIX_shadow), VER(0,0), Y, N, N, N },
+ { GL(SGIX_shadow_ambient), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_coordinate_clamp), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_lod_bias), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_range), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_scale_bias), VER(0,0), Y, N, N, N },
+ { GL(SGIX_vertex_preclip), VER(0,0), Y, N, N, N },
+ { GL(SGIX_vertex_preclip_hint), VER(0,0), Y, N, N, N },
+ { GL(SGIX_ycrcb), VER(0,0), Y, N, N, N },
+ { GL(SUN_convolution_border_modes), VER(0,0), Y, N, N, N },
+ { GL(SUN_multi_draw_arrays), VER(0,0), Y, N, Y, N },
+ { GL(SUN_slice_accum), VER(0,0), Y, N, N, N },
+ { NULL }
+};
+
+
+#define __GL_EXT_BYTES ((__NUM_GL_EXTS + 7) / 8)
+
+/* global bit-fields of available extensions and their characteristics */
+static unsigned char client_glx_support[8];
+static unsigned char client_glx_only[8];
+static unsigned char direct_glx_only[8];
+static unsigned char client_gl_support[ __GL_EXT_BYTES ];
+static unsigned char client_gl_only[ __GL_EXT_BYTES ];
+
+/**
+ * Bits representing the set of extensions that are enabled by default in all
+ * direct rendering drivers.
+ */
+static unsigned char direct_glx_support[8];
+
+/**
+ * Highest core GL version that can be supported for indirect rendering.
+ */
+static unsigned gl_major = 0;
+static unsigned gl_minor = 0;
+
+/* client extensions string */
+static const char * __glXGLXClientExtensions = NULL;
+
+static void __glXExtensionsCtr( void );
+static void __glXExtensionsCtrScreen( __GLXscreenConfigs *psc );
+static void __glXProcessServerString( const struct extension_info * ext,
+ const char * server_string, unsigned char * server_support );
+
+/**
+ * Set the state of a GLX extension.
+ *
+ * \param name Name of the extension.
+ * \param name_len Length, in characters, of the extension name.
+ * \param state New state (either enabled or disabled) of the extension.
+ * \param supported Table in which the state of the extension is to be set.
+ */
+static void
+set_glx_extension( const struct extension_info * ext,
+ const char * name, unsigned name_len, GLboolean state,
+ unsigned char * supported )
+{
+ unsigned i;
+
+
+ for ( i = 0 ; ext[i].name != NULL ; i++ ) {
+ if ( (name_len == ext[i].name_len)
+ && (strncmp( ext[i].name, name, name_len ) == 0) ) {
+ if ( state ) {
+ SET_BIT( supported, ext[i].bit );
+ }
+ else {
+ CLR_BIT( supported, ext[i].bit );
+ }
+
+ return;
+ }
+ }
+}
+
+
+#define NUL '\0'
+#define SEPARATOR ' '
+
+/**
+ * Convert the server's extension string to a bit-field.
+ *
+ * \param server_string GLX extension string from the server.
+ * \param server_support Bit-field of supported extensions.
+ */
+static void
+__glXProcessServerString( const struct extension_info * ext,
+ const char * server_string,
+ unsigned char * server_support )
+{
+ unsigned base;
+ unsigned len;
+
+ (void) memset( server_support, 0, sizeof( server_support ) );
+
+ for ( base = 0 ; server_string[ base ] != NUL ; /* empty */ ) {
+ /* Determine the length of the next extension name.
+ */
+ for ( len = 0
+ ; (server_string[ base + len ] != SEPARATOR)
+ && (server_string[ base + len ] != NUL)
+ ; len++ ) {
+ /* empty */
+ }
+
+ /* Set the bit for the extension in the server_support table.
+ */
+ set_glx_extension( ext, & server_string[ base ], len, GL_TRUE,
+ server_support );
+
+
+ /* Advance to the next extension string. This means that we skip
+ * over the previous string and any trialing white-space.
+ */
+ for ( base += len ;
+ (server_string[ base ] == SEPARATOR)
+ && (server_string[ base ] != NUL)
+ ; base++ ) {
+ /* empty */
+ }
+ }
+}
+
+
+/**
+ * Enable a named GLX extension on a given screen.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ * \param name Name of the extension to enable.
+ *
+ * \sa glXGetProcAddress
+ *
+ * \since Internal API version 20030813.
+ */
+void
+__glXScrEnableExtension( __GLXscreenConfigs *psc, const char * name )
+{
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen(psc);
+ set_glx_extension( known_glx_extensions, name, strlen( name ), GL_TRUE,
+ psc->direct_support );
+}
+
+
+/**
+ * Initialize global extension support tables.
+ */
+
+static void
+__glXExtensionsCtr( void )
+{
+ static const char major_table[32] = { 1, 1, 1, 1, 1, 1, 2, };
+ static const char minor_table[32] = { 0, 1, 2, 3, 4, 5, 0, };
+ unsigned i;
+ static GLboolean ext_list_first_time = GL_TRUE;
+ unsigned full_support = ~0;
+
+
+ if ( ext_list_first_time ) {
+ ext_list_first_time = GL_FALSE;
+
+ (void) memset( client_glx_support, 0, sizeof( client_glx_support ) );
+ (void) memset( direct_glx_support, 0, sizeof( direct_glx_support ) );
+ (void) memset( client_glx_only, 0, sizeof( client_glx_only ) );
+ (void) memset( direct_glx_only, 0, sizeof( direct_glx_only ) );
+
+ (void) memset( client_gl_support, 0, sizeof( client_gl_support ) );
+ (void) memset( client_gl_only, 0, sizeof( client_gl_only ) );
+
+ for ( i = 0 ; known_glx_extensions[i].name != NULL ; i++ ) {
+ const unsigned bit = known_glx_extensions[i].bit;
+
+ if ( known_glx_extensions[i].client_support ) {
+ SET_BIT( client_glx_support, bit );
+ }
+
+ if ( known_glx_extensions[i].direct_support ) {
+ SET_BIT( direct_glx_support, bit );
+ }
+
+ if ( known_glx_extensions[i].client_only ) {
+ SET_BIT( client_glx_only, bit );
+ }
+
+ if ( known_glx_extensions[i].direct_only ) {
+ SET_BIT( direct_glx_only, bit );
+ }
+ }
+
+ for ( i = 0 ; known_gl_extensions[i].name != NULL ; i++ ) {
+ const unsigned bit = known_gl_extensions[i].bit;
+
+ if ( known_gl_extensions[i].client_support ) {
+ SET_BIT( client_gl_support, bit );
+ }
+ else if ( known_gl_extensions[i].version_major != 0 ) {
+ /* If an extension that is required for some core GL version is
+ * not supported, clear the bit for that core GL version as well.
+ */
+
+ unsigned ver_bit = (6 * (known_gl_extensions[i].version_major - 1))
+ + (known_gl_extensions[i].version_minor);
+
+ full_support &= ~(1U << ver_bit);
+ }
+
+ if ( known_gl_extensions[i].client_only ) {
+ SET_BIT( client_gl_only, bit );
+ }
+ }
+
+ /* Determine the lowest unsupported core GL version. The version before
+ * that is, therefore, the highest supported core GL version.
+ */
+ for ( i = 0 ; (full_support & (1 << i)) != 0 ; i++ )
+ /* empty */ ;
+
+ i--;
+ gl_major = major_table[i];
+ gl_minor = minor_table[i];
+#if 0
+ fprintf( stderr, "[%s:%u] Maximum client library version: %u.%u\n",
+ __func__, __LINE__, gl_major, gl_minor );
+#endif
+ }
+}
+
+
+/**
+ * Make sure that per-screen direct-support table is initialized.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ */
+
+static void
+__glXExtensionsCtrScreen( __GLXscreenConfigs *psc )
+{
+ if (psc->ext_list_first_time) {
+ psc->ext_list_first_time = GL_FALSE;
+ (void) memcpy( psc->direct_support, direct_glx_support,
+ sizeof( direct_glx_support ) );
+ }
+}
+
+
+/**
+ * Check if a certain extension is enabled on a given screen.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ * \param bit Bit index in the direct-support table.
+ * \returns If the extension bit is enabled for the screen, \c GL_TRUE is
+ * returned. If the extension bit is not enabled or if \c psc is
+ * \c NULL, then \c GL_FALSE is returned.
+ */
+GLboolean
+__glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit )
+{
+ GLboolean enabled = GL_FALSE;
+
+ if ( psc != NULL ) {
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen( psc );
+ enabled = EXT_ENABLED( bit, psc->direct_support );
+ }
+
+ return enabled;
+}
+
+
+/**
+ * Convert a bit-field to a string of supported extensions.
+ */
+static char *
+__glXGetStringFromTable( const struct extension_info * ext,
+ const unsigned char * supported )
+{
+ unsigned i;
+ unsigned ext_str_len;
+ char * ext_str;
+ char * point;
+
+
+ ext_str_len = 0;
+ for ( i = 0 ; ext[i].name != NULL ; i++ ) {
+ if ( EXT_ENABLED( ext[i].bit, supported ) ) {
+ ext_str_len += ext[i].name_len + 1;
+ }
+ }
+
+ ext_str = Xmalloc( ext_str_len + 1 );
+ if ( ext_str != NULL ) {
+ point = ext_str;
+
+ for ( i = 0 ; ext[i].name != NULL ; i++ ) {
+ if ( EXT_ENABLED( ext[i].bit, supported ) ) {
+ (void) memcpy( point, ext[i].name, ext[i].name_len );
+ point += ext[i].name_len;
+
+ *point = ' ';
+ point++;
+ }
+ }
+
+ *point = '\0';
+ }
+
+ return ext_str;
+}
+
+
+/**
+ * Get the string of client library supported extensions.
+ */
+const char *
+__glXGetClientExtensions( void )
+{
+ if ( __glXGLXClientExtensions == NULL ) {
+ __glXExtensionsCtr();
+ __glXGLXClientExtensions = __glXGetStringFromTable( known_glx_extensions,
+ client_glx_support );
+ }
+
+ return __glXGLXClientExtensions;
+}
+
+
+/**
+ * Calculate the list of application usable extensions. The resulting
+ * string is stored in \c psc->effectiveGLXexts.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ * \param display_is_direct_capable True if the display is capable of
+ * direct rendering.
+ * \param minor_version GLX minor version from the server.
+ */
+
+void
+__glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
+ GLboolean display_is_direct_capable,
+ int minor_version )
+{
+ unsigned char server_support[8];
+ unsigned char usable[8];
+ unsigned i;
+
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen( psc );
+ __glXProcessServerString( known_glx_extensions,
+ psc->serverGLXexts, server_support );
+
+
+ /* This is a hack. Some servers support GLX 1.3 but don't export
+ * all of the extensions implied by GLX 1.3. If the server claims
+ * support for GLX 1.3, enable support for the extensions that can be
+ * "emulated" as well.
+ */
+
+ if ( minor_version >= 3 ) {
+ SET_BIT( server_support, EXT_visual_info_bit );
+ SET_BIT( server_support, EXT_visual_rating_bit );
+ SET_BIT( server_support, SGI_make_current_read_bit );
+ SET_BIT( server_support, SGIX_fbconfig_bit );
+ SET_BIT( server_support, SGIX_pbuffer_bit );
+
+ /* This one is a little iffy. GLX 1.3 doesn't incorporate all of this
+ * extension. However, the only part that is not strictly client-side
+ * is shared. That's the glXQueryContext / glXQueryContextInfoEXT
+ * function.
+ */
+
+ SET_BIT( server_support, EXT_import_context_bit );
+ }
+
+
+ /* An extension is supported if the client-side (i.e., libGL) supports
+ * it and the "server" supports it. In this case that means that either
+ * the true server supports it or it is only for direct-rendering and
+ * the direct rendering driver supports it.
+ *
+ * If the display is not capable of direct rendering, then the extension
+ * is enabled if and only if the client-side library and the server
+ * support it.
+ */
+
+ if ( display_is_direct_capable ) {
+ for ( i = 0 ; i < 8 ; i++ ) {
+ usable[i] = (client_glx_support[i] & client_glx_only[i])
+ | (client_glx_support[i] & psc->direct_support[i] & server_support[i])
+ | (client_glx_support[i] & psc->direct_support[i] & direct_glx_only[i]);
+ }
+ }
+ else {
+ for ( i = 0 ; i < 8 ; i++ ) {
+ usable[i] = (client_glx_support[i] & client_glx_only[i])
+ | (client_glx_support[i] & server_support[i]);
+ }
+ }
+
+ psc->effectiveGLXexts = __glXGetStringFromTable( known_glx_extensions,
+ usable );
+}
+
+
+/**
+ * Calculate the list of application usable extensions. The resulting
+ * string is stored in \c gc->extensions.
+ *
+ * \param gc Pointer to GLX context.
+ * \param server_string Extension string from the server.
+ * \param major_version GL major version from the server.
+ * \param minor_version GL minor version from the server.
+ */
+
+void
+__glXCalculateUsableGLExtensions( __GLXcontext * gc,
+ const char * server_string,
+ int major_version, int minor_version )
+{
+ unsigned char server_support[ __GL_EXT_BYTES ];
+ unsigned char usable[ __GL_EXT_BYTES ];
+ unsigned i;
+
+
+ __glXExtensionsCtr();
+
+ (void) memset( server_support, 0, sizeof( server_support ) );
+ __glXProcessServerString( known_gl_extensions, server_string,
+ server_support );
+
+
+ /* Handle lazy servers that don't export all the extensions strings that
+ * are part of the GL core version that they support.
+ */
+
+ for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
+ if ( (known_gl_extensions[i].version_major != 0)
+ && ((major_version > known_gl_extensions[i].version_major)
+ || ((major_version == known_gl_extensions[i].version_major)
+ && (minor_version >= known_gl_extensions[i].version_minor))) ) {
+ SET_BIT( server_support, known_gl_extensions[i].bit );
+ }
+ }
+
+
+ /* An extension is supported if the client-side (i.e., libGL) supports
+ * it and the server supports it or the client-side library supports it
+ * and it only needs client-side support.
+ */
+
+ for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
+ usable[i] = (client_gl_support[i] & client_gl_only[i])
+ | (client_gl_support[i] & server_support[i]);
+ }
+
+ gc->extensions = (unsigned char *)
+ __glXGetStringFromTable( known_gl_extensions, usable );
+}
+
+
+/**
+ * Calculates the maximum core GL version that can be supported for indirect
+ * rendering.
+ */
+void
+__glXGetGLVersion( int * major_version, int * minor_version )
+{
+ __glXExtensionsCtr();
+ *major_version = gl_major;
+ *minor_version = gl_minor;
+}
+
+
+/**
+ * Get a string representing the set of extensions supported by the client
+ * library. This is currently only used to send the list of extensions
+ * supported by the client to the server.
+ */
+char *
+__glXGetClientGLExtensionString( void )
+{
+ __glXExtensionsCtr();
+ return __glXGetStringFromTable( known_gl_extensions, client_gl_support );
+}
diff --git a/src/glx/x11/glxextensions.h b/src/glx/x11/glxextensions.h
new file mode 100644
index 0000000000..812e1caec4
--- /dev/null
+++ b/src/glx/x11/glxextensions.h
@@ -0,0 +1,253 @@
+/*
+ * (C) Copyright IBM Corporation 2002, 2004
+ * All Rights Reserved.
+ *
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS 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 glxextensions.h
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+/* $XFree86: xc/lib/GL/glx/glxextensions.h,v 1.2tsi Exp $ */
+
+#ifndef GLX_GLXEXTENSIONS_H
+#define GLX_GLXEXTENSIONS_H
+
+enum {
+ ARB_get_proc_address_bit = 0,
+ ARB_multisample_bit,
+ ARB_render_texture_bit,
+ ATI_pixel_format_float_bit,
+ EXT_visual_info_bit,
+ EXT_visual_rating_bit,
+ EXT_import_context_bit,
+ MESA_agp_offset_bit,
+ MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
+ MESA_copy_sub_buffer_bit,
+ MESA_depth_float_bit,
+ MESA_pixmap_colormap_bit,
+ MESA_release_buffers_bit,
+ MESA_set_3dfx_mode_bit,
+ MESA_swap_control_bit,
+ MESA_swap_frame_usage_bit,
+ NV_float_buffer_bit,
+ NV_render_depth_texture_bit,
+ NV_render_texture_rectangle_bit,
+ NV_vertex_array_range_bit,
+ OML_swap_method_bit,
+ OML_sync_control_bit,
+ SGI_cushion_bit,
+ SGI_make_current_read_bit,
+ SGI_swap_control_bit,
+ SGI_video_sync_bit,
+ SGIS_blended_overlay_bit,
+ SGIS_color_range_bit,
+ SGIS_multisample_bit,
+ SGIX_dm_buffer_bit,
+ SGIX_fbconfig_bit,
+ SGIX_pbuffer_bit,
+ SGIX_swap_barrier_bit,
+ SGIX_swap_group_bit,
+ SGIX_video_resize_bit,
+ SGIX_video_source_bit,
+ SGIX_visual_select_group_bit,
+ SUN_get_transparent_index_bit
+};
+
+enum {
+ GL_ARB_depth_texture_bit = 0,
+ GL_ARB_fragment_program_bit,
+ GL_ARB_imaging_bit,
+ GL_ARB_multisample_bit,
+ GL_ARB_multitexture_bit,
+ GL_ARB_occlusion_query_bit,
+ GL_ARB_point_parameters_bit,
+ GL_ARB_point_sprite_bit,
+ GL_ARB_shadow_bit,
+ GL_ARB_shadow_ambient_bit,
+ GL_ARB_texture_border_clamp_bit,
+ GL_ARB_texture_cube_map_bit,
+ GL_ARB_texture_compression_bit,
+ GL_ARB_texture_env_add_bit,
+ GL_ARB_texture_env_combine_bit,
+ GL_ARB_texture_env_crossbar_bit,
+ GL_ARB_texture_env_dot3_bit,
+ GL_ARB_texture_mirrored_repeat_bit,
+ GL_ARB_texture_non_power_of_two_bit,
+ GL_ARB_transpose_matrix_bit,
+ GL_ARB_vertex_buffer_object_bit,
+ GL_ARB_vertex_program_bit,
+ GL_ARB_window_pos_bit,
+ GL_EXT_abgr_bit,
+ GL_EXT_bgra_bit,
+ GL_EXT_blend_color_bit,
+ GL_EXT_blend_equation_separate_bit,
+ GL_EXT_blend_func_separate_bit,
+ GL_EXT_blend_logic_op_bit,
+ GL_EXT_blend_minmax_bit,
+ GL_EXT_blend_subtract_bit,
+ GL_EXT_clip_volume_hint_bit,
+ GL_EXT_compiled_vertex_array_bit,
+ GL_EXT_convolution_bit,
+ GL_EXT_copy_texture_bit,
+ GL_EXT_cull_vertex_bit,
+ GL_EXT_depth_bounds_test_bit,
+ GL_EXT_draw_range_elements_bit,
+ GL_EXT_fog_coord_bit,
+ GL_EXT_multi_draw_arrays_bit,
+ GL_EXT_packed_pixels_bit,
+ GL_EXT_paletted_texture_bit,
+ GL_EXT_pixel_buffer_object_bit,
+ GL_EXT_polygon_offset_bit,
+ GL_EXT_rescale_normal_bit,
+ GL_EXT_secondary_color_bit,
+ GL_EXT_separate_specular_color_bit,
+ GL_EXT_shadow_funcs_bit,
+ GL_EXT_shared_texture_palette_bit,
+ GL_EXT_stencil_two_side_bit,
+ GL_EXT_stencil_wrap_bit,
+ GL_EXT_subtexture_bit,
+ GL_EXT_texture_bit,
+ GL_EXT_texture3D_bit,
+ GL_EXT_texture_compression_s3tc_bit,
+ GL_EXT_texture_edge_clamp_bit,
+ GL_EXT_texture_env_combine_bit,
+ GL_EXT_texture_env_dot3_bit,
+ GL_EXT_texture_filter_anisotropic_bit,
+ GL_EXT_texture_lod_bit,
+ GL_EXT_texture_lod_bias_bit,
+ GL_EXT_texture_mirror_clamp_bit,
+ GL_EXT_texture_object_bit,
+ GL_EXT_texture_rectangle_bit,
+ GL_EXT_vertex_array_bit,
+ GL_3DFX_texture_compression_FXT1_bit,
+ GL_APPLE_packed_pixels_bit,
+ GL_APPLE_ycbcr_422_bit,
+ GL_ATI_texture_env_combine3_bit,
+ GL_ATI_texture_float_bit,
+ GL_ATI_texture_mirror_once_bit,
+ GL_HP_convolution_border_modes_bit,
+ GL_HP_occlusion_test_bit,
+ GL_IBM_cull_vertex_bit,
+ GL_IBM_pixel_filter_hint_bit,
+ GL_IBM_rasterpos_clip_bit,
+ GL_IBM_texture_clamp_nodraw_bit,
+ GL_INGR_interlace_read_bit,
+ GL_MESA_pack_invert_bit,
+ GL_MESA_ycbcr_texture_bit,
+ GL_NV_blend_square_bit,
+ GL_NV_copy_depth_to_color_bit,
+ GL_NV_depth_clamp_bit,
+ GL_NV_fog_distance_bit,
+ GL_NV_light_max_exponent_bit,
+ GL_NV_multisample_filter_hint_bit,
+ GL_NV_point_sprite_bit,
+ GL_NV_texgen_reflection_bit,
+ GL_NV_texture_compression_vtc_bit,
+ GL_NV_texture_env_combine4_bit,
+ GL_SGIS_generate_mipmap_bit,
+ GL_SGIS_multisample_bit,
+ GL_SGIS_texture_lod_bit,
+ GL_SGIX_blend_alpha_minmax_bit,
+ GL_SGIX_clipmap_bit,
+ GL_SGIX_depth_texture_bit,
+ GL_SGIX_fog_offset_bit,
+ GL_SGIX_shadow_bit,
+ GL_SGIX_texture_coordinate_clamp_bit,
+ GL_SGIX_texture_lod_bias_bit,
+ GL_SGIX_texture_range_bit,
+ GL_SGIX_texture_scale_bias_bit,
+ GL_SGIX_vertex_preclip_bit,
+ GL_SGIX_vertex_preclip_hint_bit,
+ GL_SGIX_ycrcb_bit,
+ GL_SUN_convolution_border_modes_bit,
+ GL_SUN_slice_accum_bit,
+
+ /* This *MUST* go here. If it gets put after the duplicate values it will
+ * get the value after the last duplicate.
+ */
+ __NUM_GL_EXTS,
+
+
+ /* Alias extension bits. These extensions exist in either vendor-specific
+ * or EXT form and were later promoted to either EXT or ARB form. In all
+ * cases, the meaning is *exactly* the same. That's why
+ * EXT_texture_env_combine is *NOT* an alias of ARB_texture_env_combine and
+ * EXT_texture_env_dot3 is *NOT* an alias of ARB_texture_env_dot3. Be
+ * careful! When in doubt, src/mesa/main/extensions.c in the Mesa tree
+ * is a great reference.
+ */
+
+ GL_ATI_blend_equation_separate_bit = GL_EXT_blend_equation_separate_bit,
+ GL_ATIX_texture_env_combine3_bit = GL_ATI_texture_env_combine3_bit,
+ GL_EXT_point_parameters_bit = GL_ARB_point_parameters_bit,
+ GL_EXT_texture_env_add_bit = GL_ARB_texture_env_add_bit,
+ GL_IBM_texture_mirrored_repeat_bit = GL_ARB_texture_mirrored_repeat_bit,
+ GL_INGR_blend_func_separate_bit = GL_EXT_blend_func_separate_bit,
+ GL_MESA_window_pos_bit = GL_ARB_window_pos_bit,
+ GL_NV_texture_rectangle_bit = GL_EXT_texture_rectangle_bit,
+ GL_SGIS_texture_border_clamp_bit = GL_ARB_texture_border_clamp_bit,
+ GL_SGIS_texture_edge_clamp_bit = GL_EXT_texture_edge_clamp_bit,
+ GL_SGIX_shadow_ambient_bit = GL_ARB_shadow_ambient_bit,
+ GL_SUN_multi_draw_arrays_bit = GL_EXT_multi_draw_arrays_bit
+};
+
+extern GLboolean __glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit );
+extern const char * __glXGetClientExtensions( void );
+extern void __glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
+ GLboolean display_is_direct_capable, int server_minor_version );
+extern void __glXScrEnableExtension( __GLXscreenConfigs *psc, const char * name );
+extern void __glXCalculateUsableGLExtensions( __GLXcontext * gc,
+ const char * server_string, int major_version, int minor_version );
+extern void __glXGetGLVersion( int * major_version, int * minor_version );
+extern char * __glXGetClientGLExtensionString( void );
+
+/* Source-level backwards compatibility with old drivers. They won't
+ * find the respective functions, though.
+ */
+typedef void (* PFNGLXENABLEEXTENSIONPROC) ( const char * name,
+ GLboolean force_client );
+typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name );
+
+/* GLX_ALIAS should be used for functions with a non-void return type.
+ GLX_ALIAS_VOID is for functions with a void return type. */
+#ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func)
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func)
+#else
+# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
+ return_type GLX_PREFIX( real_func ) proto_args \
+ __attribute__ ((alias( # aliased_func ) ));
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
+ GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
+# else
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
+ return_type GLX_PREFIX( real_func ) proto_args \
+ { return aliased_func args ; }
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
+ void GLX_PREFIX( real_func ) proto_args \
+ { aliased_func args ; }
+# endif /* __GNUC__ */
+#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */
+
+#endif /* GLX_GLXEXTENSIONS_H */
diff --git a/src/glx/x11/indirect.h b/src/glx/x11/indirect.h
new file mode 100644
index 0000000000..4982f46189
--- /dev/null
+++ b/src/glx/x11/indirect.h
@@ -0,0 +1,647 @@
+/* $XFree86: xc/lib/GL/glx/indirect.h,v 1.5 2003/09/28 20:15:03 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#if !defined( _INDIRECT_H_ ) || defined( GENERATE_GLX_PROTOCOL_FUNCTIONS )
+
+# if !defined( _INDIRECT_H_ )
+# if defined( GENERATE_GLX_PROTOCOL_FUNCTIONS )
+# error "indirect.h must be included once without GENERATE_GLX_PROTOCOL_FUNCTIONS defined!"
+# endif
+
+# define _INDIRECT_H_
+# include "indirect_wrap.h"
+
+# define glxproto_void(name, rop) \
+ extern void __indirect_gl ## name ( void );
+# define glxproto_Cv(name, rop, type, count) \
+ extern void __indirect_gl ## name (const type * v);
+# define glxproto_Cv_transpose(name, rop, type, w) \
+ extern void __indirect_gl ## name (const type * v);
+# define glxproto_1s(name, rop, type) \
+ extern void __indirect_gl ## name (type v1);
+# define glxproto_2s(name, rop, type) \
+ extern void __indirect_gl ## name (type v1, type v2);
+# define glxproto_3s(name, rop, type) \
+ extern void __indirect_gl ## name (type v1, type v2, type v3);
+# define glxproto_4s(name, rop, type) \
+ extern void __indirect_gl ## name (type v1, type v2, type v3, type v4);
+# define glxproto_6s(name, rop, type) \
+ void __indirect_gl ## name (type v1, type v2, type v3, type v4, type v5, type v6);
+# define glxproto_enum1_1s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1);
+# define glxproto_enum1_1v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v);
+# define glxproto_enum1_2s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1, type v2);
+# define glxproto_enum1_2v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v);
+# define glxproto_enum1_3s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1, type v2, type v3);
+# define glxproto_enum1_3v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v);
+# define glxproto_enum1_4s(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, type v1, type v2, type v3, type v4);
+# define glxproto_enum1_4v(name, rop, type) \
+ void __indirect_gl ## name (GLenum e, const type * v);
+# define glxproto_enum1_Vv(name, rop, type) \
+ void __indirect_gl ## name (GLenum pname, const type * v);
+# define glxproto_enum2_1s(name, rop, type) \
+ void __indirect_gl ## name (GLenum target, GLenum pname, type v1);
+#define glxproto_enum2_Vv(name, rop, type) \
+ void __indirect_gl ## name (GLenum target, GLenum pname, const type * v);
+
+# endif /* !defined( _INDIRECT_H_ ) */
+
+#define glxproto_1(name, rop, type) \
+ glxproto_1s(name, rop, type) \
+ glxproto_Cv(name ## v, rop, type, 1)
+
+#define glxvendr_1(name, rop, type, VEN) \
+ glxproto_1s(name ## VEN, rop, type) \
+ glxproto_Cv(name ## v ## VEN, rop, type, 1)
+
+#define glxproto_2(name, rop, type) \
+ glxproto_2s(name, rop, type) \
+ glxproto_Cv(name ## v, rop, type, 2)
+
+#define glxvendr_2(name, rop, type, VEN) \
+ glxproto_2s(name ## VEN, rop, type) \
+ glxproto_Cv(name ## v ## VEN, rop, type, 2)
+
+#define glxproto_3(name, rop, type) \
+ glxproto_3s(name, rop, type) \
+ glxproto_Cv(name ## v, rop, type, 3)
+
+#define glxvendr_3(name, rop, type, VEN) \
+ glxproto_3s(name ## VEN, rop, type) \
+ glxproto_Cv(name ## v ## VEN, rop, type, 3)
+
+#define glxproto_4(name, rop, type) \
+ glxproto_4s(name, rop, type) \
+ glxproto_Cv(name ## v, rop, type, 4)
+
+#define glxproto_enum1_1(name, rop, type) \
+ glxproto_enum1_1s(name, rop, type) \
+ glxproto_enum1_1v(name ## v, rop, type)
+
+#define glxvendr_enum1_1(name, rop, type, VEN) \
+ glxproto_enum1_1s(name ## VEN, rop, type) \
+ glxproto_enum1_1v(name ## v ## VEN, rop, type)
+
+#define glxproto_enum1_2(name, rop, type) \
+ glxproto_enum1_2s(name, rop, type) \
+ glxproto_enum1_2v(name ## v, rop, type)
+
+#define glxvendr_enum1_2(name, rop, type, VEN) \
+ glxproto_enum1_2s(name ## VEN, rop, type) \
+ glxproto_enum1_2v(name ## v ## VEN, rop, type)
+
+#define glxproto_enum1_3(name, rop, type) \
+ glxproto_enum1_3s(name, rop, type) \
+ glxproto_enum1_3v(name ## v, rop, type)
+
+#define glxvendr_enum1_3(name, rop, type, VEN) \
+ glxproto_enum1_3s(name ## VEN, rop, type) \
+ glxproto_enum1_3v(name ## v ## VEN, rop, type)
+
+#define glxproto_enum1_4(name, rop, type) \
+ glxproto_enum1_4s(name, rop, type) \
+ glxproto_enum1_4v(name ## v, rop, type)
+
+#define glxvendr_enum1_4(name, rop, type, VEN) \
+ glxproto_enum1_4s(name ## VEN, rop, type) \
+ glxproto_enum1_4v(name ## v ## VEN, rop, type)
+
+#define glxproto_enum1_V(name, rop, type) \
+ glxproto_enum1_1s(name, rop, type) \
+ glxproto_enum1_Vv(name ## v, rop ## v, type)
+
+#define glxvendr_enum1_V(name, rop, type, VEN) \
+ glxproto_enum1_1s(name ## VEN, rop ## VEN, type) \
+ glxproto_enum1_Vv(name ## v ## VEN, rop ## v ## VEN, type)
+
+#define glxproto_enum2_V(name, rop, type) \
+ glxproto_enum2_1s(name, rop, type) \
+ glxproto_enum2_Vv(name ## v, rop ## v, type)
+
+#define glxvendr_enum2_V(name, rop, type, VEN) \
+ glxproto_enum2_1s(name ## VEN, rop ## VEN, type) \
+ glxproto_enum2_Vv(name ## v ## VEN, rop ## v ## VEN, type)
+
+glxproto_1s(CallList, X_GLrop_CallList, GLuint)
+glxproto_1s(ListBase, X_GLrop_ListBase, GLuint)
+glxproto_1s(Begin, X_GLrop_Begin, GLenum)
+
+glxproto_3(Color3b, X_GLrop_Color3bv, GLbyte)
+glxproto_3(Color3s, X_GLrop_Color3sv, GLshort)
+glxproto_3(Color3i, X_GLrop_Color3iv, GLint)
+glxproto_3(Color3ub, X_GLrop_Color3ubv, GLubyte)
+glxproto_3(Color3us, X_GLrop_Color3usv, GLushort)
+glxproto_3(Color3ui, X_GLrop_Color3uiv, GLuint)
+glxproto_3(Color3f, X_GLrop_Color3fv, GLfloat)
+glxproto_3(Color3d, X_GLrop_Color3dv, GLdouble)
+
+glxproto_4(Color4b, X_GLrop_Color4bv, GLbyte)
+glxproto_4(Color4s, X_GLrop_Color4sv, GLshort)
+glxproto_4(Color4i, X_GLrop_Color4iv, GLint)
+glxproto_4(Color4ub, X_GLrop_Color4ubv, GLubyte)
+glxproto_4(Color4us, X_GLrop_Color4usv, GLushort)
+glxproto_4(Color4ui, X_GLrop_Color4uiv, GLuint)
+glxproto_4(Color4f, X_GLrop_Color4fv, GLfloat)
+glxproto_4(Color4d, X_GLrop_Color4dv, GLdouble)
+
+glxproto_1(FogCoordf, X_GLrop_FogCoordfv, GLfloat)
+glxproto_1(FogCoordd, X_GLrop_FogCoorddv, GLdouble)
+
+glxproto_3(SecondaryColor3b, X_GLrop_SecondaryColor3bv, GLbyte)
+glxproto_3(SecondaryColor3s, X_GLrop_SecondaryColor3sv, GLshort)
+glxproto_3(SecondaryColor3i, X_GLrop_SecondaryColor3iv, GLint)
+glxproto_3(SecondaryColor3ub, X_GLrop_SecondaryColor3ubv, GLubyte)
+glxproto_3(SecondaryColor3us, X_GLrop_SecondaryColor3usv, GLushort)
+glxproto_3(SecondaryColor3ui, X_GLrop_SecondaryColor3uiv, GLuint)
+glxproto_3(SecondaryColor3f, X_GLrop_SecondaryColor3fv, GLfloat)
+glxproto_3(SecondaryColor3d, X_GLrop_SecondaryColor3dv, GLdouble)
+
+glxproto_1(EdgeFlag, X_GLrop_EdgeFlagv, GLboolean)
+
+glxproto_1(Indexd, X_GLrop_Indexdv, GLdouble)
+glxproto_1(Indexf, X_GLrop_Indexfv, GLfloat)
+glxproto_1(Indexi, X_GLrop_Indexiv, GLint)
+glxproto_1(Indexs, X_GLrop_Indexsv, GLshort)
+glxproto_1(Indexub, X_GLrop_Indexubv, GLubyte)
+
+glxproto_void(End, X_GLrop_End)
+
+glxproto_3(Normal3b, X_GLrop_Normal3bv, GLbyte)
+glxproto_3(Normal3s, X_GLrop_Normal3sv, GLshort)
+glxproto_3(Normal3i, X_GLrop_Normal3iv, GLint)
+glxproto_3(Normal3f, X_GLrop_Normal3fv, GLfloat)
+glxproto_3(Normal3d, X_GLrop_Normal3dv, GLdouble)
+
+glxproto_2(RasterPos2s, X_GLrop_RasterPos2sv, GLshort)
+glxproto_2(RasterPos2i, X_GLrop_RasterPos2iv, GLint)
+glxproto_2(RasterPos2f, X_GLrop_RasterPos2fv, GLfloat)
+glxproto_2(RasterPos2d, X_GLrop_RasterPos2dv, GLdouble)
+glxproto_3(RasterPos3s, X_GLrop_RasterPos3sv, GLshort)
+glxproto_3(RasterPos3i, X_GLrop_RasterPos3iv, GLint)
+glxproto_3(RasterPos3f, X_GLrop_RasterPos3fv, GLfloat)
+glxproto_3(RasterPos3d, X_GLrop_RasterPos3dv, GLdouble)
+glxproto_4(RasterPos4s, X_GLrop_RasterPos4sv, GLshort)
+glxproto_4(RasterPos4i, X_GLrop_RasterPos4iv, GLint)
+glxproto_4(RasterPos4f, X_GLrop_RasterPos4fv, GLfloat)
+glxproto_4(RasterPos4d, X_GLrop_RasterPos4dv, GLdouble)
+
+glxproto_1(TexCoord1s, X_GLrop_TexCoord1sv, GLshort)
+glxproto_1(TexCoord1i, X_GLrop_TexCoord1iv, GLint)
+glxproto_1(TexCoord1f, X_GLrop_TexCoord1fv, GLfloat)
+glxproto_1(TexCoord1d, X_GLrop_TexCoord1dv, GLdouble)
+glxproto_2(TexCoord2s, X_GLrop_TexCoord2sv, GLshort)
+glxproto_2(TexCoord2i, X_GLrop_TexCoord2iv, GLint)
+glxproto_2(TexCoord2f, X_GLrop_TexCoord2fv, GLfloat)
+glxproto_2(TexCoord2d, X_GLrop_TexCoord2dv, GLdouble)
+glxproto_3(TexCoord3s, X_GLrop_TexCoord3sv, GLshort)
+glxproto_3(TexCoord3i, X_GLrop_TexCoord3iv, GLint)
+glxproto_3(TexCoord3f, X_GLrop_TexCoord3fv, GLfloat)
+glxproto_3(TexCoord3d, X_GLrop_TexCoord3dv, GLdouble)
+glxproto_4(TexCoord4s, X_GLrop_TexCoord4sv, GLshort)
+glxproto_4(TexCoord4i, X_GLrop_TexCoord4iv, GLint)
+glxproto_4(TexCoord4f, X_GLrop_TexCoord4fv, GLfloat)
+glxproto_4(TexCoord4d, X_GLrop_TexCoord4dv, GLdouble)
+
+glxproto_2(Vertex2s, X_GLrop_Vertex2sv, GLshort)
+glxproto_2(Vertex2i, X_GLrop_Vertex2iv, GLint)
+glxproto_2(Vertex2f, X_GLrop_Vertex2fv, GLfloat)
+glxproto_2(Vertex2d, X_GLrop_Vertex2dv, GLdouble)
+glxproto_3(Vertex3s, X_GLrop_Vertex3sv, GLshort)
+glxproto_3(Vertex3i, X_GLrop_Vertex3iv, GLint)
+glxproto_3(Vertex3f, X_GLrop_Vertex3fv, GLfloat)
+glxproto_3(Vertex3d, X_GLrop_Vertex3dv, GLdouble)
+glxproto_4(Vertex4s, X_GLrop_Vertex4sv, GLshort)
+glxproto_4(Vertex4i, X_GLrop_Vertex4iv, GLint)
+glxproto_4(Vertex4f, X_GLrop_Vertex4fv, GLfloat)
+glxproto_4(Vertex4d, X_GLrop_Vertex4dv, GLdouble)
+
+glxproto_enum1_4v(ClipPlane, X_GLrop_ClipPlane, GLdouble)
+
+glxproto_2s(ColorMaterial, X_GLrop_ColorMaterial, GLenum)
+
+glxproto_1s(CullFace, X_GLrop_CullFace, GLenum)
+
+glxproto_enum1_V(Fogi, X_GLrop_Fogi, GLint)
+glxproto_enum1_V(Fogf, X_GLrop_Fogf, GLfloat)
+
+glxproto_1s(FrontFace, X_GLrop_FrontFace, GLenum)
+glxproto_2s(Hint, X_GLrop_Hint, GLenum)
+
+glxproto_enum2_V(Lighti, X_GLrop_Lighti, GLint)
+glxproto_enum2_V(Lightf, X_GLrop_Lightf, GLfloat)
+
+glxproto_enum1_V(LightModeli, X_GLrop_LightModeli, GLint)
+glxproto_enum1_V(LightModelf, X_GLrop_LightModelf, GLfloat)
+
+glxproto_1s(LineWidth, X_GLrop_LineWidth, GLfloat)
+
+glxproto_enum2_V(Materiali, X_GLrop_Materiali, GLint)
+glxproto_enum2_V(Materialf, X_GLrop_Materialf, GLfloat)
+
+glxproto_1s(PointSize, X_GLrop_PointSize, GLfloat)
+
+glxproto_2s(PolygonMode, X_GLrop_PolygonMode, GLenum)
+
+glxproto_1s(ShadeModel, X_GLrop_ShadeModel, GLenum)
+
+glxproto_enum2_V(TexParameteri, X_GLrop_TexParameteri, GLint)
+glxproto_enum2_V(TexParameterf, X_GLrop_TexParameterf, GLfloat)
+
+glxproto_enum2_V(TexEnvi, X_GLrop_TexEnvi, GLint)
+glxproto_enum2_V(TexEnvf, X_GLrop_TexEnvf, GLfloat)
+glxproto_enum2_V(TexGeni, X_GLrop_TexGeni, GLint)
+glxproto_enum2_V(TexGenf, X_GLrop_TexGenf, GLfloat)
+glxproto_enum2_V(TexGend, X_GLrop_TexGend, GLdouble)
+
+glxproto_void(InitNames, X_GLrop_InitNames)
+glxproto_1s(LoadName, X_GLrop_LoadName, GLuint)
+glxproto_1s(PassThrough, X_GLrop_PassThrough, GLfloat)
+glxproto_void(PopName, X_GLrop_PopName)
+glxproto_1s(PushName, X_GLrop_PushName, GLuint)
+
+glxproto_1s(DrawBuffer, X_GLrop_DrawBuffer, GLenum)
+glxproto_1s(Clear, X_GLrop_Clear, GLbitfield)
+
+glxproto_4s(ClearAccum, X_GLrop_ClearAccum, GLfloat)
+glxproto_1s(ClearIndex, X_GLrop_ClearIndex, GLfloat)
+glxproto_4s(ClearColor, X_GLrop_ClearColor, GLclampf)
+glxproto_1s(ClearStencil, X_GLrop_ClearStencil, GLint)
+glxproto_1s(ClearDepth, X_GLrop_ClearDepth, GLclampd)
+
+glxproto_1s(StencilMask, X_GLrop_StencilMask, GLuint)
+glxproto_4s(ColorMask, X_GLrop_ColorMask, GLboolean)
+glxproto_1s(DepthMask, X_GLrop_DepthMask, GLboolean)
+glxproto_1s(IndexMask, X_GLrop_IndexMask, GLuint)
+
+glxproto_enum1_1s(Accum, X_GLrop_Accum, GLfloat)
+
+glxproto_void(PopAttrib, X_GLrop_PopAttrib)
+glxproto_1s(PushAttrib, X_GLrop_PushAttrib, GLbitfield)
+
+glxproto_1(EvalCoord1f, X_GLrop_EvalCoord1fv, GLfloat)
+glxproto_1(EvalCoord1d, X_GLrop_EvalCoord1dv, GLdouble)
+glxproto_2(EvalCoord2f, X_GLrop_EvalCoord2fv, GLfloat)
+glxproto_2(EvalCoord2d, X_GLrop_EvalCoord2dv, GLdouble)
+glxproto_enum1_2s(EvalMesh1, X_GLrop_EvalMesh1, GLint)
+glxproto_enum1_4s(EvalMesh2, X_GLrop_EvalMesh2, GLint)
+glxproto_1s(EvalPoint1, X_GLrop_EvalPoint1, GLint)
+glxproto_2s(EvalPoint2, X_GLrop_EvalPoint2, GLint)
+
+glxproto_enum1_1s(AlphaFunc, X_GLrop_AlphaFunc, GLclampf)
+
+glxproto_2s(BlendFunc, X_GLrop_BlendFunc, GLenum)
+glxproto_4s(BlendFuncSeparate, X_GLrop_BlendFuncSeparate, GLenum)
+
+glxproto_1s(LogicOp, X_GLrop_LogicOp, GLenum)
+
+glxproto_3s(StencilOp, X_GLrop_StencilOp, GLenum)
+glxproto_1s(DepthFunc, X_GLrop_DepthFunc, GLenum)
+
+glxproto_2s(PixelZoom, X_GLrop_PixelZoom, GLfloat)
+
+glxproto_enum1_1s(PixelTransferf, X_GLrop_PixelTransferf, GLfloat)
+glxproto_enum1_1s(PixelTransferi, X_GLrop_PixelTransferi, GLint)
+
+glxproto_1s(ReadBuffer, X_GLrop_ReadBuffer, GLenum)
+
+glxproto_2s(DepthRange, X_GLrop_DepthRange, GLclampd)
+
+glxproto_6s(Frustum, X_GLrop_Frustum, GLdouble)
+
+glxproto_void(LoadIdentity, X_GLrop_LoadIdentity)
+glxproto_1s(MatrixMode, X_GLrop_MatrixMode, GLenum)
+glxproto_Cv(LoadMatrixf, X_GLrop_LoadMatrixf, GLfloat, 16)
+glxproto_Cv(MultMatrixf, X_GLrop_MultMatrixf, GLfloat, 16)
+glxproto_Cv(LoadMatrixd, X_GLrop_LoadMatrixd, GLdouble, 16)
+glxproto_Cv(MultMatrixd, X_GLrop_MultMatrixd, GLdouble, 16)
+glxproto_Cv_transpose(LoadTransposeMatrixfARB, X_GLrop_LoadMatrixf, GLfloat, 4)
+glxproto_Cv_transpose(MultTransposeMatrixfARB, X_GLrop_MultMatrixf, GLfloat, 4)
+glxproto_Cv_transpose(LoadTransposeMatrixdARB, X_GLrop_LoadMatrixd, GLdouble, 4)
+glxproto_Cv_transpose(MultTransposeMatrixdARB, X_GLrop_MultMatrixd, GLdouble, 4)
+
+glxproto_6s(Ortho, X_GLrop_Ortho, GLdouble)
+
+glxproto_void(PushMatrix, X_GLrop_PushMatrix)
+glxproto_void(PopMatrix, X_GLrop_PopMatrix)
+
+glxproto_4s(Rotatef, X_GLrop_Rotatef, GLfloat)
+glxproto_3s(Scalef, X_GLrop_Scalef, GLfloat)
+glxproto_3s(Translatef, X_GLrop_Translatef, GLfloat)
+glxproto_4s(Rotated, X_GLrop_Rotated, GLdouble)
+glxproto_3s(Scaled, X_GLrop_Scaled, GLdouble)
+glxproto_3s(Translated, X_GLrop_Translated, GLdouble)
+
+glxproto_2s(PolygonOffset, X_GLrop_PolygonOffset, GLfloat)
+
+glxproto_enum1_1s(BindTexture, X_GLrop_BindTexture, GLuint)
+
+glxproto_4s(BlendColor, X_GLrop_BlendColor, GLclampf)
+glxproto_1s(BlendEquation, X_GLrop_BlendEquation, GLenum)
+
+glxproto_enum2_Vv(ColorTableParameteriv, X_GLrop_ColorTableParameteriv, GLint)
+glxproto_enum2_Vv(ColorTableParameterfv, X_GLrop_ColorTableParameterfv, GLfloat)
+
+glxproto_enum2_V(ConvolutionParameteri, X_GLrop_ConvolutionParameteri, GLint)
+glxproto_enum2_V(ConvolutionParameterf, X_GLrop_ConvolutionParameterf, GLfloat)
+
+glxproto_enum2_1s(Minmax, X_GLrop_Minmax, GLboolean)
+
+glxproto_1s(ResetHistogram, X_GLrop_ResetHistogram, GLenum)
+glxproto_1s(ResetMinmax, X_GLrop_ResetMinmax, GLenum)
+
+glxproto_1s( ActiveTextureARB, X_GLrop_ActiveTextureARB, GLenum)
+glxvendr_enum1_1(MultiTexCoord1s, X_GLrop_MultiTexCoord1svARB, GLshort, ARB)
+glxvendr_enum1_1(MultiTexCoord1i, X_GLrop_MultiTexCoord1ivARB, GLint, ARB)
+glxvendr_enum1_1(MultiTexCoord1f, X_GLrop_MultiTexCoord1fvARB, GLfloat, ARB)
+glxvendr_enum1_1(MultiTexCoord1d, X_GLrop_MultiTexCoord1dvARB, GLdouble, ARB)
+glxvendr_enum1_2(MultiTexCoord2s, X_GLrop_MultiTexCoord2svARB, GLshort, ARB)
+glxvendr_enum1_2(MultiTexCoord2i, X_GLrop_MultiTexCoord2ivARB, GLint, ARB)
+glxvendr_enum1_2(MultiTexCoord2f, X_GLrop_MultiTexCoord2fvARB, GLfloat, ARB)
+glxvendr_enum1_2(MultiTexCoord2d, X_GLrop_MultiTexCoord2dvARB, GLdouble, ARB)
+glxvendr_enum1_3(MultiTexCoord3s, X_GLrop_MultiTexCoord3svARB, GLshort, ARB)
+glxvendr_enum1_3(MultiTexCoord3i, X_GLrop_MultiTexCoord3ivARB, GLint, ARB)
+glxvendr_enum1_3(MultiTexCoord3f, X_GLrop_MultiTexCoord3fvARB, GLfloat, ARB)
+glxvendr_enum1_3(MultiTexCoord3d, X_GLrop_MultiTexCoord3dvARB, GLdouble, ARB)
+glxvendr_enum1_4(MultiTexCoord4s, X_GLrop_MultiTexCoord4svARB, GLshort, ARB)
+glxvendr_enum1_4(MultiTexCoord4i, X_GLrop_MultiTexCoord4ivARB, GLint, ARB)
+glxvendr_enum1_4(MultiTexCoord4f, X_GLrop_MultiTexCoord4fvARB, GLfloat, ARB)
+glxvendr_enum1_4(MultiTexCoord4d, X_GLrop_MultiTexCoord4dvARB, GLdouble, ARB)
+
+glxvendr_enum1_V(PointParameterf, X_GLrop_PointParameterf, GLfloat, ARB)
+glxproto_enum1_V(PointParameteri, X_GLrop_PointParameteri, GLint)
+
+glxvendr_3(WindowPos3f, X_GLrop_WindowPos3fARB, GLfloat, ARB)
+
+glxproto_1s(ActiveStencilFaceEXT, X_GLrop_ActiveStencilFaceEXT, GLenum)
+
+glxproto_4s(Rects, X_GLrop_Rectsv, GLshort)
+glxproto_4s(Recti, X_GLrop_Rectiv, GLint)
+glxproto_4s(Rectf, X_GLrop_Rectfv, GLfloat)
+glxproto_4s(Rectd, X_GLrop_Rectdv, GLdouble)
+
+#if !defined( GENERATE_GLX_PROTOCOL_FUNCTIONS )
+GLboolean __indirect_glAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences);
+GLboolean __indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint *textures, GLboolean *residences);
+void __indirect_glArrayElement(GLint i);
+void __indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
+void __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid *lists);
+void __indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+void __indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table);
+void __indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+void __indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+void __indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+void __indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+void __indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+void __indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
+void __indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+void __indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+void __indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+void __indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+void __indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+void __indirect_glDeleteLists(GLuint list, GLsizei range);
+void __indirect_glDeleteTextures(GLsizei n, const GLuint *textures);
+void __indirect_glDeleteTexturesEXT(GLsizei n, const GLuint *textures);
+void __indirect_glDisable(GLenum cap);
+void __indirect_glDisableClientState(GLenum array);
+void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count);
+void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+void __indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+void __indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid *pointer);
+void __indirect_glEnable(GLenum cap);
+void __indirect_glEnableClientState(GLenum array);
+void __indirect_glEndList(void);
+void __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer);
+void __indirect_glFinish(void);
+void __indirect_glFlush(void);
+GLuint __indirect_glGenLists(GLsizei range);
+void __indirect_glGenTextures(GLsizei n, GLuint *textures);
+void __indirect_glGenTexturesEXT(GLsizei n, GLuint *textures);
+void __indirect_glGetBooleanv(GLenum val, GLboolean *b);
+void __indirect_glGetClipPlane(GLenum plane, GLdouble *equation);
+void __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid *table);
+void __indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params);
+void __indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, GLint *params);
+void __indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image);
+void __indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params);
+void __indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params);
+void __indirect_glGetDoublev(GLenum val, GLdouble *d);
+GLenum __indirect_glGetError(void);
+void __indirect_glGetFloatv(GLenum val, GLfloat *f);
+void __indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+void __indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params);
+void __indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, GLint *params);
+void __indirect_glGetIntegerv(GLenum val, GLint *i);
+void __indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat *params);
+void __indirect_glGetLightiv(GLenum light, GLenum pname, GLint *params);
+void __indirect_glGetMapdv(GLenum target, GLenum query, GLdouble *v);
+void __indirect_glGetMapfv(GLenum target, GLenum query, GLfloat *v);
+void __indirect_glGetMapiv(GLenum target, GLenum query, GLint *v);
+void __indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params);
+void __indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint *params);
+void __indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+void __indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params);
+void __indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params);
+void __indirect_glGetPixelMapfv(GLenum map, GLfloat *values);
+void __indirect_glGetPixelMapuiv(GLenum map, GLuint *values);
+void __indirect_glGetPixelMapusv(GLenum map, GLushort *values);
+void __indirect_glGetPointerv(GLenum pname, void **params);
+void __indirect_glGetPolygonStipple(GLubyte *mask);
+const GLubyte *__indirect_glGetString(GLenum name);
+void __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+void __indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params);
+void __indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint *params);
+void __indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble *params);
+void __indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params);
+void __indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint *params);
+void __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *texels);
+void __indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params);
+void __indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params);
+void __indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
+void __indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint *params);
+void __indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+void __indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
+void __indirect_glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
+GLboolean __indirect_glIsEnabled(GLenum cap);
+GLboolean __indirect_glIsList(GLuint list);
+GLboolean __indirect_glIsTexture(GLuint texture);
+GLboolean __indirect_glIsTextureEXT(GLuint texture);
+void __indirect_glLineStipple(GLint factor, GLushort pattern);
+void __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *pnts);
+void __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *pnts);
+void __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, GLint uord, GLdouble v1, GLdouble v2, GLint vstr, GLint vord, const GLdouble *pnts);
+void __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord, const GLfloat *pnts);
+void __indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2);
+void __indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2);
+void __indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
+void __indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
+void __indirect_glNewList(GLuint list, GLenum mode);
+void __indirect_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
+void __indirect_glPixelMapfv(GLenum map, GLint mapsize, const GLfloat *values);
+void __indirect_glPixelMapuiv(GLenum map, GLint mapsize, const GLuint *values);
+void __indirect_glPixelMapusv(GLenum map, GLint mapsize, const GLushort *values);
+void __indirect_glPixelStoref(GLenum pname, GLfloat param);
+void __indirect_glPixelStorei(GLenum pname, GLint param);
+void __indirect_glPolygonStipple(const GLubyte *mask);
+void __indirect_glPopClientAttrib(void);
+void __indirect_glPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities);
+void __indirect_glPushClientAttrib(GLuint mask);
+void __indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+void __indirect_glRectdv(const GLdouble *v1, const GLdouble *v2);
+void __indirect_glRectfv(const GLfloat *v1, const GLfloat *v2);
+void __indirect_glRectiv(const GLint *v1, const GLint *v2);
+void __indirect_glRectsv(const GLshort *v1, const GLshort *v2);
+GLint __indirect_glRenderMode(GLenum mode);
+void __indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
+void __indirect_glSelectBuffer(GLsizei numnames, GLuint *buffer);
+void __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+void __indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask);
+void __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+void __indirect_glTexImage1D(GLenum target, GLint level, GLint components, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glTexImage2D(GLenum target, GLint level, GLint components, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *image);
+void __indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+void __indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
+
+void __indirect_glClientActiveTextureARB(GLenum texture);
+
+void __indirect_glSampleCoverageARB( GLfloat value, GLboolean invert );
+
+void __indirect_glWindowPos2dARB(GLdouble x, GLdouble y);
+void __indirect_glWindowPos2iARB(GLint x, GLint y);
+void __indirect_glWindowPos2fARB(GLfloat x, GLfloat y);
+void __indirect_glWindowPos2sARB(GLshort x, GLshort y);
+void __indirect_glWindowPos2dvARB(const GLdouble * p);
+void __indirect_glWindowPos2fvARB(const GLfloat * p);
+void __indirect_glWindowPos2ivARB(const GLint * p);
+void __indirect_glWindowPos2svARB(const GLshort * p);
+void __indirect_glWindowPos3dARB(GLdouble x, GLdouble y, GLdouble z);
+void __indirect_glWindowPos3iARB(GLint x, GLint y, GLint z);
+void __indirect_glWindowPos3sARB(GLshort x, GLshort y, GLshort z);
+void __indirect_glWindowPos3dvARB(const GLdouble * p);
+void __indirect_glWindowPos3ivARB(const GLint * p);
+void __indirect_glWindowPos3svARB(const GLshort * p);
+
+void __indirect_glMultiDrawArrays(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+void __indirect_glMultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, const GLvoid ** indices, GLsizei primcount);
+
+void __indirect_glSampleMaskSGIS( GLfloat value, GLboolean invert );
+void __indirect_glSamplePatternSGIS( GLenum pass );
+
+/* ARB 12. GL_ARB_texture_compression / GL 1.3 */
+
+void __indirect_glGetCompressedTexImage( GLenum target, GLint level,
+ GLvoid * img );
+void __indirect_glCompressedTexImage1D( GLenum target, GLint level,
+ GLenum internalformat, GLsizei width,
+ GLint border, GLsizei image_size, const GLvoid *data );
+void __indirect_glCompressedTexImage2D( GLenum target, GLint level,
+ GLenum internalformat, GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size, const GLvoid *data );
+void __indirect_glCompressedTexImage3D( GLenum target, GLint level,
+ GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLsizei image_size, const GLvoid *data );
+void __indirect_glCompressedTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLsizei image_size, const GLvoid *data );
+void __indirect_glCompressedTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size, const GLvoid *data );
+void __indirect_glCompressedTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLsizei image_size, const GLvoid *data );
+
+/* 145. GL_EXT_secondary_color / GL 1.4 */
+
+void __indirect_glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *);
+
+/* 149. GL_EXT_fog_coord / GL 1.4 */
+
+void __indirect_glFogCoordPointer (GLenum, GLsizei, const GLvoid *);
+
+# undef glxproto_void
+# undef glxproto_Cv
+# undef glxproto_Cv_transpose
+# undef glxproto_1s
+# undef glxproto_2s
+# undef glxproto_3s
+# undef glxproto_4s
+# undef glxproto_6s
+# undef glxproto_enum1_1s
+# undef glxproto_enum1_1v
+# undef glxproto_enum1_2s
+# undef glxproto_enum1_2v
+# undef glxproto_enum1_3s
+# undef glxproto_enum1_3v
+# undef glxproto_enum1_4s
+# undef glxproto_enum1_4v
+# undef glxproto_enum1_Vv
+# undef glxproto_enum2_1s
+# undef glxproto_enum2_Vv
+# undef glxproto_1
+# undef glxvendr_1
+# undef glxproto_2
+# undef glxvendr_2
+# undef glxproto_3
+# undef glxvendr_3
+# undef glxproto_4
+# undef glxproto_enum1_1
+# undef glxvendr_enum1_1
+# undef glxproto_enum1_2
+# undef glxvendr_enum1_2
+# undef glxproto_enum1_3
+# undef glxvendr_enum1_3
+# undef glxproto_enum1_4
+# undef glxvendr_enum1_4
+# undef glxproto_enum1_V
+# undef glxvendr_enum1_V
+# undef glxproto_enum2_V
+# undef glxvendr_enum2_V
+#endif /* !defined( GENERATE_GLX_PROTOCOL_FUNCTIONS ) */
+
+#endif /* _INDIRECT_H_ */
diff --git a/src/glx/x11/indirect_init.c b/src/glx/x11/indirect_init.c
new file mode 100644
index 0000000000..b3d6c8343c
--- /dev/null
+++ b/src/glx/x11/indirect_init.c
@@ -0,0 +1,624 @@
+/* $XFree86: xc/lib/GL/glx/indirect_init.c,v 1.9 2004/01/28 18:11:41 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ */
+
+#include "indirect_init.h"
+#include "indirect.h"
+#include "glapi.h"
+
+
+/*
+** No-op function
+*/
+static int NoOp(void)
+{
+ return 0;
+}
+
+/**
+ * \name Vertex array pointer bridge functions
+ *
+ * When EXT_vertex_array was moved into the core GL spec, the \c count
+ * parameter was lost. This libGL really only wants to implement the GL 1.1
+ * version, but we need to support applications that were written to the old
+ * interface. These bridge functions are part of the glue that makes this
+ * happen.
+ */
+/*@{*/
+static void ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glColorPointer( size, type, stride, pointer );
+}
+
+static void EdgeFlagPointerEXT(GLsizei stride,
+ GLsizei count, const GLboolean * pointer )
+{
+ (void) count; __indirect_glEdgeFlagPointer( stride, pointer );
+}
+
+static void IndexPointerEXT(GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glIndexPointer( type, stride, pointer );
+}
+
+static void NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid * pointer )
+{
+ (void) count; __indirect_glNormalPointer( type, stride, pointer );
+}
+
+static void TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glTexCoordPointer( size, type, stride, pointer );
+}
+
+static void VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glVertexPointer( size, type, stride, pointer );
+}
+/*@}*/
+
+
+__GLapi *__glXNewIndirectAPI(void)
+{
+ __GLapi *glAPI;
+ GLuint entries;
+
+ entries = _glapi_get_dispatch_table_size();
+ glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *));
+
+ /* first, set all entries to point to no-op functions */
+ {
+ int i;
+ void **dispatch = (void **) glAPI;
+ for (i = 0; i < entries; i++) {
+ dispatch[i] = (void *) NoOp;
+ }
+ }
+
+ /* now, initialize the entries we understand */
+ glAPI->Accum = __indirect_glAccum;
+ glAPI->AlphaFunc = __indirect_glAlphaFunc;
+ glAPI->AreTexturesResident = __indirect_glAreTexturesResident;
+ glAPI->ArrayElement = __indirect_glArrayElement;
+ glAPI->Begin = __indirect_glBegin;
+ glAPI->BindTexture = __indirect_glBindTexture;
+ glAPI->Bitmap = __indirect_glBitmap;
+ glAPI->BlendFunc = __indirect_glBlendFunc;
+ glAPI->CallList = __indirect_glCallList;
+ glAPI->CallLists = __indirect_glCallLists;
+ glAPI->Clear = __indirect_glClear;
+ glAPI->ClearAccum = __indirect_glClearAccum;
+ glAPI->ClearColor = __indirect_glClearColor;
+ glAPI->ClearDepth = __indirect_glClearDepth;
+ glAPI->ClearIndex = __indirect_glClearIndex;
+ glAPI->ClearStencil = __indirect_glClearStencil;
+ glAPI->ClipPlane = __indirect_glClipPlane;
+ glAPI->Color3b = __indirect_glColor3b;
+ glAPI->Color3bv = __indirect_glColor3bv;
+ glAPI->Color3d = __indirect_glColor3d;
+ glAPI->Color3dv = __indirect_glColor3dv;
+ glAPI->Color3f = __indirect_glColor3f;
+ glAPI->Color3fv = __indirect_glColor3fv;
+ glAPI->Color3i = __indirect_glColor3i;
+ glAPI->Color3iv = __indirect_glColor3iv;
+ glAPI->Color3s = __indirect_glColor3s;
+ glAPI->Color3sv = __indirect_glColor3sv;
+ glAPI->Color3ub = __indirect_glColor3ub;
+ glAPI->Color3ubv = __indirect_glColor3ubv;
+ glAPI->Color3ui = __indirect_glColor3ui;
+ glAPI->Color3uiv = __indirect_glColor3uiv;
+ glAPI->Color3us = __indirect_glColor3us;
+ glAPI->Color3usv = __indirect_glColor3usv;
+ glAPI->Color4b = __indirect_glColor4b;
+ glAPI->Color4bv = __indirect_glColor4bv;
+ glAPI->Color4d = __indirect_glColor4d;
+ glAPI->Color4dv = __indirect_glColor4dv;
+ glAPI->Color4f = __indirect_glColor4f;
+ glAPI->Color4fv = __indirect_glColor4fv;
+ glAPI->Color4i = __indirect_glColor4i;
+ glAPI->Color4iv = __indirect_glColor4iv;
+ glAPI->Color4s = __indirect_glColor4s;
+ glAPI->Color4sv = __indirect_glColor4sv;
+ glAPI->Color4ub = __indirect_glColor4ub;
+ glAPI->Color4ubv = __indirect_glColor4ubv;
+ glAPI->Color4ui = __indirect_glColor4ui;
+ glAPI->Color4uiv = __indirect_glColor4uiv;
+ glAPI->Color4us = __indirect_glColor4us;
+ glAPI->Color4usv = __indirect_glColor4usv;
+ glAPI->ColorMask = __indirect_glColorMask;
+ glAPI->ColorMaterial = __indirect_glColorMaterial;
+ glAPI->ColorPointer = __indirect_glColorPointer;
+ glAPI->CopyPixels = __indirect_glCopyPixels;
+ glAPI->CopyTexImage1D = __indirect_glCopyTexImage1D;
+ glAPI->CopyTexImage2D = __indirect_glCopyTexImage2D;
+ glAPI->CopyTexSubImage1D = __indirect_glCopyTexSubImage1D;
+ glAPI->CopyTexSubImage2D = __indirect_glCopyTexSubImage2D;
+ glAPI->CullFace = __indirect_glCullFace;
+ glAPI->DeleteLists = __indirect_glDeleteLists;
+ glAPI->DeleteTextures = __indirect_glDeleteTextures;
+ glAPI->DepthFunc = __indirect_glDepthFunc;
+ glAPI->DepthMask = __indirect_glDepthMask;
+ glAPI->DepthRange = __indirect_glDepthRange;
+ glAPI->Disable = __indirect_glDisable;
+ glAPI->DisableClientState = __indirect_glDisableClientState;
+ glAPI->DrawArrays = __indirect_glDrawArrays;
+ glAPI->DrawBuffer = __indirect_glDrawBuffer;
+ glAPI->DrawElements = __indirect_glDrawElements;
+ glAPI->DrawPixels = __indirect_glDrawPixels;
+ glAPI->DrawRangeElements = __indirect_glDrawRangeElements;
+ glAPI->EdgeFlag = __indirect_glEdgeFlag;
+ glAPI->EdgeFlagPointer = __indirect_glEdgeFlagPointer;
+ glAPI->EdgeFlagv = __indirect_glEdgeFlagv;
+ glAPI->Enable = __indirect_glEnable;
+ glAPI->EnableClientState = __indirect_glEnableClientState;
+ glAPI->End = __indirect_glEnd;
+ glAPI->EndList = __indirect_glEndList;
+ glAPI->EvalCoord1d = __indirect_glEvalCoord1d;
+ glAPI->EvalCoord1dv = __indirect_glEvalCoord1dv;
+ glAPI->EvalCoord1f = __indirect_glEvalCoord1f;
+ glAPI->EvalCoord1fv = __indirect_glEvalCoord1fv;
+ glAPI->EvalCoord2d = __indirect_glEvalCoord2d;
+ glAPI->EvalCoord2dv = __indirect_glEvalCoord2dv;
+ glAPI->EvalCoord2f = __indirect_glEvalCoord2f;
+ glAPI->EvalCoord2fv = __indirect_glEvalCoord2fv;
+ glAPI->EvalMesh1 = __indirect_glEvalMesh1;
+ glAPI->EvalMesh2 = __indirect_glEvalMesh2;
+ glAPI->EvalPoint1 = __indirect_glEvalPoint1;
+ glAPI->EvalPoint2 = __indirect_glEvalPoint2;
+ glAPI->FeedbackBuffer = __indirect_glFeedbackBuffer;
+ glAPI->Finish = __indirect_glFinish;
+ glAPI->Flush = __indirect_glFlush;
+ glAPI->Fogf = __indirect_glFogf;
+ glAPI->Fogfv = __indirect_glFogfv;
+ glAPI->Fogi = __indirect_glFogi;
+ glAPI->Fogiv = __indirect_glFogiv;
+ glAPI->FrontFace = __indirect_glFrontFace;
+ glAPI->Frustum = __indirect_glFrustum;
+ glAPI->GenLists = __indirect_glGenLists;
+ glAPI->GenTextures = __indirect_glGenTextures;
+ glAPI->GetBooleanv = __indirect_glGetBooleanv;
+ glAPI->GetClipPlane = __indirect_glGetClipPlane;
+ glAPI->GetDoublev = __indirect_glGetDoublev;
+ glAPI->GetError = __indirect_glGetError;
+ glAPI->GetFloatv = __indirect_glGetFloatv;
+ glAPI->GetIntegerv = __indirect_glGetIntegerv;
+ glAPI->GetLightfv = __indirect_glGetLightfv;
+ glAPI->GetLightiv = __indirect_glGetLightiv;
+ glAPI->GetMapdv = __indirect_glGetMapdv;
+ glAPI->GetMapfv = __indirect_glGetMapfv;
+ glAPI->GetMapiv = __indirect_glGetMapiv;
+ glAPI->GetMaterialfv = __indirect_glGetMaterialfv;
+ glAPI->GetMaterialiv = __indirect_glGetMaterialiv;
+ glAPI->GetPixelMapfv = __indirect_glGetPixelMapfv;
+ glAPI->GetPixelMapuiv = __indirect_glGetPixelMapuiv;
+ glAPI->GetPixelMapusv = __indirect_glGetPixelMapusv;
+ glAPI->GetPointerv = __indirect_glGetPointerv;
+ glAPI->GetPolygonStipple = __indirect_glGetPolygonStipple;
+ glAPI->GetString = __indirect_glGetString;
+ glAPI->GetTexEnvfv = __indirect_glGetTexEnvfv;
+ glAPI->GetTexEnviv = __indirect_glGetTexEnviv;
+ glAPI->GetTexGendv = __indirect_glGetTexGendv;
+ glAPI->GetTexGenfv = __indirect_glGetTexGenfv;
+ glAPI->GetTexGeniv = __indirect_glGetTexGeniv;
+ glAPI->GetTexImage = __indirect_glGetTexImage;
+ glAPI->GetTexLevelParameterfv = __indirect_glGetTexLevelParameterfv;
+ glAPI->GetTexLevelParameteriv = __indirect_glGetTexLevelParameteriv;
+ glAPI->GetTexParameterfv = __indirect_glGetTexParameterfv;
+ glAPI->GetTexParameteriv = __indirect_glGetTexParameteriv;
+ glAPI->Hint = __indirect_glHint;
+ glAPI->IndexMask = __indirect_glIndexMask;
+ glAPI->IndexPointer = __indirect_glIndexPointer;
+ glAPI->Indexd = __indirect_glIndexd;
+ glAPI->Indexdv = __indirect_glIndexdv;
+ glAPI->Indexf = __indirect_glIndexf;
+ glAPI->Indexfv = __indirect_glIndexfv;
+ glAPI->Indexi = __indirect_glIndexi;
+ glAPI->Indexiv = __indirect_glIndexiv;
+ glAPI->Indexs = __indirect_glIndexs;
+ glAPI->Indexsv = __indirect_glIndexsv;
+ glAPI->Indexub = __indirect_glIndexub;
+ glAPI->Indexubv = __indirect_glIndexubv;
+ glAPI->InitNames = __indirect_glInitNames;
+ glAPI->InterleavedArrays = __indirect_glInterleavedArrays;
+ glAPI->IsEnabled = __indirect_glIsEnabled;
+ glAPI->IsList = __indirect_glIsList;
+ glAPI->IsTexture = __indirect_glIsTexture;
+ glAPI->LightModelf = __indirect_glLightModelf;
+ glAPI->LightModelfv = __indirect_glLightModelfv;
+ glAPI->LightModeli = __indirect_glLightModeli;
+ glAPI->LightModeliv = __indirect_glLightModeliv;
+ glAPI->Lightf = __indirect_glLightf;
+ glAPI->Lightfv = __indirect_glLightfv;
+ glAPI->Lighti = __indirect_glLighti;
+ glAPI->Lightiv = __indirect_glLightiv;
+ glAPI->LineStipple = __indirect_glLineStipple;
+ glAPI->LineWidth = __indirect_glLineWidth;
+ glAPI->ListBase = __indirect_glListBase;
+ glAPI->LoadIdentity = __indirect_glLoadIdentity;
+ glAPI->LoadMatrixd = __indirect_glLoadMatrixd;
+ glAPI->LoadMatrixf = __indirect_glLoadMatrixf;
+ glAPI->LoadName = __indirect_glLoadName;
+ glAPI->LogicOp = __indirect_glLogicOp;
+ glAPI->Map1d = __indirect_glMap1d;
+ glAPI->Map1f = __indirect_glMap1f;
+ glAPI->Map2d = __indirect_glMap2d;
+ glAPI->Map2f = __indirect_glMap2f;
+ glAPI->MapGrid1d = __indirect_glMapGrid1d;
+ glAPI->MapGrid1f = __indirect_glMapGrid1f;
+ glAPI->MapGrid2d = __indirect_glMapGrid2d;
+ glAPI->MapGrid2f = __indirect_glMapGrid2f;
+ glAPI->Materialf = __indirect_glMaterialf;
+ glAPI->Materialfv = __indirect_glMaterialfv;
+ glAPI->Materiali = __indirect_glMateriali;
+ glAPI->Materialiv = __indirect_glMaterialiv;
+ glAPI->MatrixMode = __indirect_glMatrixMode;
+ glAPI->MultMatrixd = __indirect_glMultMatrixd;
+ glAPI->MultMatrixf = __indirect_glMultMatrixf;
+ glAPI->NewList = __indirect_glNewList;
+ glAPI->Normal3b = __indirect_glNormal3b;
+ glAPI->Normal3bv = __indirect_glNormal3bv;
+ glAPI->Normal3d = __indirect_glNormal3d;
+ glAPI->Normal3dv = __indirect_glNormal3dv;
+ glAPI->Normal3f = __indirect_glNormal3f;
+ glAPI->Normal3fv = __indirect_glNormal3fv;
+ glAPI->Normal3i = __indirect_glNormal3i;
+ glAPI->Normal3iv = __indirect_glNormal3iv;
+ glAPI->Normal3s = __indirect_glNormal3s;
+ glAPI->Normal3sv = __indirect_glNormal3sv;
+ glAPI->NormalPointer = __indirect_glNormalPointer;
+ glAPI->Ortho = __indirect_glOrtho;
+ glAPI->PassThrough = __indirect_glPassThrough;
+ glAPI->PixelMapfv = __indirect_glPixelMapfv;
+ glAPI->PixelMapuiv = __indirect_glPixelMapuiv;
+ glAPI->PixelMapusv = __indirect_glPixelMapusv;
+ glAPI->PixelStoref = __indirect_glPixelStoref;
+ glAPI->PixelStorei = __indirect_glPixelStorei;
+ glAPI->PixelTransferf = __indirect_glPixelTransferf;
+ glAPI->PixelTransferi = __indirect_glPixelTransferi;
+ glAPI->PixelZoom = __indirect_glPixelZoom;
+ glAPI->PointSize = __indirect_glPointSize;
+ glAPI->PolygonMode = __indirect_glPolygonMode;
+ glAPI->PolygonOffset = __indirect_glPolygonOffset;
+ glAPI->PolygonStipple = __indirect_glPolygonStipple;
+ glAPI->PopAttrib = __indirect_glPopAttrib;
+ glAPI->PopClientAttrib = __indirect_glPopClientAttrib;
+ glAPI->PopMatrix = __indirect_glPopMatrix;
+ glAPI->PopName = __indirect_glPopName;
+ glAPI->PrioritizeTextures = __indirect_glPrioritizeTextures;
+ glAPI->PushAttrib = __indirect_glPushAttrib;
+ glAPI->PushClientAttrib = __indirect_glPushClientAttrib;
+ glAPI->PushMatrix = __indirect_glPushMatrix;
+ glAPI->PushName = __indirect_glPushName;
+ glAPI->RasterPos2d = __indirect_glRasterPos2d;
+ glAPI->RasterPos2dv = __indirect_glRasterPos2dv;
+ glAPI->RasterPos2f = __indirect_glRasterPos2f;
+ glAPI->RasterPos2fv = __indirect_glRasterPos2fv;
+ glAPI->RasterPos2i = __indirect_glRasterPos2i;
+ glAPI->RasterPos2iv = __indirect_glRasterPos2iv;
+ glAPI->RasterPos2s = __indirect_glRasterPos2s;
+ glAPI->RasterPos2sv = __indirect_glRasterPos2sv;
+ glAPI->RasterPos3d = __indirect_glRasterPos3d;
+ glAPI->RasterPos3dv = __indirect_glRasterPos3dv;
+ glAPI->RasterPos3f = __indirect_glRasterPos3f;
+ glAPI->RasterPos3fv = __indirect_glRasterPos3fv;
+ glAPI->RasterPos3i = __indirect_glRasterPos3i;
+ glAPI->RasterPos3iv = __indirect_glRasterPos3iv;
+ glAPI->RasterPos3s = __indirect_glRasterPos3s;
+ glAPI->RasterPos3sv = __indirect_glRasterPos3sv;
+ glAPI->RasterPos4d = __indirect_glRasterPos4d;
+ glAPI->RasterPos4dv = __indirect_glRasterPos4dv;
+ glAPI->RasterPos4f = __indirect_glRasterPos4f;
+ glAPI->RasterPos4fv = __indirect_glRasterPos4fv;
+ glAPI->RasterPos4i = __indirect_glRasterPos4i;
+ glAPI->RasterPos4iv = __indirect_glRasterPos4iv;
+ glAPI->RasterPos4s = __indirect_glRasterPos4s;
+ glAPI->RasterPos4sv = __indirect_glRasterPos4sv;
+ glAPI->ReadBuffer = __indirect_glReadBuffer;
+ glAPI->ReadPixels = __indirect_glReadPixels;
+ glAPI->Rectd = __indirect_glRectd;
+ glAPI->Rectdv = __indirect_glRectdv;
+ glAPI->Rectf = __indirect_glRectf;
+ glAPI->Rectfv = __indirect_glRectfv;
+ glAPI->Recti = __indirect_glRecti;
+ glAPI->Rectiv = __indirect_glRectiv;
+ glAPI->Rects = __indirect_glRects;
+ glAPI->Rectsv = __indirect_glRectsv;
+ glAPI->RenderMode = __indirect_glRenderMode;
+ glAPI->Rotated = __indirect_glRotated;
+ glAPI->Rotatef = __indirect_glRotatef;
+ glAPI->Scaled = __indirect_glScaled;
+ glAPI->Scalef = __indirect_glScalef;
+ glAPI->Scissor = __indirect_glScissor;
+ glAPI->SelectBuffer = __indirect_glSelectBuffer;
+ glAPI->ShadeModel = __indirect_glShadeModel;
+ glAPI->StencilFunc = __indirect_glStencilFunc;
+ glAPI->StencilMask = __indirect_glStencilMask;
+ glAPI->StencilOp = __indirect_glStencilOp;
+ glAPI->TexCoord1d = __indirect_glTexCoord1d;
+ glAPI->TexCoord1dv = __indirect_glTexCoord1dv;
+ glAPI->TexCoord1f = __indirect_glTexCoord1f;
+ glAPI->TexCoord1fv = __indirect_glTexCoord1fv;
+ glAPI->TexCoord1i = __indirect_glTexCoord1i;
+ glAPI->TexCoord1iv = __indirect_glTexCoord1iv;
+ glAPI->TexCoord1s = __indirect_glTexCoord1s;
+ glAPI->TexCoord1sv = __indirect_glTexCoord1sv;
+ glAPI->TexCoord2d = __indirect_glTexCoord2d;
+ glAPI->TexCoord2dv = __indirect_glTexCoord2dv;
+ glAPI->TexCoord2f = __indirect_glTexCoord2f;
+ glAPI->TexCoord2fv = __indirect_glTexCoord2fv;
+ glAPI->TexCoord2i = __indirect_glTexCoord2i;
+ glAPI->TexCoord2iv = __indirect_glTexCoord2iv;
+ glAPI->TexCoord2s = __indirect_glTexCoord2s;
+ glAPI->TexCoord2sv = __indirect_glTexCoord2sv;
+ glAPI->TexCoord3d = __indirect_glTexCoord3d;
+ glAPI->TexCoord3dv = __indirect_glTexCoord3dv;
+ glAPI->TexCoord3f = __indirect_glTexCoord3f;
+ glAPI->TexCoord3fv = __indirect_glTexCoord3fv;
+ glAPI->TexCoord3i = __indirect_glTexCoord3i;
+ glAPI->TexCoord3iv = __indirect_glTexCoord3iv;
+ glAPI->TexCoord3s = __indirect_glTexCoord3s;
+ glAPI->TexCoord3sv = __indirect_glTexCoord3sv;
+ glAPI->TexCoord4d = __indirect_glTexCoord4d;
+ glAPI->TexCoord4dv = __indirect_glTexCoord4dv;
+ glAPI->TexCoord4f = __indirect_glTexCoord4f;
+ glAPI->TexCoord4fv = __indirect_glTexCoord4fv;
+ glAPI->TexCoord4i = __indirect_glTexCoord4i;
+ glAPI->TexCoord4iv = __indirect_glTexCoord4iv;
+ glAPI->TexCoord4s = __indirect_glTexCoord4s;
+ glAPI->TexCoord4sv = __indirect_glTexCoord4sv;
+ glAPI->TexCoordPointer = __indirect_glTexCoordPointer;
+ glAPI->TexEnvf = __indirect_glTexEnvf;
+ glAPI->TexEnvfv = __indirect_glTexEnvfv;
+ glAPI->TexEnvi = __indirect_glTexEnvi;
+ glAPI->TexEnviv = __indirect_glTexEnviv;
+ glAPI->TexGend = __indirect_glTexGend;
+ glAPI->TexGendv = __indirect_glTexGendv;
+ glAPI->TexGenf = __indirect_glTexGenf;
+ glAPI->TexGenfv = __indirect_glTexGenfv;
+ glAPI->TexGeni = __indirect_glTexGeni;
+ glAPI->TexGeniv = __indirect_glTexGeniv;
+ glAPI->TexImage1D = __indirect_glTexImage1D;
+ glAPI->TexImage2D = __indirect_glTexImage2D;
+ glAPI->TexParameterf = __indirect_glTexParameterf;
+ glAPI->TexParameterfv = __indirect_glTexParameterfv;
+ glAPI->TexParameteri = __indirect_glTexParameteri;
+ glAPI->TexParameteriv = __indirect_glTexParameteriv;
+ glAPI->TexSubImage1D = __indirect_glTexSubImage1D;
+ glAPI->TexSubImage2D = __indirect_glTexSubImage2D;
+ glAPI->Translated = __indirect_glTranslated;
+ glAPI->Translatef = __indirect_glTranslatef;
+ glAPI->Vertex2d = __indirect_glVertex2d;
+ glAPI->Vertex2dv = __indirect_glVertex2dv;
+ glAPI->Vertex2f = __indirect_glVertex2f;
+ glAPI->Vertex2fv = __indirect_glVertex2fv;
+ glAPI->Vertex2i = __indirect_glVertex2i;
+ glAPI->Vertex2iv = __indirect_glVertex2iv;
+ glAPI->Vertex2s = __indirect_glVertex2s;
+ glAPI->Vertex2sv = __indirect_glVertex2sv;
+ glAPI->Vertex3d = __indirect_glVertex3d;
+ glAPI->Vertex3dv = __indirect_glVertex3dv;
+ glAPI->Vertex3f = __indirect_glVertex3f;
+ glAPI->Vertex3fv = __indirect_glVertex3fv;
+ glAPI->Vertex3i = __indirect_glVertex3i;
+ glAPI->Vertex3iv = __indirect_glVertex3iv;
+ glAPI->Vertex3s = __indirect_glVertex3s;
+ glAPI->Vertex3sv = __indirect_glVertex3sv;
+ glAPI->Vertex4d = __indirect_glVertex4d;
+ glAPI->Vertex4dv = __indirect_glVertex4dv;
+ glAPI->Vertex4f = __indirect_glVertex4f;
+ glAPI->Vertex4fv = __indirect_glVertex4fv;
+ glAPI->Vertex4i = __indirect_glVertex4i;
+ glAPI->Vertex4iv = __indirect_glVertex4iv;
+ glAPI->Vertex4s = __indirect_glVertex4s;
+ glAPI->Vertex4sv = __indirect_glVertex4sv;
+ glAPI->VertexPointer = __indirect_glVertexPointer;
+ glAPI->Viewport = __indirect_glViewport;
+
+ /* 1.2 */
+ glAPI->CopyTexSubImage3D = __indirect_glCopyTexSubImage3D;
+ glAPI->DrawRangeElements = __indirect_glDrawRangeElements;
+ glAPI->TexImage3D = __indirect_glTexImage3D;
+ glAPI->TexSubImage3D = __indirect_glTexSubImage3D;
+
+ /* OpenGL 1.2 GL_ARB_imaging */
+ glAPI->BlendColor = __indirect_glBlendColor;
+ glAPI->BlendEquation = __indirect_glBlendEquation;
+ glAPI->ColorSubTable = __indirect_glColorSubTable;
+ glAPI->ColorTable = __indirect_glColorTable;
+ glAPI->ColorTableParameterfv = __indirect_glColorTableParameterfv;
+ glAPI->ColorTableParameteriv = __indirect_glColorTableParameteriv;
+ glAPI->ConvolutionFilter1D = __indirect_glConvolutionFilter1D;
+ glAPI->ConvolutionFilter2D = __indirect_glConvolutionFilter2D;
+ glAPI->ConvolutionParameterf = __indirect_glConvolutionParameterf;
+ glAPI->ConvolutionParameterfv = __indirect_glConvolutionParameterfv;
+ glAPI->ConvolutionParameteri = __indirect_glConvolutionParameteri;
+ glAPI->ConvolutionParameteriv = __indirect_glConvolutionParameteriv;
+ glAPI->CopyColorSubTable = __indirect_glCopyColorSubTable;
+ glAPI->CopyColorTable = __indirect_glCopyColorTable;
+ glAPI->CopyConvolutionFilter1D = __indirect_glCopyConvolutionFilter1D;
+ glAPI->CopyConvolutionFilter2D = __indirect_glCopyConvolutionFilter2D;
+ glAPI->GetColorTable = __indirect_glGetColorTable;
+ glAPI->GetColorTableParameterfv = __indirect_glGetColorTableParameterfv;
+ glAPI->GetColorTableParameteriv = __indirect_glGetColorTableParameteriv;
+ glAPI->GetConvolutionFilter = __indirect_glGetConvolutionFilter;
+ glAPI->GetConvolutionParameterfv = __indirect_glGetConvolutionParameterfv;
+ glAPI->GetConvolutionParameteriv = __indirect_glGetConvolutionParameteriv;
+ glAPI->GetHistogram = __indirect_glGetHistogram;
+ glAPI->GetHistogramParameterfv = __indirect_glGetHistogramParameterfv;
+ glAPI->GetHistogramParameteriv = __indirect_glGetHistogramParameteriv;
+ glAPI->GetMinmax = __indirect_glGetMinmax;
+ glAPI->GetMinmaxParameterfv = __indirect_glGetMinmaxParameterfv;
+ glAPI->GetMinmaxParameteriv = __indirect_glGetMinmaxParameteriv;
+ glAPI->GetSeparableFilter = __indirect_glGetSeparableFilter;
+ glAPI->Histogram = __indirect_glHistogram;
+ glAPI->Minmax = __indirect_glMinmax;
+ glAPI->ResetHistogram = __indirect_glResetHistogram;
+ glAPI->ResetMinmax = __indirect_glResetMinmax;
+ glAPI->SeparableFilter2D = __indirect_glSeparableFilter2D;
+
+ /* 1.4 */
+ glAPI->MultiDrawArraysEXT = __indirect_glMultiDrawArrays;
+ glAPI->MultiDrawElementsEXT = __indirect_glMultiDrawElements;
+
+ /* ARB 1. GL_ARB_multitexture */
+ glAPI->ActiveTextureARB = __indirect_glActiveTextureARB;
+ glAPI->ClientActiveTextureARB = __indirect_glClientActiveTextureARB;
+ glAPI->MultiTexCoord1dARB = __indirect_glMultiTexCoord1dARB;
+ glAPI->MultiTexCoord1dvARB = __indirect_glMultiTexCoord1dvARB;
+ glAPI->MultiTexCoord1fARB = __indirect_glMultiTexCoord1fARB;
+ glAPI->MultiTexCoord1fvARB = __indirect_glMultiTexCoord1fvARB;
+ glAPI->MultiTexCoord1iARB = __indirect_glMultiTexCoord1iARB;
+ glAPI->MultiTexCoord1ivARB = __indirect_glMultiTexCoord1ivARB;
+ glAPI->MultiTexCoord1sARB = __indirect_glMultiTexCoord1sARB;
+ glAPI->MultiTexCoord1svARB = __indirect_glMultiTexCoord1svARB;
+ glAPI->MultiTexCoord2dARB = __indirect_glMultiTexCoord2dARB;
+ glAPI->MultiTexCoord2dvARB = __indirect_glMultiTexCoord2dvARB;
+ glAPI->MultiTexCoord2fARB = __indirect_glMultiTexCoord2fARB;
+ glAPI->MultiTexCoord2fvARB = __indirect_glMultiTexCoord2fvARB;
+ glAPI->MultiTexCoord2iARB = __indirect_glMultiTexCoord2iARB;
+ glAPI->MultiTexCoord2ivARB = __indirect_glMultiTexCoord2ivARB;
+ glAPI->MultiTexCoord2sARB = __indirect_glMultiTexCoord2sARB;
+ glAPI->MultiTexCoord2svARB = __indirect_glMultiTexCoord2svARB;
+ glAPI->MultiTexCoord3dARB = __indirect_glMultiTexCoord3dARB;
+ glAPI->MultiTexCoord3dvARB = __indirect_glMultiTexCoord3dvARB;
+ glAPI->MultiTexCoord3fARB = __indirect_glMultiTexCoord3fARB;
+ glAPI->MultiTexCoord3fvARB = __indirect_glMultiTexCoord3fvARB;
+ glAPI->MultiTexCoord3iARB = __indirect_glMultiTexCoord3iARB;
+ glAPI->MultiTexCoord3ivARB = __indirect_glMultiTexCoord3ivARB;
+ glAPI->MultiTexCoord3sARB = __indirect_glMultiTexCoord3sARB;
+ glAPI->MultiTexCoord3svARB = __indirect_glMultiTexCoord3svARB;
+ glAPI->MultiTexCoord4dARB = __indirect_glMultiTexCoord4dARB;
+ glAPI->MultiTexCoord4dvARB = __indirect_glMultiTexCoord4dvARB;
+ glAPI->MultiTexCoord4fARB = __indirect_glMultiTexCoord4fARB;
+ glAPI->MultiTexCoord4fvARB = __indirect_glMultiTexCoord4fvARB;
+ glAPI->MultiTexCoord4iARB = __indirect_glMultiTexCoord4iARB;
+ glAPI->MultiTexCoord4ivARB = __indirect_glMultiTexCoord4ivARB;
+ glAPI->MultiTexCoord4sARB = __indirect_glMultiTexCoord4sARB;
+ glAPI->MultiTexCoord4svARB = __indirect_glMultiTexCoord4svARB;
+
+ /* ARB 3. GL_ARB_transpose_matrix */
+ glAPI->LoadTransposeMatrixdARB = __indirect_glLoadTransposeMatrixdARB;
+ glAPI->LoadTransposeMatrixfARB = __indirect_glLoadTransposeMatrixfARB;
+ glAPI->MultTransposeMatrixdARB = __indirect_glMultTransposeMatrixdARB;
+ glAPI->MultTransposeMatrixfARB = __indirect_glMultTransposeMatrixfARB;
+
+ /* ARB 5. GL_ARB_multisample */
+ glAPI->SampleCoverageARB = __indirect_glSampleCoverageARB;
+
+ /* ARB 12. GL_ARB_texture_compression / 1.3 */
+ glAPI->GetCompressedTexImageARB = __indirect_glGetCompressedTexImage;
+ glAPI->CompressedTexImage1DARB = __indirect_glCompressedTexImage1D;
+ glAPI->CompressedTexImage2DARB = __indirect_glCompressedTexImage2D;
+ glAPI->CompressedTexImage3DARB = __indirect_glCompressedTexImage3D;
+ glAPI->CompressedTexSubImage1DARB = __indirect_glCompressedTexSubImage1D;
+ glAPI->CompressedTexSubImage2DARB = __indirect_glCompressedTexSubImage2D;
+ glAPI->CompressedTexSubImage3DARB = __indirect_glCompressedTexSubImage3D;
+
+ /* ARB 14. GL_ARB_point_parameters */
+ glAPI->PointParameterfEXT = __indirect_glPointParameterfARB;
+ glAPI->PointParameterfvEXT = __indirect_glPointParameterfvARB;
+
+ /* ARB 15. GL_ARB_window_pos */
+ glAPI->WindowPos2dMESA = __indirect_glWindowPos2dARB;
+ glAPI->WindowPos2iMESA = __indirect_glWindowPos2iARB;
+ glAPI->WindowPos2fMESA = __indirect_glWindowPos2fARB;
+ glAPI->WindowPos2iMESA = __indirect_glWindowPos2iARB;
+ glAPI->WindowPos2sMESA = __indirect_glWindowPos2sARB;
+ glAPI->WindowPos2dvMESA = __indirect_glWindowPos2dvARB;
+ glAPI->WindowPos2fvMESA = __indirect_glWindowPos2fvARB;
+ glAPI->WindowPos2ivMESA = __indirect_glWindowPos2ivARB;
+ glAPI->WindowPos2svMESA = __indirect_glWindowPos2svARB;
+ glAPI->WindowPos3dMESA = __indirect_glWindowPos3dARB;
+ glAPI->WindowPos3fMESA = __indirect_glWindowPos3fARB;
+ glAPI->WindowPos3iMESA = __indirect_glWindowPos3iARB;
+ glAPI->WindowPos3sMESA = __indirect_glWindowPos3sARB;
+ glAPI->WindowPos3dvMESA = __indirect_glWindowPos3dvARB;
+ glAPI->WindowPos3fvMESA = __indirect_glWindowPos3fvARB;
+ glAPI->WindowPos3ivMESA = __indirect_glWindowPos3ivARB;
+ glAPI->WindowPos3svMESA = __indirect_glWindowPos3svARB;
+
+ /* 25. GL_SGIS_multisample */
+ glAPI->SampleMaskSGIS = __indirect_glSampleMaskSGIS;
+ glAPI->SamplePatternSGIS = __indirect_glSamplePatternSGIS;
+
+ /* 30. GL_EXT_vertex_array */
+ glAPI->ColorPointerEXT = ColorPointerEXT;
+ glAPI->EdgeFlagPointerEXT = EdgeFlagPointerEXT;
+ glAPI->IndexPointerEXT = IndexPointerEXT;
+ glAPI->NormalPointerEXT = NormalPointerEXT;
+ glAPI->TexCoordPointerEXT = TexCoordPointerEXT;
+ glAPI->VertexPointerEXT = VertexPointerEXT;
+
+ /* 145. GL_EXT_secondary_color / GL 1.4 */
+ glAPI->SecondaryColor3bEXT = __indirect_glSecondaryColor3b;
+ glAPI->SecondaryColor3bvEXT = __indirect_glSecondaryColor3bv;
+ glAPI->SecondaryColor3sEXT = __indirect_glSecondaryColor3s;
+ glAPI->SecondaryColor3svEXT = __indirect_glSecondaryColor3sv;
+ glAPI->SecondaryColor3iEXT = __indirect_glSecondaryColor3i;
+ glAPI->SecondaryColor3ivEXT = __indirect_glSecondaryColor3iv;
+ glAPI->SecondaryColor3ubEXT = __indirect_glSecondaryColor3ub;
+ glAPI->SecondaryColor3ubvEXT = __indirect_glSecondaryColor3ubv;
+ glAPI->SecondaryColor3usEXT = __indirect_glSecondaryColor3us;
+ glAPI->SecondaryColor3usvEXT = __indirect_glSecondaryColor3usv;
+ glAPI->SecondaryColor3uiEXT = __indirect_glSecondaryColor3ui;
+ glAPI->SecondaryColor3uivEXT = __indirect_glSecondaryColor3uiv;
+ glAPI->SecondaryColor3fEXT = __indirect_glSecondaryColor3f;
+ glAPI->SecondaryColor3fvEXT = __indirect_glSecondaryColor3fv;
+ glAPI->SecondaryColor3dEXT = __indirect_glSecondaryColor3d;
+ glAPI->SecondaryColor3dvEXT = __indirect_glSecondaryColor3dv;
+ glAPI->SecondaryColorPointerEXT = __indirect_glSecondaryColorPointer;
+
+ /* 149. GL_EXT_fog_coord / GL 1.4 */
+ glAPI->FogCoordfEXT = __indirect_glFogCoordf;
+ glAPI->FogCoordfvEXT = __indirect_glFogCoordfv;
+ glAPI->FogCoorddEXT = __indirect_glFogCoordd;
+ glAPI->FogCoorddvEXT = __indirect_glFogCoorddv;
+ glAPI->FogCoordPointerEXT = __indirect_glFogCoordPointer;
+
+ /* 173. GL_EXT_blend_func_separate / GL 1.4 */
+ glAPI->BlendFuncSeparateEXT = __indirect_glBlendFuncSeparate;
+
+ /* 262. GL_NV_point_sprite / GL 1.4 */
+ glAPI->PointParameteriNV = __indirect_glPointParameteri;
+ glAPI->PointParameterivNV = __indirect_glPointParameteriv;
+
+ /* 268. GL_EXT_stencil_two_side */
+ glAPI->ActiveStencilFaceEXT = __indirect_glActiveStencilFaceEXT;
+
+ return glAPI;
+}
diff --git a/src/glx/x11/indirect_init.h b/src/glx/x11/indirect_init.h
new file mode 100644
index 0000000000..62d04ba6dc
--- /dev/null
+++ b/src/glx/x11/indirect_init.h
@@ -0,0 +1,42 @@
+/* $XFree86: xc/lib/GL/glx/indirect_init.h,v 1.2 2000/02/08 17:18:33 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _INDIRECT_INIT_H_
+#define _INDIRECT_INIT_H_
+
+#include "glxclient.h"
+
+extern __GLapi *__glXNewIndirectAPI(void);
+
+#endif /* _INDIRECT_INIT_H_ */
diff --git a/src/glx/x11/indirect_wrap.h b/src/glx/x11/indirect_wrap.h
new file mode 100644
index 0000000000..fe73fd8c20
--- /dev/null
+++ b/src/glx/x11/indirect_wrap.h
@@ -0,0 +1,730 @@
+/* $XFree86: xc/lib/GL/glx/indirect_wrap.h,v 1.4 2003/09/28 20:15:04 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+/* NOTE: This file could be automatically generated */
+
+#ifndef _INDIRECT_WRAP_H_
+#define _INDIRECT_WRAP_H_
+
+#define glAccum __indirect_glAccum
+#define glAlphaFunc __indirect_glAlphaFunc
+#define glAreTexturesResident __indirect_glAreTexturesResident
+#define glArrayElement __indirect_glArrayElement
+#define glBegin __indirect_glBegin
+#define glBindTexture __indirect_glBindTexture
+#define glBitmap __indirect_glBitmap
+#define glBlendFunc __indirect_glBlendFunc
+#define glCallList __indirect_glCallList
+#define glCallLists __indirect_glCallLists
+#define glClear __indirect_glClear
+#define glClearAccum __indirect_glClearAccum
+#define glClearColor __indirect_glClearColor
+#define glClearDepth __indirect_glClearDepth
+#define glClearIndex __indirect_glClearIndex
+#define glClearStencil __indirect_glClearStencil
+#define glClipPlane __indirect_glClipPlane
+#define glColor3b __indirect_glColor3b
+#define glColor3bv __indirect_glColor3bv
+#define glColor3d __indirect_glColor3d
+#define glColor3dv __indirect_glColor3dv
+#define glColor3f __indirect_glColor3f
+#define glColor3fv __indirect_glColor3fv
+#define glColor3i __indirect_glColor3i
+#define glColor3iv __indirect_glColor3iv
+#define glColor3s __indirect_glColor3s
+#define glColor3sv __indirect_glColor3sv
+#define glColor3ub __indirect_glColor3ub
+#define glColor3ubv __indirect_glColor3ubv
+#define glColor3ui __indirect_glColor3ui
+#define glColor3uiv __indirect_glColor3uiv
+#define glColor3us __indirect_glColor3us
+#define glColor3usv __indirect_glColor3usv
+#define glColor4b __indirect_glColor4b
+#define glColor4bv __indirect_glColor4bv
+#define glColor4d __indirect_glColor4d
+#define glColor4dv __indirect_glColor4dv
+#define glColor4f __indirect_glColor4f
+#define glColor4fv __indirect_glColor4fv
+#define glColor4i __indirect_glColor4i
+#define glColor4iv __indirect_glColor4iv
+#define glColor4s __indirect_glColor4s
+#define glColor4sv __indirect_glColor4sv
+#define glColor4ub __indirect_glColor4ub
+#define glColor4ubv __indirect_glColor4ubv
+#define glColor4ui __indirect_glColor4ui
+#define glColor4uiv __indirect_glColor4uiv
+#define glColor4us __indirect_glColor4us
+#define glColor4usv __indirect_glColor4usv
+#define glColorMask __indirect_glColorMask
+#define glColorMaterial __indirect_glColorMaterial
+#define glColorPointer __indirect_glColorPointer
+#define glCopyPixels __indirect_glCopyPixels
+#define glCopyTexImage1D __indirect_glCopyTexImage1D
+#define glCopyTexImage2D __indirect_glCopyTexImage2D
+#define glCopyTexSubImage1D __indirect_glCopyTexSubImage1D
+#define glCopyTexSubImage2D __indirect_glCopyTexSubImage2D
+#define glCullFace __indirect_glCullFace
+#define glDeleteLists __indirect_glDeleteLists
+#define glDeleteTextures __indirect_glDeleteTextures
+#define glDepthFunc __indirect_glDepthFunc
+#define glDepthMask __indirect_glDepthMask
+#define glDepthRange __indirect_glDepthRange
+#define glDisable __indirect_glDisable
+#define glDisableClientState __indirect_glDisableClientState
+#define glDrawArrays __indirect_glDrawArrays
+#define glDrawBuffer __indirect_glDrawBuffer
+#define glDrawElements __indirect_glDrawElements
+#define glDrawPixels __indirect_glDrawPixels
+#define glEdgeFlag __indirect_glEdgeFlag
+#define glEdgeFlagPointer __indirect_glEdgeFlagPointer
+#define glEdgeFlagv __indirect_glEdgeFlagv
+#define glEnable __indirect_glEnable
+#define glEnableClientState __indirect_glEnableClientState
+#define glEnd __indirect_glEnd
+#define glEndList __indirect_glEndList
+#define glEvalCoord1d __indirect_glEvalCoord1d
+#define glEvalCoord1dv __indirect_glEvalCoord1dv
+#define glEvalCoord1f __indirect_glEvalCoord1f
+#define glEvalCoord1fv __indirect_glEvalCoord1fv
+#define glEvalCoord2d __indirect_glEvalCoord2d
+#define glEvalCoord2dv __indirect_glEvalCoord2dv
+#define glEvalCoord2f __indirect_glEvalCoord2f
+#define glEvalCoord2fv __indirect_glEvalCoord2fv
+#define glEvalMesh1 __indirect_glEvalMesh1
+#define glEvalMesh2 __indirect_glEvalMesh2
+#define glEvalPoint1 __indirect_glEvalPoint1
+#define glEvalPoint2 __indirect_glEvalPoint2
+#define glFeedbackBuffer __indirect_glFeedbackBuffer
+#define glFinish __indirect_glFinish
+#define glFlush __indirect_glFlush
+#define glFogf __indirect_glFogf
+#define glFogfv __indirect_glFogfv
+#define glFogi __indirect_glFogi
+#define glFogiv __indirect_glFogiv
+#define glFrontFace __indirect_glFrontFace
+#define glFrustum __indirect_glFrustum
+#define glGenLists __indirect_glGenLists
+#define glGenTextures __indirect_glGenTextures
+#define glGetBooleanv __indirect_glGetBooleanv
+#define glGetClipPlane __indirect_glGetClipPlane
+#define glGetDoublev __indirect_glGetDoublev
+#define glGetError __indirect_glGetError
+#define glGetFloatv __indirect_glGetFloatv
+#define glGetIntegerv __indirect_glGetIntegerv
+#define glGetLightfv __indirect_glGetLightfv
+#define glGetLightiv __indirect_glGetLightiv
+#define glGetMapdv __indirect_glGetMapdv
+#define glGetMapfv __indirect_glGetMapfv
+#define glGetMapiv __indirect_glGetMapiv
+#define glGetMaterialfv __indirect_glGetMaterialfv
+#define glGetMaterialiv __indirect_glGetMaterialiv
+#define glGetPixelMapfv __indirect_glGetPixelMapfv
+#define glGetPixelMapuiv __indirect_glGetPixelMapuiv
+#define glGetPixelMapusv __indirect_glGetPixelMapusv
+#define glGetPointerv __indirect_glGetPointerv
+#define glGetPolygonStipple __indirect_glGetPolygonStipple
+#define glGetString __indirect_glGetString
+#define glGetTexEnvfv __indirect_glGetTexEnvfv
+#define glGetTexEnviv __indirect_glGetTexEnviv
+#define glGetTexGendv __indirect_glGetTexGendv
+#define glGetTexGenfv __indirect_glGetTexGenfv
+#define glGetTexGeniv __indirect_glGetTexGeniv
+#define glGetTexImage __indirect_glGetTexImage
+#define glGetTexLevelParameterfv __indirect_glGetTexLevelParameterfv
+#define glGetTexLevelParameteriv __indirect_glGetTexLevelParameteriv
+#define glGetTexParameterfv __indirect_glGetTexParameterfv
+#define glGetTexParameteriv __indirect_glGetTexParameteriv
+#define glHint __indirect_glHint
+#define glIndexMask __indirect_glIndexMask
+#define glIndexPointer __indirect_glIndexPointer
+#define glIndexd __indirect_glIndexd
+#define glIndexdv __indirect_glIndexdv
+#define glIndexf __indirect_glIndexf
+#define glIndexfv __indirect_glIndexfv
+#define glIndexi __indirect_glIndexi
+#define glIndexiv __indirect_glIndexiv
+#define glIndexs __indirect_glIndexs
+#define glIndexsv __indirect_glIndexsv
+#define glIndexub __indirect_glIndexub
+#define glIndexubv __indirect_glIndexubv
+#define glInitNames __indirect_glInitNames
+#define glInterleavedArrays __indirect_glInterleavedArrays
+#define glIsEnabled __indirect_glIsEnabled
+#define glIsList __indirect_glIsList
+#define glIsTexture __indirect_glIsTexture
+#define glLightModelf __indirect_glLightModelf
+#define glLightModelfv __indirect_glLightModelfv
+#define glLightModeli __indirect_glLightModeli
+#define glLightModeliv __indirect_glLightModeliv
+#define glLightf __indirect_glLightf
+#define glLightfv __indirect_glLightfv
+#define glLighti __indirect_glLighti
+#define glLightiv __indirect_glLightiv
+#define glLineStipple __indirect_glLineStipple
+#define glLineWidth __indirect_glLineWidth
+#define glListBase __indirect_glListBase
+#define glLoadIdentity __indirect_glLoadIdentity
+#define glLoadMatrixd __indirect_glLoadMatrixd
+#define glLoadMatrixf __indirect_glLoadMatrixf
+#define glLoadName __indirect_glLoadName
+#define glLogicOp __indirect_glLogicOp
+#define glMap1d __indirect_glMap1d
+#define glMap1f __indirect_glMap1f
+#define glMap2d __indirect_glMap2d
+#define glMap2f __indirect_glMap2f
+#define glMapGrid1d __indirect_glMapGrid1d
+#define glMapGrid1f __indirect_glMapGrid1f
+#define glMapGrid2d __indirect_glMapGrid2d
+#define glMapGrid2f __indirect_glMapGrid2f
+#define glMaterialf __indirect_glMaterialf
+#define glMaterialfv __indirect_glMaterialfv
+#define glMateriali __indirect_glMateriali
+#define glMaterialiv __indirect_glMaterialiv
+#define glMatrixMode __indirect_glMatrixMode
+#define glMultMatrixd __indirect_glMultMatrixd
+#define glMultMatrixf __indirect_glMultMatrixf
+#define glNewList __indirect_glNewList
+#define glNormal3b __indirect_glNormal3b
+#define glNormal3bv __indirect_glNormal3bv
+#define glNormal3d __indirect_glNormal3d
+#define glNormal3dv __indirect_glNormal3dv
+#define glNormal3f __indirect_glNormal3f
+#define glNormal3fv __indirect_glNormal3fv
+#define glNormal3i __indirect_glNormal3i
+#define glNormal3iv __indirect_glNormal3iv
+#define glNormal3s __indirect_glNormal3s
+#define glNormal3sv __indirect_glNormal3sv
+#define glNormalPointer __indirect_glNormalPointer
+#define glOrtho __indirect_glOrtho
+#define glPassThrough __indirect_glPassThrough
+#define glPixelMapfv __indirect_glPixelMapfv
+#define glPixelMapuiv __indirect_glPixelMapuiv
+#define glPixelMapusv __indirect_glPixelMapusv
+#define glPixelStoref __indirect_glPixelStoref
+#define glPixelStorei __indirect_glPixelStorei
+#define glPixelTransferf __indirect_glPixelTransferf
+#define glPixelTransferi __indirect_glPixelTransferi
+#define glPixelZoom __indirect_glPixelZoom
+#define glPointSize __indirect_glPointSize
+#define glPolygonMode __indirect_glPolygonMode
+#define glPolygonOffset __indirect_glPolygonOffset
+#define glPolygonStipple __indirect_glPolygonStipple
+#define glPopAttrib __indirect_glPopAttrib
+#define glPopClientAttrib __indirect_glPopClientAttrib
+#define glPopMatrix __indirect_glPopMatrix
+#define glPopName __indirect_glPopName
+#define glPrioritizeTextures __indirect_glPrioritizeTextures
+#define glPushAttrib __indirect_glPushAttrib
+#define glPushClientAttrib __indirect_glPushClientAttrib
+#define glPushMatrix __indirect_glPushMatrix
+#define glPushName __indirect_glPushName
+#define glRasterPos2d __indirect_glRasterPos2d
+#define glRasterPos2dv __indirect_glRasterPos2dv
+#define glRasterPos2f __indirect_glRasterPos2f
+#define glRasterPos2fv __indirect_glRasterPos2fv
+#define glRasterPos2i __indirect_glRasterPos2i
+#define glRasterPos2iv __indirect_glRasterPos2iv
+#define glRasterPos2s __indirect_glRasterPos2s
+#define glRasterPos2sv __indirect_glRasterPos2sv
+#define glRasterPos3d __indirect_glRasterPos3d
+#define glRasterPos3dv __indirect_glRasterPos3dv
+#define glRasterPos3f __indirect_glRasterPos3f
+#define glRasterPos3fv __indirect_glRasterPos3fv
+#define glRasterPos3i __indirect_glRasterPos3i
+#define glRasterPos3iv __indirect_glRasterPos3iv
+#define glRasterPos3s __indirect_glRasterPos3s
+#define glRasterPos3sv __indirect_glRasterPos3sv
+#define glRasterPos4d __indirect_glRasterPos4d
+#define glRasterPos4dv __indirect_glRasterPos4dv
+#define glRasterPos4f __indirect_glRasterPos4f
+#define glRasterPos4fv __indirect_glRasterPos4fv
+#define glRasterPos4i __indirect_glRasterPos4i
+#define glRasterPos4iv __indirect_glRasterPos4iv
+#define glRasterPos4s __indirect_glRasterPos4s
+#define glRasterPos4sv __indirect_glRasterPos4sv
+#define glReadBuffer __indirect_glReadBuffer
+#define glReadPixels __indirect_glReadPixels
+#define glRectd __indirect_glRectd
+#define glRectdv __indirect_glRectdv
+#define glRectf __indirect_glRectf
+#define glRectfv __indirect_glRectfv
+#define glRecti __indirect_glRecti
+#define glRectiv __indirect_glRectiv
+#define glRects __indirect_glRects
+#define glRectsv __indirect_glRectsv
+#define glRenderMode __indirect_glRenderMode
+#define glRotated __indirect_glRotated
+#define glRotatef __indirect_glRotatef
+#define glScaled __indirect_glScaled
+#define glScalef __indirect_glScalef
+#define glScissor __indirect_glScissor
+#define glSelectBuffer __indirect_glSelectBuffer
+#define glShadeModel __indirect_glShadeModel
+#define glStencilFunc __indirect_glStencilFunc
+#define glStencilMask __indirect_glStencilMask
+#define glStencilOp __indirect_glStencilOp
+#define glTexCoord1d __indirect_glTexCoord1d
+#define glTexCoord1dv __indirect_glTexCoord1dv
+#define glTexCoord1f __indirect_glTexCoord1f
+#define glTexCoord1fv __indirect_glTexCoord1fv
+#define glTexCoord1i __indirect_glTexCoord1i
+#define glTexCoord1iv __indirect_glTexCoord1iv
+#define glTexCoord1s __indirect_glTexCoord1s
+#define glTexCoord1sv __indirect_glTexCoord1sv
+#define glTexCoord2d __indirect_glTexCoord2d
+#define glTexCoord2dv __indirect_glTexCoord2dv
+#define glTexCoord2f __indirect_glTexCoord2f
+#define glTexCoord2fv __indirect_glTexCoord2fv
+#define glTexCoord2i __indirect_glTexCoord2i
+#define glTexCoord2iv __indirect_glTexCoord2iv
+#define glTexCoord2s __indirect_glTexCoord2s
+#define glTexCoord2sv __indirect_glTexCoord2sv
+#define glTexCoord3d __indirect_glTexCoord3d
+#define glTexCoord3dv __indirect_glTexCoord3dv
+#define glTexCoord3f __indirect_glTexCoord3f
+#define glTexCoord3fv __indirect_glTexCoord3fv
+#define glTexCoord3i __indirect_glTexCoord3i
+#define glTexCoord3iv __indirect_glTexCoord3iv
+#define glTexCoord3s __indirect_glTexCoord3s
+#define glTexCoord3sv __indirect_glTexCoord3sv
+#define glTexCoord4d __indirect_glTexCoord4d
+#define glTexCoord4dv __indirect_glTexCoord4dv
+#define glTexCoord4f __indirect_glTexCoord4f
+#define glTexCoord4fv __indirect_glTexCoord4fv
+#define glTexCoord4i __indirect_glTexCoord4i
+#define glTexCoord4iv __indirect_glTexCoord4iv
+#define glTexCoord4s __indirect_glTexCoord4s
+#define glTexCoord4sv __indirect_glTexCoord4sv
+#define glTexCoordPointer __indirect_glTexCoordPointer
+#define glTexEnvf __indirect_glTexEnvf
+#define glTexEnvfv __indirect_glTexEnvfv
+#define glTexEnvi __indirect_glTexEnvi
+#define glTexEnviv __indirect_glTexEnviv
+#define glTexGend __indirect_glTexGend
+#define glTexGendv __indirect_glTexGendv
+#define glTexGenf __indirect_glTexGenf
+#define glTexGenfv __indirect_glTexGenfv
+#define glTexGeni __indirect_glTexGeni
+#define glTexGeniv __indirect_glTexGeniv
+#define glTexImage1D __indirect_glTexImage1D
+#define glTexImage2D __indirect_glTexImage2D
+#define glTexParameterf __indirect_glTexParameterf
+#define glTexParameterfv __indirect_glTexParameterfv
+#define glTexParameteri __indirect_glTexParameteri
+#define glTexParameteriv __indirect_glTexParameteriv
+#define glTexSubImage1D __indirect_glTexSubImage1D
+#define glTexSubImage2D __indirect_glTexSubImage2D
+#define glTranslated __indirect_glTranslated
+#define glTranslatef __indirect_glTranslatef
+#define glVertex2d __indirect_glVertex2d
+#define glVertex2dv __indirect_glVertex2dv
+#define glVertex2f __indirect_glVertex2f
+#define glVertex2fv __indirect_glVertex2fv
+#define glVertex2i __indirect_glVertex2i
+#define glVertex2iv __indirect_glVertex2iv
+#define glVertex2s __indirect_glVertex2s
+#define glVertex2sv __indirect_glVertex2sv
+#define glVertex3d __indirect_glVertex3d
+#define glVertex3dv __indirect_glVertex3dv
+#define glVertex3f __indirect_glVertex3f
+#define glVertex3fv __indirect_glVertex3fv
+#define glVertex3i __indirect_glVertex3i
+#define glVertex3iv __indirect_glVertex3iv
+#define glVertex3s __indirect_glVertex3s
+#define glVertex3sv __indirect_glVertex3sv
+#define glVertex4d __indirect_glVertex4d
+#define glVertex4dv __indirect_glVertex4dv
+#define glVertex4f __indirect_glVertex4f
+#define glVertex4fv __indirect_glVertex4fv
+#define glVertex4i __indirect_glVertex4i
+#define glVertex4iv __indirect_glVertex4iv
+#define glVertex4s __indirect_glVertex4s
+#define glVertex4sv __indirect_glVertex4sv
+#define glVertexPointer __indirect_glVertexPointer
+#define glViewport __indirect_glViewport
+
+/* 1.2 */
+#define glCopyTexSubImage3D __indirect_glCopyTexSubImage3D
+#define glDrawRangeElements __indirect_glDrawRangeElements
+#define glTexImage3D __indirect_glTexImage3D
+#define glTexSubImage3D __indirect_glTexSubImage3D
+
+/* 1.4 */
+#define glMultiDrawArrays __indirect_glMultiDrawArrays
+#define glMultiDrawElements __indirect_glMultiDrawElements
+#define glBlendFuncSeparate __indirect_glBlendFuncSeparate
+
+/* GL_ARB_imaging */
+#define glBlendColor __indirect_glBlendColor
+#define glBlendEquation __indirect_glBlendEquation
+#define glColorSubTable __indirect_glColorSubTable
+#define glColorTable __indirect_glColorTable
+#define glColorTableParameterfv __indirect_glColorTableParameterfv
+#define glColorTableParameteriv __indirect_glColorTableParameteriv
+#define glConvolutionFilter1D __indirect_glConvolutionFilter1D
+#define glConvolutionFilter2D __indirect_glConvolutionFilter2D
+#define glConvolutionParameterf __indirect_glConvolutionParameterf
+#define glConvolutionParameterfv __indirect_glConvolutionParameterfv
+#define glConvolutionParameteri __indirect_glConvolutionParameteri
+#define glConvolutionParameteriv __indirect_glConvolutionParameteriv
+#define glCopyColorSubTable __indirect_glCopyColorSubTable
+#define glCopyColorTable __indirect_glCopyColorTable
+#define glCopyConvolutionFilter1D __indirect_glCopyConvolutionFilter1D
+#define glCopyConvolutionFilter2D __indirect_glCopyConvolutionFilter2D
+#define glGetColorTable __indirect_glGetColorTable
+#define glGetColorTableParameterfv __indirect_glGetColorTableParameterfv
+#define glGetColorTableParameteriv __indirect_glGetColorTableParameteriv
+#define glGetConvolutionFilter __indirect_glGetConvolutionFilter
+#define glGetConvolutionParameterfv __indirect_glGetConvolutionParameterfv
+#define glGetConvolutionParameteriv __indirect_glGetConvolutionParameteriv
+#define glGetHistogram __indirect_glGetHistogram
+#define glGetHistogramParameterfv __indirect_glGetHistogramParameterfv
+#define glGetHistogramParameteriv __indirect_glGetHistogramParameteriv
+#define glGetMinmax __indirect_glGetMinmax
+#define glGetMinmaxParameterfv __indirect_glGetMinmaxParameterfv
+#define glGetMinmaxParameteriv __indirect_glGetMinmaxParameteriv
+#define glGetSeparableFilter __indirect_glGetSeparableFilter
+#define glHistogram __indirect_glHistogram
+#define glMinmax __indirect_glMinmax
+#define glResetHistogram __indirect_glResetHistogram
+#define glResetMinmax __indirect_glResetMinmax
+#define glSeparableFilter2D __indirect_glSeparableFilter2D
+
+/* ARB 1. GL_ARB_multitexture */
+#define glActiveTextureARB __indirect_glActiveTextureARB
+#define glClientActiveTextureARB __indirect_glClientActiveTextureARB
+#define glMultiTexCoord1dARB __indirect_glMultiTexCoord1dARB
+#define glMultiTexCoord1dvARB __indirect_glMultiTexCoord1dvARB
+#define glMultiTexCoord1fARB __indirect_glMultiTexCoord1fARB
+#define glMultiTexCoord1fvARB __indirect_glMultiTexCoord1fvARB
+#define glMultiTexCoord1iARB __indirect_glMultiTexCoord1iARB
+#define glMultiTexCoord1ivARB __indirect_glMultiTexCoord1ivARB
+#define glMultiTexCoord1sARB __indirect_glMultiTexCoord1sARB
+#define glMultiTexCoord1svARB __indirect_glMultiTexCoord1svARB
+#define glMultiTexCoord2dARB __indirect_glMultiTexCoord2dARB
+#define glMultiTexCoord2dvARB __indirect_glMultiTexCoord2dvARB
+#define glMultiTexCoord2fARB __indirect_glMultiTexCoord2fARB
+#define glMultiTexCoord2fvARB __indirect_glMultiTexCoord2fvARB
+#define glMultiTexCoord2iARB __indirect_glMultiTexCoord2iARB
+#define glMultiTexCoord2ivARB __indirect_glMultiTexCoord2ivARB
+#define glMultiTexCoord2sARB __indirect_glMultiTexCoord2sARB
+#define glMultiTexCoord2svARB __indirect_glMultiTexCoord2svARB
+#define glMultiTexCoord3dARB __indirect_glMultiTexCoord3dARB
+#define glMultiTexCoord3dvARB __indirect_glMultiTexCoord3dvARB
+#define glMultiTexCoord3fARB __indirect_glMultiTexCoord3fARB
+#define glMultiTexCoord3fvARB __indirect_glMultiTexCoord3fvARB
+#define glMultiTexCoord3iARB __indirect_glMultiTexCoord3iARB
+#define glMultiTexCoord3ivARB __indirect_glMultiTexCoord3ivARB
+#define glMultiTexCoord3sARB __indirect_glMultiTexCoord3sARB
+#define glMultiTexCoord3svARB __indirect_glMultiTexCoord3svARB
+#define glMultiTexCoord4dARB __indirect_glMultiTexCoord4dARB
+#define glMultiTexCoord4dvARB __indirect_glMultiTexCoord4dvARB
+#define glMultiTexCoord4fARB __indirect_glMultiTexCoord4fARB
+#define glMultiTexCoord4fvARB __indirect_glMultiTexCoord4fvARB
+#define glMultiTexCoord4iARB __indirect_glMultiTexCoord4iARB
+#define glMultiTexCoord4ivARB __indirect_glMultiTexCoord4ivARB
+#define glMultiTexCoord4sARB __indirect_glMultiTexCoord4sARB
+#define glMultiTexCoord4svARB __indirect_glMultiTexCoord4svARB
+
+/* ARB 3. ARB_transpose_matrix */
+
+#define glLoadTransposeMatrixdARB __indirect_glLoadTransposeMatrixdARB
+#define glLoadTransposeMatrixfARB __indirect_glLoadTransposeMatrixfARB
+#define glMultTransposeMatrixdARB __indirect_glMultTransposeMatrixdARB
+#define glMultTransposeMatrixfARB __indirect_glMultTransposeMatrixfARB
+
+/* ARB 5. ARB_multisample */
+
+#define glSampleCoverageARB __indirect_glSampleCoverageARB
+
+/* ARB 12. ARB_texture_compression */
+
+/* FIXME: Not yet supported. */
+
+/* ARB 14. ARB_point_parameters / GL 1.4 / NV_point_sprite */
+
+#define glPointParameterfARB __indirect_glPointParameterfARB
+#define glPointParameterfvARB __indirect_glPointParameterfvARB
+#define glPointParameteri __indirect_glPointParameteri
+#define glPointParameteriv __indirect_glPointParameteriv
+
+/* ARB 25. ARB_window_pos */
+
+#define glWindowPos2dARB __indirect_glWindowPos2dARB
+#define glWindowPos2fARB __indirect_glWindowPos2fARB
+#define glWindowPos2iARB __indirect_glWindowPos2iARB
+#define glWindowPos2sARB __indirect_glWindowPos2sARB
+#define glWindowPos2dvARB __indirect_glWindowPos2dvARB
+#define glWindowPos2fvARB __indirect_glWindowPos2fvARB
+#define glWindowPos2ivARB __indirect_glWindowPos2ivARB
+#define glWindowPos2svARB __indirect_glWindowPos2svARB
+#define glWindowPos3dARB __indirect_glWindowPos3dARB
+#define glWindowPos3fARB __indirect_glWindowPos3fARB
+#define glWindowPos3iARB __indirect_glWindowPos3iARB
+#define glWindowPos3sARB __indirect_glWindowPos3sARB
+#define glWindowPos3dvARB __indirect_glWindowPos3dvARB
+#define glWindowPos3fvARB __indirect_glWindowPos3fvARB
+#define glWindowPos3ivARB __indirect_glWindowPos3ivARB
+#define glWindowPos3svARB __indirect_glWindowPos3svARB
+
+/*
+ * Extensions
+ */
+
+#define glBlendColorEXT __indirect_glBlendColorEXT
+
+#define glPolygonOffsetEXT __indirect_glPolygonOffsetEXT
+
+#define glCopyTexSubImage3DEXT __indirect_glCopyTexSubImage3DEXT
+#define glTexImage3DEXT __indirect_glTexImage3DEXT
+#define glTexSubImage3DEXT __indirect_glTexSubImage3DEXT
+
+#define glGetTexFilterFuncSGIS __indirect_glGetTexFilterFuncSGIS
+#define glTexFilterFuncSGIS __indirect_glTexFilterFuncSGIS
+
+#define glTexSubImage1DEXT __indirect_glTexSubImage1DEXT
+#define glTexSubImage2DEXT __indirect_glTexSubImage2DEXT
+
+#define glCopyTexImage1DEXT __indirect_glCopyTexImage1DEXT
+#define glCopyTexImage2DEXT __indirect_glCopyTexImage2DEXT
+#define glCopyTexSubImage1DEXT __indirect_glCopyTexSubImage1DEXT
+#define glCopyTexSubImage2DEXT __indirect_glCopyTexSubImage2DEXT
+
+#define glGetHistogramEXT __indirect_glGetHistogramEXT
+#define glGetHistogramParameterfvEXT __indirect_glGetHistogramParameterfvEXT
+#define glGetHistogramParameterivEXT __indirect_glGetHistogramParameterivEXT
+#define glGetMinmaxEXT __indirect_glGetMinmaxEXT
+#define glGetMinmaxParameterfvEXT __indirect_glGetMinmaxParameterfvEXT
+#define glGetMinmaxParameterivEXT __indirect_glGetMinmaxParameterivEXT
+#define glHistogramEXT __indirect_glHistogramEXT
+#define glMinmaxEXT __indirect_glMinmaxEXT
+#define glResetHistogramEXT __indirect_glResetHistogramEXT
+#define glResetMinmaxEXT __indirect_glResetMinmaxEXT
+
+#define glConvolutionFilter1DEXT __indirect_glConvolutionFilter1DEXT
+#define glConvolutionFilter2DEXT __indirect_glConvolutionFilter2DEXT
+#define glConvolutionParameterfEXT __indirect_glConvolutionParameterfEXT
+#define glConvolutionParameterfvEXT __indirect_glConvolutionParameterfvEXT
+#define glConvolutionParameteriEXT __indirect_glConvolutionParameteriEXT
+#define glConvolutionParameterivEXT __indirect_glConvolutionParameterivEXT
+#define glCopyConvolutionFilter1DEXT __indirect_glCopyConvolutionFilter1DEXT
+#define glCopyConvolutionFilter2DEXT __indirect_glCopyConvolutionFilter2DEXT
+#define glGetConvolutionFilterEXT __indirect_glGetConvolutionFilterEXT
+#define glGetConvolutionParameterfvEXT __indirect_glGetConvolutionParameterfvEXT
+#define glGetConvolutionParameterivEXT __indirect_glGetConvolutionParameterivEXT
+#define glGetSeparableFilterEXT __indirect_glGetSeparableFilterEXT
+#define glSeparableFilter2DEXT __indirect_glSeparableFilter2DEXT
+
+#define glColorTableSGI __indirect_glColorTableSGI
+#define glColorTableParameterfvSGI __indirect_glColorTableParameterfvSGI
+#define glColorTableParameterivSGI __indirect_glColorTableParameterivSGI
+#define glCopyColorTableSGI __indirect_glCopyColorTableSGI
+#define glGetColorTableSGI __indirect_glGetColorTableSGI
+#define glGetColorTableParameterfvSGI __indirect_glGetColorTableParameterfvSGI
+#define glGetColorTableParameterivSGI __indirect_glGetColorTableParameterivSGI
+
+#define glPixelTexGenParameterfSGIS __indirect_glPixelTexGenParameterfSGIS
+#define glPixelTexGenParameteriSGIS __indirect_glPixelTexGenParameteriSGIS
+#define glGetPixelTexGenParameterfvSGIS __indirect_glGetPixelTexGenParameterfvSGIS
+#define glGetPixelTexGenParameterivSGIS __indirect_glGetPixelTexGenParameterivSGIS
+
+#define glTexImage4DSGIS __indirect_glTexImage4DSGIS
+#define glTexSubImage4DSGIS __indirect_glTexSubImage4DSGIS
+
+#define glAreTexturesResidentEXT __indirect_glAreTexturesResidentEXT
+#define glBindTextureEXT __indirect_glBindTextureEXT
+#define glDeleteTexturesEXT __indirect_glDeleteTexturesEXT
+#define glGenTexturesEXT __indirect_glGenTexturesEXT
+#define glIsTextureEXT __indirect_glIsTextureEXT
+#define glPrioritizeTexturesEXT __indirect_glPrioritizeTexturesEXT
+
+#define glDetailTexFuncSGIS __indirect_glDetailTexFuncSGIS
+#define glGetDetailTexFuncSGIS __indirect_glGetDetailTexFuncSGIS
+
+#define glGetSharpenTexFuncSGIS __indirect_glGetSharpenTexFuncSGIS
+#define glSharpenTexFuncSGIS __indirect_glSharpenTexFuncSGIS
+
+#define glSampleMaskSGIS __indirect_glSampleMaskSGIS
+#define glSamplePatternSGIS __indirect_glSamplePatternSGIS
+
+#define glArrayElementEXT __indirect_glArrayElementEXT
+#define glColorPointerEXT __indirect_glColorPointerEXT
+#define glDrawArraysEXT __indirect_glDrawArraysEXT
+#define glEdgeFlagPointerEXT __indirect_glEdgeFlagPointerEXT
+#define glGetPointervEXT __indirect_glGetPointervEXT
+#define glIndexPointerEXT __indirect_glIndexPointerEXT
+#define glNormalPointerEXT __indirect_glNormalPointerEXT
+#define glTexCoordPointerEXT __indirect_glTexCoordPointerEXT
+#define glVertexPointerEXT __indirect_glVertexPointerEXT
+
+#define glBlendEquationEXT __indirect_glBlendEquationEXT
+
+#define glSpriteParameterfSGIX __indirect_glSpriteParameterfSGIX
+#define glSpriteParameterfvSGIX __indirect_glSpriteParameterfvSGIX
+#define glSpriteParameteriSGIX __indirect_glSpriteParameteriSGIX
+#define glSpriteParameterivSGIX __indirect_glSpriteParameterivSGIX
+
+#define glPointParameterfEXT __indirect_glPointParameterfEXT
+#define glPointParameterfvEXT __indirect_glPointParameterfvEXT
+
+#define glGetInstrumentsSGIX __indirect_glGetInstrumentsSGIX
+#define glInstrumentsBufferSGIX __indirect_glInstrumentsBufferSGIX
+#define glPollInstrumentsSGIX __indirect_glPollInstrumentsSGIX
+#define glReadInstrumentsSGIX __indirect_glReadInstrumentsSGIX
+#define glStartInstrumentsSGIX __indirect_glStartInstrumentsSGIX
+#define glStopInstrumentsSGIX __indirect_glStopInstrumentsSGIX
+
+#define glFrameZoomSGIX __indirect_glFrameZoomSGIX
+
+#define glReferencePlaneSGIX __indirect_glReferencePlaneSGIX
+
+#define glFlushRasterSGIX __indirect_glFlushRasterSGIX
+
+#define glGetImageTransformParameterfvHP __indirect_glGetImageTransformParameterfvHP
+#define glGetImageTransformParameterivHP __indirect_glGetImageTransformParameterivHP
+#define glImageTransformParameterfHP __indirect_glImageTransformParameterfHP
+#define glImageTransformParameterfvHP __indirect_glImageTransformParameterfvHP
+#define glImageTransformParameteriHP __indirect_glImageTransformParameteriHP
+#define glImageTransformParameterivHP __indirect_glImageTransformParameterivHP
+
+#define glColorSubTableEXT __indirect_glColorSubTableEXT
+#define glCopyColorSubTableEXT __indirect_glCopyColorSubTableEXT
+
+#define glHintPGI __indirect_glHintPGI
+
+#define glColorTableEXT __indirect_glColorTableEXT
+#define glGetColorTableEXT __indirect_glGetColorTableEXT
+#define glGetColorTableParameterfvEXT __indirect_glGetColorTableParameterfvEXT
+#define glGetColorTableParameterivEXT __indirect_glGetColorTableParameterivEXT
+
+#define glGetListParameterfvSGIX __indirect_glGetListParameterfvSGIX
+#define glGetListParameterivSGIX __indirect_glGetListParameterivSGIX
+#define glListParameterfSGIX __indirect_glListParameterfSGIX
+#define glListParameterfvSGIX __indirect_glListParameterfvSGIX
+#define glListParameteriSGIX __indirect_glListParameteriSGIX
+#define glListParameterivSGIX __indirect_glListParameterivSGIX
+
+#define glIndexMaterialEXT __indirect_glIndexMaterialEXT
+
+#define glIndexFuncEXT __indirect_glIndexFuncEXT
+
+#define glLockArraysEXT __indirect_glLockArraysEXT
+#define glUnlockArraysEXT __indirect_glUnlockArraysEXT
+
+#define glCullParameterfvEXT __indirect_glCullParameterfvEXT
+#define glCullParameterdvEXT __indirect_glCullParameterdvEXT
+
+#define glBlendFuncSeparateINGR __indirect_glBlendFuncSeparateINGR
+
+#define glWindowPos2iMESA __indirect_WindowPos2iMESA
+#define glWindowPos2sMESA __indirect_WindowPos2sMESA
+#define glWindowPos2fMESA __indirect_WindowPos2fMESA
+#define glWindowPos2dMESA __indirect_WindowPos2dMESA
+#define glWindowPos2ivMESA __indirect_WindowPos2ivMESA
+#define glWindowPos2svMESA __indirect_WindowPos2svMESA
+#define glWindowPos2fvMESA __indirect_WindowPos2fvMESA
+#define glWindowPos2dvMESA __indirect_WindowPos2dvMESA
+#define glWindowPos3iMESA __indirect_WindowPos3iMESA
+#define glWindowPos3sMESA __indirect_WindowPos3sMESA
+#define glWindowPos3fMESA __indirect_WindowPos3fMESA
+#define glWindowPos3dMESA __indirect_WindowPos3dMESA
+#define glWindowPos3ivMESA __indirect_WindowPos3ivMESA
+#define glWindowPos3svMESA __indirect_WindowPos3svMESA
+#define glWindowPos3fvMESA __indirect_WindowPos3fvMESA
+#define glWindowPos3dvMESA __indirect_WindowPos3dvMESA
+#define glWindowPos4iMESA __indirect_WindowPos4iMESA
+#define glWindowPos4sMESA __indirect_WindowPos4sMESA
+#define glWindowPos4fMESA __indirect_WindowPos4fMESA
+#define glWindowPos4dMESA __indirect_WindowPos4dMESA
+#define glWindowPos4ivMESA __indirect_WindowPos4ivMESA
+#define glWindowPos4svMESA __indirect_WindowPos4svMESA
+#define glWindowPos4fvMESA __indirect_WindowPos4fvMESA
+#define glWindowPos4dvMESA __indirect_WindowPos4dvMESA
+
+#define glResizeBuffersMESA __indirect_glResizeBuffersMESA
+
+#define glActiveStencilFaceEXT __indirect_glActiveStencilFaceEXT
+
+#define glPointParameterfARB __indirect_glPointParameterfARB
+#define glPointParameterfvARB __indirect_glPointParameterfvARB
+
+#define glActiveStencilFaceEXT __indirect_glActiveStencilFaceEXT
+
+#define glWindowPos2dARB __indirect_glWindowPos2dARB
+#define glWindowPos2iARB __indirect_glWindowPos2iARB
+#define glWindowPos2fARB __indirect_glWindowPos2fARB
+#define glWindowPos2iARB __indirect_glWindowPos2iARB
+#define glWindowPos2sARB __indirect_glWindowPos2sARB
+#define glWindowPos2dvARB __indirect_glWindowPos2dvARB
+#define glWindowPos2fvARB __indirect_glWindowPos2fvARB
+#define glWindowPos2ivARB __indirect_glWindowPos2ivARB
+#define glWindowPos2svARB __indirect_glWindowPos2svARB
+#define glWindowPos3dARB __indirect_glWindowPos3dARB
+#define glWindowPos3fARB __indirect_glWindowPos3fARB
+#define glWindowPos3iARB __indirect_glWindowPos3iARB
+#define glWindowPos3sARB __indirect_glWindowPos3sARB
+#define glWindowPos3dvARB __indirect_glWindowPos3dvARB
+#define glWindowPos3fvARB __indirect_glWindowPos3fvARB
+#define glWindowPos3ivARB __indirect_glWindowPos3ivARB
+#define glWindowPos3svARB __indirect_glWindowPos3svARB
+
+/* 145. GL_EXT_secondary_color / GL 1.4 */
+
+#define glSecondaryColor3b __indirect_glSecondaryColor3b
+#define glSecondaryColor3bv __indirect_glSecondaryColor3bv
+#define glSecondaryColor3d __indirect_glSecondaryColor3d
+#define glSecondaryColor3dv __indirect_glSecondaryColor3dv
+#define glSecondaryColor3f __indirect_glSecondaryColor3f
+#define glSecondaryColor3fv __indirect_glSecondaryColor3fv
+#define glSecondaryColor3i __indirect_glSecondaryColor3i
+#define glSecondaryColor3iv __indirect_glSecondaryColor3iv
+#define glSecondaryColor3s __indirect_glSecondaryColor3s
+#define glSecondaryColor3sv __indirect_glSecondaryColor3sv
+#define glSecondaryColor3ub __indirect_glSecondaryColor3ub
+#define glSecondaryColor3ubv __indirect_glSecondaryColor3ubv
+#define glSecondaryColor3ui __indirect_glSecondaryColor3ui
+#define glSecondaryColor3uiv __indirect_glSecondaryColor3uiv
+#define glSecondaryColor3us __indirect_glSecondaryColor3us
+#define glSecondaryColor3usv __indirect_glSecondaryColor3usv
+#define glSecondaryColorPointer __indirect_glSecondaryColorPointer
+
+/* 149. GL_EXT_fog_coord / GL 1.4 */
+
+#define glFogCoordf __indirect_glFogCoordf
+#define glFogCoordd __indirect_glFogCoordd
+#define glFogCoordfv __indirect_glFogCoordfv
+#define glFogCoorddv __indirect_glFogCoorddv
+#define glFogCoordPointer __indirect_glFogCoordPointer
+
+#endif /* _INDIRECT_WRAP_H_ */
diff --git a/src/glx/x11/packrender.h b/src/glx/x11/packrender.h
new file mode 100644
index 0000000000..dc891a6e4c
--- /dev/null
+++ b/src/glx/x11/packrender.h
@@ -0,0 +1,250 @@
+/* $XFree86: xc/lib/GL/glx/packrender.h,v 1.7tsi Exp $ */
+#ifndef __GLX_packrender_h__
+#define __GLX_packrender_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.1 (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-2000 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.
+**
+*/
+
+#define NEED_GL_FUNCS_WRAPPED
+#include "glxclient.h"
+
+/*
+** The macros in this header convert the client machine's native data types to
+** wire protocol data types. The header is part of the porting layer of the
+** client library, and it is intended that hardware vendors will rewrite this
+** header to suit their own machines.
+*/
+
+/*
+** Pad a count of bytes to the nearest multiple of 4. The X protocol
+** transfers data in 4 byte quantities, so this macro is used to
+** insure the right amount of data being sent.
+*/
+#define __GLX_PAD(a) (((a)+3) & ~3)
+
+/*
+ ** Network size parameters
+ */
+#define sz_double 8
+
+/* Setup for all commands */
+#define __GLX_DECLARE_VARIABLES() \
+ __GLXcontext *gc; \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen
+
+#define __GLX_LOAD_VARIABLES() \
+ gc = __glXGetCurrentContext(); \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ cmdlen = 0; (void)cmdlen; \
+ compsize = 0; (void)compsize; \
+ pixelHeaderPC = 0; (void)pixelHeaderPC
+
+/*
+** Variable sized command support macro. This macro is used by calls
+** that are potentially larger than __GLX_SMALL_RENDER_CMD_SIZE.
+** Because of their size, they may not automatically fit in the buffer.
+** If the buffer can't hold the command then it is flushed so that
+** the command will fit in the next buffer.
+*/
+#define __GLX_BEGIN_VARIABLE(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode)
+
+#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode)
+
+#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode); \
+ pc += __GLX_RENDER_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode); \
+ pc += __GLX_RENDER_LARGE_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode); \
+ pc += __GLX_RENDER_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_3D_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode); \
+ pc += __GLX_RENDER_LARGE_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_3D_HDR_SIZE
+
+/*
+** Fixed size command support macro. This macro is used by calls that
+** are never larger than __GLX_SMALL_RENDER_CMD_SIZE. Because they
+** always fit in the buffer, and because the buffer promises to
+** maintain enough room for them, we don't need to check for space
+** before doing the storage work.
+*/
+#define __GLX_BEGIN(opcode,size) \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode)
+
+/*
+** Finish a rendering command by advancing the pc. If the pc is now past
+** the limit pointer then there is no longer room for a
+** __GLX_SMALL_RENDER_CMD_SIZE sized command, which will break the
+** assumptions present in the __GLX_BEGIN macro. In this case the
+** rendering buffer is flushed out into the X protocol stream (which may
+** or may not do I/O).
+*/
+#define __GLX_END(size) \
+ pc += size; \
+ if (pc > gc->limit) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ } else { \
+ gc->pc = pc; \
+ }
+
+/* Array copy macros */
+#define __GLX_MEM_COPY(dest,src,bytes) \
+ if (src && dest) \
+ memcpy(dest, src, bytes)
+
+/* Single item copy macros */
+#define __GLX_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
+
+#ifndef _CRAY
+#define __GLX_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
+
+#define __GLX_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
+
+#define __GLX_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
+
+#else
+#define __GLX_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
+
+#define __GLX_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
+
+#define __GLX_PUT_FLOAT(offset,a) \
+ gl_put_float((pc + offset),a)
+
+#define __GLX_PUT_DOUBLE(offset,a) \
+ gl_put_double(pc + offset, a)
+
+extern void gl_put_float(/*GLubyte *, struct cray_single*/);
+extern void gl_put_double(/*GLubyte *, struct cray_double*/);
+#endif
+
+#ifndef _CRAY
+
+#ifdef __GLX_ALIGN64
+/*
+** This can certainly be done better for a particular machine
+** architecture!
+*/
+#define __GLX_PUT_DOUBLE(offset,a) \
+ __GLX_MEM_COPY(pc + offset, &a, 8)
+#else
+#define __GLX_PUT_DOUBLE(offset,a) \
+ *((FLOAT64 *) (pc + offset)) = a
+#endif
+
+#endif
+
+#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8)
+
+#ifndef _CRAY
+#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16)
+
+#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32)
+
+#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32)
+
+#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64)
+
+#else
+#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
+ gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16)
+
+#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
+ gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32)
+
+#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
+ gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32)
+
+#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
+ gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
+
+extern gl_put_short_array (GLubyte *, short *, int);
+extern gl_put_long_array (GLubyte *, long *, int);
+extern gl_put_float_array (GLubyte *, float *, int);
+extern gl_put_double_array (GLubyte *, double *, int);
+
+#endif /* _CRAY */
+
+#endif /* !__GLX_packrender_h__ */
diff --git a/src/glx/x11/packsingle.h b/src/glx/x11/packsingle.h
new file mode 100644
index 0000000000..16b054f1e0
--- /dev/null
+++ b/src/glx/x11/packsingle.h
@@ -0,0 +1,219 @@
+/* $XFree86: xc/lib/GL/glx/packsingle.h,v 1.5tsi Exp $ */
+#ifndef __GLX_packsingle_h__
+#define __GLX_packsingle_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.1 (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-2000 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 "packrender.h"
+
+/*
+** The macros in this header convert wire protocol data types to the client
+** machine's native data types. The header is part of the porting layer of
+** the client library, and it is intended that hardware vendors will rewrite
+** this header to suit their own machines.
+*/
+
+/*
+** Dummy define to make the GetReqExtra macro happy. The value is not
+** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store
+** to req->reqType with the proper code (our extension code).
+*/
+#define X_GLXSingle 0
+
+/* Declare common variables used during a single command */
+#define __GLX_SINGLE_DECLARE_VARIABLES() \
+ __GLXcontext *gc = __glXGetCurrentContext(); \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen; \
+ Display *dpy = gc->currentDpy; \
+ xGLXSingleReq *req
+
+#define __GLX_SINGLE_LOAD_VARIABLES() \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ pixelHeaderPC = 0; (void)pixelHeaderPC; \
+ compsize = 0; (void)compsize; \
+ cmdlen = 0; (void)cmdlen
+
+/* Start a single command */
+#define __GLX_SINGLE_BEGIN(opcode,bytes) \
+ if (dpy) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ LockDisplay(dpy); \
+ GetReqExtra(GLXSingle,bytes,req); \
+ req->reqType = gc->majorOpcode; \
+ req->glxCode = opcode; \
+ req->contextTag = gc->currentContextTag; \
+ pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
+
+/* End a single command */
+#define __GLX_SINGLE_END() \
+ UnlockDisplay(dpy); \
+ SyncHandle(); \
+ }
+
+/* Store data to sending for a single command */
+#define __GLX_SINGLE_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
+
+#ifndef CRAY
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
+
+#define __GLX_SINGLE_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
+
+#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
+
+#else
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
+
+#define __GLX_SINGLE_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
+
+#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
+ gl_put_float(pc + offset, a)
+#endif
+
+/* Read support macros */
+#define __GLX_SINGLE_READ_XREPLY() \
+ (void) _XReply(dpy, (xReply*) &reply, 0, False)
+
+#define __GLX_SINGLE_GET_RETVAL(a,cast) \
+ a = (cast) reply.retval
+
+#define __GLX_SINGLE_GET_SIZE(a) \
+ a = (GLint) reply.size
+
+#ifndef _CRAY
+#define __GLX_SINGLE_GET_CHAR(p) \
+ *p = *(GLbyte *)&reply.pad3;
+
+#define __GLX_SINGLE_GET_SHORT(p) \
+ *p = *(GLshort *)&reply.pad3;
+
+#define __GLX_SINGLE_GET_LONG(p) \
+ *p = *(GLint *)&reply.pad3;
+
+#define __GLX_SINGLE_GET_FLOAT(p) \
+ *p = *(GLfloat *)&reply.pad3;
+
+#else
+#define __GLX_SINGLE_GET_CHAR(p) \
+ *p = reply.pad3 >> 24;
+
+#define __GLX_SINGLE_GET_SHORT(p) \
+ {int t = reply.pad3 >> 16; \
+ *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
+
+#define __GLX_SINGLE_GET_LONG(p) \
+ {int t = reply.pad3; \
+ *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
+
+#define PAD3OFFSET 16
+#define __GLX_SINGLE_GET_FLOAT(p) \
+ *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
+
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
+
+extern float gl_ntoh_float(GLubyte *);
+extern float gl_ntoh_double(GLubyte *);
+#endif
+
+#ifndef _CRAY
+
+#ifdef __GLX_ALIGN64
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ __GLX_MEM_COPY(p, &reply.pad3, 8)
+#else
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ *p = *(GLdouble *)&reply.pad3
+#endif
+
+#endif
+
+/* Get an array of typed data */
+#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \
+{ \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \
+{ \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+
+#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \
+{ \
+ GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16);\
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
+
+#ifndef _CRAY
+#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
+
+#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
+
+#else
+#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
+ gl_get_float_array(dpy,a,alen);
+
+#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
+ gl_get_double_array(dpy, a, alen);
+
+extern void gl_get_float_array(Display *dpy, float *a, int alen);
+extern void gl_get_double_array(Display *dpy, double *a, int alen);
+#endif
+
+#endif /* !__GLX_packsingle_h__ */
diff --git a/src/glx/x11/packvendpriv.h b/src/glx/x11/packvendpriv.h
new file mode 100644
index 0000000000..e733f49d15
--- /dev/null
+++ b/src/glx/x11/packvendpriv.h
@@ -0,0 +1,220 @@
+/* $XFree86: xc/lib/GL/glx/packvendpriv.h,v 1.5tsi Exp $ */
+#ifndef __GLX_packvendpriv_h__
+#define __GLX_packvendpriv_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.1 (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-2000 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 "packrender.h"
+
+/*
+** The macros in this header convert wire protocol data types to the client
+** machine's native data types. The header is part of the porting layer of
+** the client library, and it is intended that hardware vendors will rewrite
+** this header to suit their own machines.
+*/
+
+/*
+** Dummy define to make the GetReqExtra macro happy. The value is not
+** used, but instead the code in __GLX_VENDPRIV_BEGIN issues its own store
+** to req->reqType with the proper code (our extension code).
+*/
+#define X_GLXVendpriv 0
+
+/* Declare common variables used during a single command */
+#define __GLX_VENDPRIV_DECLARE_VARIABLES() \
+ __GLXcontext *gc = __glXGetCurrentContext(); \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen; \
+ Display *dpy = gc->currentDpy; \
+ xGLXVendorPrivateReq *req
+
+#define __GLX_VENDPRIV_LOAD_VARIABLES() \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ pixelHeaderPC = 0; (void)pixelHeaderPC; \
+ compsize = 0; (void)compsize; \
+ cmdlen = 0; (void)cmdlen
+
+/* Start a vendor private command */
+#define __GLX_VENDPRIV_BEGIN(glxcode, opcode,bytes) \
+ if (dpy) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ LockDisplay(dpy); \
+ GetReqExtra(GLXVendorPrivate,bytes,req); \
+ req->reqType = gc->majorOpcode; \
+ req->glxCode = glxcode; \
+ req->vendorCode = opcode; \
+ req->contextTag = gc->currentContextTag; \
+ pc = ((GLubyte *)(req) + sz_xGLXVendorPrivateReq)
+
+/* End a vendor private command */
+#define __GLX_VENDPRIV_END() \
+ UnlockDisplay(dpy); \
+ SyncHandle(); \
+ }
+
+/* Store data to sending for a vendor private command */
+#define __GLX_VENDPRIV_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
+
+#ifndef CRAY
+#define __GLX_VENDPRIV_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
+
+#define __GLX_VENDPRIV_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
+
+#define __GLX_VENDPRIV_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
+
+#else
+#define __GLX_VENDPRIV_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
+
+#define __GLX_VENDPRIV_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
+
+#define __GLX_VENDPRIV_PUT_FLOAT(offset,a) \
+ gl_put_float(pc + offset, a)
+#endif
+
+/* Read support macros */
+#define __GLX_VENDPRIV_READ_XREPLY() \
+ (void) _XReply(dpy, (xReply*) &reply, 0, False)
+
+#define __GLX_VENDPRIV_GET_RETVAL(a,cast) \
+ a = (cast) reply.retval
+
+#define __GLX_VENDPRIV_GET_SIZE(a) \
+ a = (GLint) reply.size
+
+#ifndef _CRAY
+#define __GLX_VENDPRIV_GET_CHAR(p) \
+ *p = *(GLbyte *)&reply.pad3;
+
+#define __GLX_VENDPRIV_GET_SHORT(p) \
+ *p = *(GLshort *)&reply.pad3;
+
+#define __GLX_VENDPRIV_GET_LONG(p) \
+ *p = *(GLint *)&reply.pad3;
+
+#define __GLX_VENDPRIV_GET_FLOAT(p) \
+ *p = *(GLfloat *)&reply.pad3;
+
+#else
+#define __GLX_VENDPRIV_GET_CHAR(p) \
+ *p = reply.pad3 >> 24;
+
+#define __GLX_VENDPRIV_GET_SHORT(p) \
+ {int t = reply.pad3 >> 16; \
+ *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
+
+#define __GLX_VENDPRIV_GET_LONG(p) \
+ {int t = reply.pad3; \
+ *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
+
+#define PAD3OFFSET 16
+#define __GLX_VENDPRIV_GET_FLOAT(p) \
+ *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
+
+#define __GLX_VENDPRIV_GET_DOUBLE(p) \
+ *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
+
+extern float gl_ntoh_float(GLubyte *);
+extern float gl_ntoh_double(GLubyte *);
+#endif
+
+#ifndef _CRAY
+
+#ifdef __GLX_ALIGN64
+#define __GLX_VENDPRIV_GET_DOUBLE(p) \
+ __GLX_MEM_COPY(p, &reply.pad3, 8)
+#else
+#define __GLX_VENDPRIV_GET_DOUBLE(p) \
+ *p = *(GLdouble *)&reply.pad3
+#endif
+
+#endif
+
+/* Get an array of typed data */
+#define __GLX_VENDPRIV_GET_VOID_ARRAY(a,alen) \
+{ \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+#define __GLX_VENDPRIV_GET_CHAR_ARRAY(a,alen) \
+{ \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+
+#define __GLX_VENDPRIV_GET_SHORT_ARRAY(a,alen) \
+{ \
+ GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+#define __GLX_VENDPRIV_GET_LONG_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
+
+#ifndef _CRAY
+#define __GLX_VENDPRIV_GET_FLOAT_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
+
+#define __GLX_VENDPRIV_GET_DOUBLE_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
+
+#else
+#define __GLX_VENDPRIV_GET_FLOAT_ARRAY(a,alen) \
+ gl_get_float_array(dpy,a,alen);
+
+#define __GLX_VENDPRIV_GET_DOUBLE_ARRAY(a,alen) \
+ gl_get_double_array(dpy, a, alen);
+
+extern void gl_get_float_array(Display *dpy, float *a, int alen);
+extern void gl_get_double_array(Display *dpy, double *a, int alen);
+#endif
+
+#endif /* !__GLX_packvendpriv_h__ */
diff --git a/src/glx/x11/pixel.c b/src/glx/x11/pixel.c
new file mode 100644
index 0000000000..b279a8d73d
--- /dev/null
+++ b/src/glx/x11/pixel.c
@@ -0,0 +1,462 @@
+/* $XFree86: xc/lib/GL/glx/pixel.c,v 1.8 2003/09/28 20:15:04 alanh Exp $ */
+/*
+** 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.1 (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-2000 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 "packrender.h"
+
+static GLubyte MsbToLsbTable[256] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+static GLubyte LowBitsMask[9] = {
+ 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
+};
+
+static GLubyte HighBitsMask[9] = {
+ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
+};
+
+
+/*
+** Copy bitmap data from clients packed memory applying unpacking modes as the
+** data is transfered into the destImage buffer. Return in modes the
+** set of pixel modes that are to be done by the server.
+*/
+static void FillBitmap(__GLXcontext *gc, GLint width, GLint height,
+ GLenum format, const GLvoid *userdata,
+ GLubyte *destImage)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storeUnpack.rowLength;
+ GLint alignment = state->storeUnpack.alignment;
+ GLint skipPixels = state->storeUnpack.skipPixels;
+ GLint skipRows = state->storeUnpack.skipRows;
+ GLint lsbFirst = state->storeUnpack.lsbFirst;
+ GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
+ GLint lowBitMask, i;
+ GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+ const GLubyte *start, *iter;
+
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+ components = __glElementsPerGroup(format,GL_BITMAP);
+ rowSize = (groupsPerRow * components + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ start = ((const GLubyte*) userdata) + skipRows * rowSize +
+ ((skipPixels * components) >> 3);
+ bitOffset = (skipPixels * components) & 7;
+ highBitMask = LowBitsMask[8-bitOffset];
+ lowBitMask = HighBitsMask[bitOffset];
+ elementsPerRow = width * components;
+ for (i = 0; i < height; i++) {
+ elementsLeft = elementsPerRow;
+ iter = start;
+ while (elementsLeft) {
+ /* First retrieve low bits from current byte */
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ } else {
+ currentByte = iter[0];
+ }
+ if (bitOffset) {
+ /* Need to read next byte to finish current byte */
+ if (elementsLeft > (8 - bitOffset)) {
+ if (lsbFirst) {
+ nextByte = MsbToLsbTable[iter[1]];
+ } else {
+ nextByte = iter[1];
+ }
+ currentByte =
+ ((currentByte & highBitMask) << bitOffset) |
+ ((nextByte & lowBitMask) >> (8 - bitOffset));
+ } else {
+ currentByte =
+ ((currentByte & highBitMask) << bitOffset);
+ }
+ }
+ if (elementsLeft >= 8) {
+ *destImage = currentByte;
+ elementsLeft -= 8;
+ } else {
+ *destImage = currentByte & HighBitsMask[elementsLeft];
+ elementsLeft = 0;
+ }
+ destImage++;
+ iter++;
+ }
+ start += rowSize;
+ }
+}
+
+/*
+** Extract array from user's data applying all pixel store modes.
+** The internal packed array format used has LSB_FIRST = FALSE and
+** ALIGNMENT = 1.
+*/
+void __glFillImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type,
+ const GLvoid *userdata, GLubyte *newimage, GLubyte *modes)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storeUnpack.rowLength;
+ GLint imageHeight = state->storeUnpack.imageHeight;
+ GLint alignment = state->storeUnpack.alignment;
+ GLint skipPixels = state->storeUnpack.skipPixels;
+ GLint skipRows = state->storeUnpack.skipRows;
+ GLint skipImages = state->storeUnpack.skipImages;
+ GLint swapBytes = state->storeUnpack.swapEndian;
+ GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+ GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
+ const GLubyte *start, *iter, *itera, *iterb, *iterc;
+ GLubyte *iter2;
+
+ if (type == GL_BITMAP) {
+ FillBitmap(gc, width, height, format, userdata, newimage);
+ } else {
+ components = __glElementsPerGroup(format,type);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+ if (imageHeight > 0) {
+ rowsPerImage = imageHeight;
+ } else {
+ rowsPerImage = height;
+ }
+
+ elementSize = __glBytesPerElement(type);
+ groupSize = elementSize * components;
+ if (elementSize == 1) swapBytes = 0;
+
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ imageSize = rowSize * rowsPerImage;
+ start = ((const GLubyte*) userdata) + skipImages * imageSize +
+ skipRows * rowSize + skipPixels * groupSize;
+ iter2 = newimage;
+ elementsPerRow = width * components;
+
+ if (swapBytes) {
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ iterb = itera;
+ for (i = 0; i < height; i++) {
+ iterc = iterb;
+ for (j = 0; j < elementsPerRow; j++) {
+ for (k = 1; k <= elementSize; k++) {
+ iter2[k-1] = iterc[elementSize - k];
+ }
+ iter2 += elementSize;
+ iterc += elementSize;
+ }
+ iterb += rowSize;
+ }
+ itera += imageSize;
+ }
+ } else {
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ if (rowSize == elementsPerRow * elementSize) {
+ /* Ha! This is mondo easy! */
+ __GLX_MEM_COPY(iter2, itera,
+ elementsPerRow * elementSize * height);
+ iter2 += elementsPerRow * elementSize * height;
+ } else {
+ iter = itera;
+ for (i = 0; i < height; i++) {
+ __GLX_MEM_COPY(iter2, iter, elementsPerRow*elementSize);
+ iter2 += elementsPerRow * elementSize;
+ iter += rowSize;
+ }
+ }
+ itera += imageSize;
+ }
+ }
+ }
+
+ /* Setup store modes that describe what we just did */
+ if (modes) {
+ if (dim == 3) {
+ GLubyte *pc = modes;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,0);
+ __GLX_PUT_LONG(20,0);
+ __GLX_PUT_LONG(24,0);
+ __GLX_PUT_LONG(28,0);
+ __GLX_PUT_LONG(32,1);
+ } else {
+ GLubyte *pc = modes;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ }
+}
+
+/*
+** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it
+** into the clients memory using the pixel store PACK modes.
+*/
+static void EmptyBitmap(__GLXcontext *gc, GLint width, GLint height,
+ GLenum format, const GLubyte *sourceImage,
+ GLvoid *userdata)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storePack.rowLength;
+ GLint alignment = state->storePack.alignment;
+ GLint skipPixels = state->storePack.skipPixels;
+ GLint skipRows = state->storePack.skipRows;
+ GLint lsbFirst = state->storePack.lsbFirst;
+ GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+ GLint sourceRowSize, sourcePadding, sourceSkip;
+ GLubyte *start, *iter;
+ GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
+ GLint writeMask, i;
+ GLubyte writeByte;
+
+ components = __glElementsPerGroup(format,GL_BITMAP);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+
+ rowSize = (groupsPerRow * components + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ sourceRowSize = (width * components + 7) >> 3;
+ sourcePadding = (sourceRowSize % 4);
+ if (sourcePadding) {
+ sourceSkip = 4 - sourcePadding;
+ } else {
+ sourceSkip = 0;
+ }
+ start = ((GLubyte*) userdata) + skipRows * rowSize +
+ ((skipPixels * components) >> 3);
+ bitOffset = (skipPixels * components) & 7;
+ highBitMask = LowBitsMask[8-bitOffset];
+ lowBitMask = HighBitsMask[bitOffset];
+ elementsPerRow = width * components;
+ for (i = 0; i < height; i++) {
+ elementsLeft = elementsPerRow;
+ iter = start;
+ writeMask = highBitMask;
+ writeByte = 0;
+ while (elementsLeft) {
+ /* Set up writeMask (to write to current byte) */
+ if (elementsLeft + bitOffset < 8) {
+ /* Need to trim writeMask */
+ writeMask &= HighBitsMask[bitOffset+elementsLeft];
+ }
+
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ } else {
+ currentByte = iter[0];
+ }
+
+ if (bitOffset) {
+ writeByte |= (sourceImage[0] >> bitOffset);
+ currentByte = (currentByte & ~writeMask) |
+ (writeByte & writeMask);
+ writeByte = (sourceImage[0] << (8 - bitOffset));
+ } else {
+ currentByte = (currentByte & ~writeMask) |
+ (sourceImage[0] & writeMask);
+ }
+
+ if (lsbFirst) {
+ iter[0] = MsbToLsbTable[currentByte];
+ } else {
+ iter[0] = currentByte;
+ }
+
+ if (elementsLeft >= 8) {
+ elementsLeft -= 8;
+ } else {
+ elementsLeft = 0;
+ }
+ sourceImage++;
+ iter++;
+ writeMask = 0xff;
+ }
+ if (writeByte) {
+ /* Some data left over that still needs writing */
+ writeMask &= lowBitMask;
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ } else {
+ currentByte = iter[0];
+ }
+ currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
+ if (lsbFirst) {
+ iter[0] = MsbToLsbTable[currentByte];
+ } else {
+ iter[0] = currentByte;
+ }
+ }
+ start += rowSize;
+ sourceImage += sourceSkip;
+ }
+}
+
+/*
+** Insert array into user's data applying all pixel store modes.
+** The packed array format from the server is LSB_FIRST = FALSE,
+** SWAP_BYTES = the current pixel storage pack mode, and ALIGNMENT = 4.
+** Named __glEmptyImage() because it is the opposite of __glFillImage().
+*/
+/* ARGSUSED */
+void __glEmptyImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type,
+ const GLubyte *sourceImage, GLvoid *userdata)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storePack.rowLength;
+ GLint imageHeight = state->storePack.imageHeight;
+ GLint alignment = state->storePack.alignment;
+ GLint skipPixels = state->storePack.skipPixels;
+ GLint skipRows = state->storePack.skipRows;
+ GLint skipImages = state->storePack.skipImages;
+ GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+ GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
+ GLint imageSize, rowsPerImage;
+ GLubyte *start, *iter, *itera;
+
+ if (type == GL_BITMAP) {
+ EmptyBitmap(gc, width, height, format, sourceImage, userdata);
+ } else {
+ components = __glElementsPerGroup(format,type);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+ if (imageHeight > 0) {
+ rowsPerImage = imageHeight;
+ } else {
+ rowsPerImage = height;
+ }
+ elementSize = __glBytesPerElement(type);
+ groupSize = elementSize * components;
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ sourceRowSize = width * groupSize;
+ sourcePadding = (sourceRowSize % 4);
+ if (sourcePadding) {
+ sourceRowSize += 4 - sourcePadding;
+ }
+ imageSize = sourceRowSize * rowsPerImage;
+ start = ((GLubyte*) userdata) + skipImages * imageSize +
+ skipRows * rowSize + skipPixels * groupSize;
+ elementsPerRow = width * components;
+
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
+ /* Ha! This is mondo easy! */
+ __GLX_MEM_COPY(itera, sourceImage,
+ elementsPerRow * elementSize * height);
+ sourceImage += elementsPerRow * elementSize * height;
+ } else {
+ iter = itera;
+ for (i = 0; i < height; i++) {
+ __GLX_MEM_COPY(iter, sourceImage,
+ elementsPerRow * elementSize);
+ sourceImage += sourceRowSize;
+ iter += rowSize;
+ }
+ }
+ itera += imageSize;
+ }
+ }
+}
diff --git a/src/glx/x11/pixelstore.c b/src/glx/x11/pixelstore.c
new file mode 100644
index 0000000000..31a3468824
--- /dev/null
+++ b/src/glx/x11/pixelstore.c
@@ -0,0 +1,301 @@
+/* $XFree86: xc/lib/GL/glx/pixelstore.c,v 1.4 2004/01/28 18:11:43 alanh Exp $ */
+/*
+** 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.1 (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-2000 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.
+**
+*/
+
+#define NEED_GL_FUNCS_WRAPPED
+#include "glxclient.h"
+#include "indirect_wrap.h"
+
+/*
+** Specify parameters that control the storage format of pixel arrays.
+*/
+void glPixelStoref(GLenum pname, GLfloat param)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = gc->client_state_private;
+ Display *dpy = gc->currentDpy;
+ GLuint a;
+
+ if (!dpy) return;
+
+ switch (pname) {
+ case GL_PACK_ROW_LENGTH:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.rowLength = a;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.imageHeight = a;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipRows = a;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipPixels = a;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipImages = a;
+ break;
+ case GL_PACK_ALIGNMENT:
+ a = (GLint) (param + 0.5);
+ switch (a) {
+ case 1: case 2: case 4: case 8:
+ state->storePack.alignment = a;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_PACK_SWAP_BYTES:
+ state->storePack.swapEndian = (param != 0);
+ break;
+ case GL_PACK_LSB_FIRST:
+ state->storePack.lsbFirst = (param != 0);
+ break;
+
+ case GL_UNPACK_ROW_LENGTH:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.rowLength = a;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.imageHeight = a;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipRows = a;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipPixels = a;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipImages = a;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ a = (GLint) (param + 0.5);
+ switch (a) {
+ case 1: case 2: case 4: case 8:
+ state->storeUnpack.alignment = a;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ state->storeUnpack.swapEndian = (param != 0);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ state->storeUnpack.lsbFirst = (param != 0);
+ break;
+ default:
+ /*
+ ** NOTE: there are currently no pixel storage commands that need to
+ ** be sent to the server. This may change in future versions
+ ** of the API, however.
+ */
+ __glXSetError(gc, GL_INVALID_ENUM);
+ break;
+ }
+}
+
+void glPixelStorei(GLenum pname, GLint param)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = gc->client_state_private;
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ switch (pname) {
+ case GL_PACK_ROW_LENGTH:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.rowLength = param;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.imageHeight = param;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipRows = param;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipPixels = param;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipImages = param;
+ break;
+ case GL_PACK_ALIGNMENT:
+ switch (param) {
+ case 1: case 2: case 4: case 8:
+ state->storePack.alignment = param;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_PACK_SWAP_BYTES:
+ state->storePack.swapEndian = (param != 0);
+ break;
+ case GL_PACK_LSB_FIRST:
+ state->storePack.lsbFirst = (param != 0);
+ break;
+
+ case GL_UNPACK_ROW_LENGTH:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.rowLength = param;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.imageHeight = param;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipRows = param;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipPixels = param;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipImages = param;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ switch (param) {
+ case 1: case 2: case 4: case 8:
+ state->storeUnpack.alignment = param;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ state->storeUnpack.swapEndian = (param != 0);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ state->storeUnpack.lsbFirst = (param != 0);
+ break;
+ default:
+ /*
+ ** NOTE: there are currently no pixel storage commands that need to
+ ** be sent to the server. This may change in future versions
+ ** of the API, however.
+ */
+ __glXSetError(gc, GL_INVALID_ENUM);
+ break;
+ }
+}
diff --git a/src/glx/x11/render2.c b/src/glx/x11/render2.c
new file mode 100644
index 0000000000..db60544c6a
--- /dev/null
+++ b/src/glx/x11/render2.c
@@ -0,0 +1,512 @@
+/* $XFree86: xc/lib/GL/glx/render2.c,v 1.6 2004/01/31 09:29:33 alanh Exp $ */
+/*
+** 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.1 (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-2000 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 "packrender.h"
+#include "size.h"
+
+/*
+** This file contains routines that might need to be transported as
+** GLXRender or GLXRenderLarge commands, and these commands don't
+** use the pixel header. See renderpix.c for those routines.
+*/
+
+void glCallLists(GLsizei n, GLenum type, const GLvoid *lists)
+{
+ __GLX_DECLARE_VARIABLES();
+ __GLX_LOAD_VARIABLES();
+
+ compsize = __glCallLists_size(n,type);
+ cmdlen = __GLX_PAD(12 + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_CallLists,cmdlen);
+ __GLX_PUT_LONG(4,n);
+ __GLX_PUT_LONG(8,type);
+ __GLX_PUT_CHAR_ARRAY(12,lists,compsize);
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CallLists,cmdlen+4);
+ __GLX_PUT_LONG(8,n);
+ __GLX_PUT_LONG(12,type);
+ __glXSendLargeCommand(gc, pc, 16, lists, compsize);
+ }
+}
+
+void glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+ GLint order, const GLdouble *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glEvalComputeK(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (stride < k || order <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * order * __GLX_SIZE_FLOAT64;
+ cmdlen = 28+compsize;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map1d,cmdlen);
+ __GLX_PUT_DOUBLE(4,u1);
+ __GLX_PUT_DOUBLE(12,u2);
+ __GLX_PUT_LONG(20,target);
+ __GLX_PUT_LONG(24,order);
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 3
+ ** longs preceeding
+ */
+ __glFillMap1d(k, order, stride, pnts, (pc+28));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d,cmdlen+4);
+ __GLX_PUT_DOUBLE(8,u1);
+ __GLX_PUT_DOUBLE(16,u2);
+ __GLX_PUT_LONG(24,target);
+ __GLX_PUT_LONG(28,order);
+
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 3
+ ** longs preceeding
+ */
+ if (stride != k) {
+ GLubyte *buf;
+
+ buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ __glFillMap1d(k, order, stride, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 32, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 32, pnts, compsize);
+ }
+ }
+}
+
+void glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glEvalComputeK(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (stride < k || order <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * order * __GLX_SIZE_FLOAT32;
+ cmdlen = 20+compsize;
+ if (!gc->currentDpy) return;
+
+ /*
+ ** The order that arguments are packed is different from the order
+ ** for glMap1d.
+ */
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map1f,cmdlen);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_FLOAT(8,u1);
+ __GLX_PUT_FLOAT(12,u2);
+ __GLX_PUT_LONG(16,order);
+ __glFillMap1f(k, order, stride, pnts, (GLubyte*) (pc+20));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f,cmdlen+4);
+ __GLX_PUT_LONG(8,target);
+ __GLX_PUT_FLOAT(12,u1);
+ __GLX_PUT_FLOAT(16,u2);
+ __GLX_PUT_LONG(20,order);
+
+ if (stride != k) {
+ GLubyte *buf;
+
+ buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ __glFillMap1f(k, order, stride, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 24, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 24, pnts, compsize);
+ }
+ }
+}
+
+void glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, GLint uord,
+ GLdouble v1, GLdouble v2, GLint vstr, GLint vord,
+ const GLdouble *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glEvalComputeK(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * uord * vord * __GLX_SIZE_FLOAT64;
+ cmdlen = 48+compsize;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map2d,cmdlen);
+ __GLX_PUT_DOUBLE(4,u1);
+ __GLX_PUT_DOUBLE(12,u2);
+ __GLX_PUT_DOUBLE(20,v1);
+ __GLX_PUT_DOUBLE(28,v2);
+ __GLX_PUT_LONG(36,target);
+ __GLX_PUT_LONG(40,uord);
+ __GLX_PUT_LONG(44,vord);
+ /*
+ ** Pack into a u-major ordering.
+ ** NOTE: the doubles that follow are not aligned because of 5
+ ** longs preceeding
+ */
+ __glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble*) (pc+48));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d,cmdlen+4);
+ __GLX_PUT_DOUBLE(8,u1);
+ __GLX_PUT_DOUBLE(16,u2);
+ __GLX_PUT_DOUBLE(24,v1);
+ __GLX_PUT_DOUBLE(32,v2);
+ __GLX_PUT_LONG(40,target);
+ __GLX_PUT_LONG(44,uord);
+ __GLX_PUT_LONG(48,vord);
+
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 5
+ ** longs preceeding
+ */
+ if ((vstr != k) || (ustr != k*vord)) {
+ GLdouble *buf;
+
+ buf = (GLdouble *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 52, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 52, pnts, compsize);
+ }
+ }
+}
+
+void glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, GLint uord,
+ GLfloat v1, GLfloat v2, GLint vstr, GLint vord,
+ const GLfloat *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glEvalComputeK(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * uord * vord * __GLX_SIZE_FLOAT32;
+ cmdlen = 32+compsize;
+ if (!gc->currentDpy) return;
+
+ /*
+ ** The order that arguments are packed is different from the order
+ ** for glMap2d.
+ */
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map2f,cmdlen);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_FLOAT(8,u1);
+ __GLX_PUT_FLOAT(12,u2);
+ __GLX_PUT_LONG(16,uord);
+ __GLX_PUT_FLOAT(20,v1);
+ __GLX_PUT_FLOAT(24,v2);
+ __GLX_PUT_LONG(28,vord);
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat*) (pc+32));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f,cmdlen+4);
+ __GLX_PUT_LONG(8,target);
+ __GLX_PUT_FLOAT(12,u1);
+ __GLX_PUT_FLOAT(16,u2);
+ __GLX_PUT_LONG(20,uord);
+ __GLX_PUT_FLOAT(24,v1);
+ __GLX_PUT_FLOAT(28,v2);
+ __GLX_PUT_LONG(32,vord);
+
+ if ((vstr != k) || (ustr != k*vord)) {
+ GLfloat *buf;
+
+ buf = (GLfloat *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 36, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 36, pnts, compsize);
+ }
+ }
+}
+
+void glPixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (mapsize < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = mapsize * __GLX_SIZE_FLOAT32;
+ cmdlen = 12+compsize;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_PixelMapfv,cmdlen);
+ __GLX_PUT_LONG(4,map);
+ __GLX_PUT_LONG(8,mapsize);
+ __GLX_PUT_FLOAT_ARRAY(12,values,mapsize);
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_PixelMapfv,cmdlen+4);
+ __GLX_PUT_LONG(8,map);
+ __GLX_PUT_LONG(12,mapsize);
+ __glXSendLargeCommand(gc, pc, 16, values, compsize);
+ }
+}
+
+void glPixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (mapsize < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = mapsize * __GLX_SIZE_CARD32;
+ cmdlen = 12+compsize;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_PixelMapuiv,cmdlen);
+ __GLX_PUT_LONG(4,map);
+ __GLX_PUT_LONG(8,mapsize);
+ __GLX_PUT_LONG_ARRAY(12,values,mapsize);
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_PixelMapuiv,cmdlen+4);
+ __GLX_PUT_LONG(8,map);
+ __GLX_PUT_LONG(12,mapsize);
+ __glXSendLargeCommand(gc, pc, 16, values, compsize);
+ }
+}
+
+void glPixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (mapsize < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = mapsize * __GLX_SIZE_CARD16;
+ cmdlen = __GLX_PAD(12 + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_PixelMapusv,cmdlen);
+ __GLX_PUT_LONG(4,map);
+ __GLX_PUT_LONG(8,mapsize);
+ __GLX_PUT_SHORT_ARRAY(12,values,mapsize);
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_PixelMapusv,cmdlen+4);
+ __GLX_PUT_LONG(8,map);
+ __GLX_PUT_LONG(12,mapsize);
+ __glXSendLargeCommand(gc, pc, 16, values, compsize);
+ }
+}
+
+void glEnable(GLenum cap)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ switch(cap) {
+ case GL_COLOR_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_VERTEX_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ glEnableClientState(cap);
+ return;
+ default:
+ break;
+ }
+
+ __GLX_BEGIN(X_GLrop_Enable,8);
+ __GLX_PUT_LONG(4,cap);
+ __GLX_END(8);
+}
+
+void glDisable(GLenum cap)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ switch(cap) {
+ case GL_COLOR_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_VERTEX_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ glDisableClientState(cap);
+ return;
+ default:
+ break;
+ }
+
+ __GLX_BEGIN(X_GLrop_Disable,8);
+ __GLX_PUT_LONG(4,cap);
+ __GLX_END(8);
+}
+
+void glSampleCoverageARB( GLfloat value, GLboolean invert )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ __GLX_BEGIN(X_GLrop_SampleCoverageARB,12);
+ __GLX_PUT_FLOAT(4,value);
+ __GLX_PUT_CHAR(8,invert);
+ __GLX_END(12);
+}
+
+void glSampleMaskSGIS( GLfloat value, GLboolean invert )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ __GLX_BEGIN(X_GLvop_SampleMaskSGIS,12);
+ __GLX_PUT_FLOAT(4,value);
+ __GLX_PUT_CHAR(8,invert);
+ __GLX_END(12);
+}
+
+void glSamplePatternSGIS( GLenum pass )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ __GLX_BEGIN(X_GLvop_SamplePatternSGIS,8);
+ __GLX_PUT_LONG(4,pass);
+ __GLX_END(8);
+}
diff --git a/src/glx/x11/renderpix.c b/src/glx/x11/renderpix.c
new file mode 100644
index 0000000000..2f5346ad67
--- /dev/null
+++ b/src/glx/x11/renderpix.c
@@ -0,0 +1,906 @@
+/* $XFree86: xc/lib/GL/glx/renderpix.c,v 1.5 2003/09/28 20:15:04 alanh Exp $ */
+/*
+** 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.1 (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-2000 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 "packrender.h"
+
+/*
+** This file contains routines that deal with unpacking data from client
+** memory using the pixel store unpack modes and then shipping it to
+** the server. For all of these routines (except glPolygonStipple) there
+** are two forms of the transport - small and large. Small commands are
+** the commands that fit into the "rendering" transport buffer. Large
+** commands are sent to the server in chunks by __glXSendLargeCommand.
+**
+** All of the commands send over a pixel header (see glxproto.h) which
+** describes the pixel store modes that the server must use to properly
+** handle the data. Any pixel store modes not done by the __glFillImage
+** routine are passed on to the server.
+*/
+
+/*
+** Send a large image to the server. If necessary, a buffer is allocated
+** to hold the unpacked data that is copied from the clients memory.
+*/
+static void SendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
+ GLint width, GLint height, GLint depth,
+ GLenum format, GLenum type, const GLvoid *src,
+ GLubyte *pc, GLubyte *modes)
+{
+ if (!gc->fastImageUnpack) {
+ /* Allocate a temporary holding buffer */
+ GLubyte *buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+
+ /* Apply pixel store unpack modes to copy data into buf */
+ (*gc->fillImage)(gc, dim, width, height, depth, format, type, src, buf,
+ modes);
+
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
+
+ /* Free buffer */
+ Xfree((char*) buf);
+ } else {
+ /* Just send the data straight as is */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize);
+ }
+}
+
+/*
+** Send a large null image to the server. To be backwards compatible,
+** data must be sent to the server even when the application has passed
+** a null pointer into glTexImage1D, glTexImage2D or glTexImage3D.
+*/
+static void SendLargeNULLImage(__GLXcontext *gc, GLint compsize,
+ GLint width, GLint height, GLint depth,
+ GLenum format, GLenum type, const GLvoid *src,
+ GLubyte *pc, GLubyte *modes)
+{
+ GLubyte *buf = (GLubyte *) Xmalloc(compsize);
+
+ /* Allocate a temporary holding buffer */
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
+
+ /* Free buffer */
+ Xfree((char*) buf);
+}
+
+/************************************************************************/
+
+void glPolygonStipple(const GLubyte *mask)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(32, 32, 1, GL_COLOR_INDEX, GL_BITMAP);
+ cmdlen = __GLX_PAD(__GLX_POLYGONSTIPPLE_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ __GLX_BEGIN(X_GLrop_PolygonStipple,cmdlen);
+ pc += __GLX_RENDER_HDR_SIZE;
+ pixelHeaderPC = pc;
+ pc += __GLX_PIXEL_HDR_SIZE;
+ (*gc->fillImage)(gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
+ mask, pc, pixelHeaderPC);
+ __GLX_END(__GLX_PAD(compsize));
+}
+
+void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
+ GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(width, height, 1, GL_COLOR_INDEX, GL_BITMAP);
+ cmdlen = __GLX_PAD(__GLX_BITMAP_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_Bitmap,cmdlen);
+ __GLX_PUT_LONG(0,width);
+ __GLX_PUT_LONG(4,height);
+ __GLX_PUT_FLOAT(8,xorig);
+ __GLX_PUT_FLOAT(12,yorig);
+ __GLX_PUT_FLOAT(16,xmove);
+ __GLX_PUT_FLOAT(20,ymove);
+ pc += __GLX_BITMAP_HDR_SIZE;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 2, width, height, 1, GL_COLOR_INDEX,
+ GL_BITMAP, bitmap, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_Bitmap,cmdlen+4);
+ __GLX_PUT_LONG(0,width);
+ __GLX_PUT_LONG(4,height);
+ __GLX_PUT_FLOAT(8,xorig);
+ __GLX_PUT_FLOAT(12,yorig);
+ __GLX_PUT_FLOAT(16,xmove);
+ __GLX_PUT_FLOAT(20,ymove);
+ pc += __GLX_BITMAP_HDR_SIZE;
+ SendLargeImage(gc, compsize, 2, width, height, 1, GL_COLOR_INDEX,
+ GL_BITMAP, bitmap, pc, pixelHeaderPC);
+ }
+}
+
+void glTexImage1D(GLenum target, GLint level, GLint components,
+ GLsizei width, GLint border, GLenum format, GLenum type,
+ const GLvoid *image)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (target == GL_PROXY_TEXTURE_1D) {
+ compsize = 0;
+ } else {
+ compsize = __glImageSize(width, 1, 1, format, type);
+ }
+ cmdlen = __GLX_PAD(__GLX_TEXIMAGE_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_TexImage1D,cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,components);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(20,border);
+ __GLX_PUT_LONG(24,format);
+ __GLX_PUT_LONG(28,type);
+ pc += __GLX_TEXIMAGE_HDR_SIZE;
+ if (compsize > 0 && image != NULL) {
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type,
+ image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_TexImage1D,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,components);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,1);
+ __GLX_PUT_LONG(20,border);
+ __GLX_PUT_LONG(24,format);
+ __GLX_PUT_LONG(28,type);
+ pc += __GLX_TEXIMAGE_HDR_SIZE;
+ if (image != NULL) {
+ SendLargeImage(gc, compsize, 1, width, 1, 1, format,
+ type, image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ {
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ SendLargeNULLImage(gc, compsize, width, 1, 1, format,
+ type, image, pc, pixelHeaderPC);
+ }
+ }
+}
+
+void glTexImage2D(GLenum target, GLint level, GLint components,
+ GLsizei width, GLsizei height, GLint border, GLenum format,
+ GLenum type, const GLvoid *image)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (target == GL_PROXY_TEXTURE_2D ||
+ target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ compsize = 0;
+ } else {
+ compsize = __glImageSize(width, height, 1, format, type);
+ }
+ cmdlen = __GLX_PAD(__GLX_TEXIMAGE_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_TexImage2D,cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,components);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_PUT_LONG(20,border);
+ __GLX_PUT_LONG(24,format);
+ __GLX_PUT_LONG(28,type);
+ pc += __GLX_TEXIMAGE_HDR_SIZE;
+ if (compsize > 0 && image != NULL) {
+ (*gc->fillImage)(gc, 2, width, height, 1, format, type,
+ image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_TexImage2D,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,components);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_PUT_LONG(20,border);
+ __GLX_PUT_LONG(24,format);
+ __GLX_PUT_LONG(28,type);
+ pc += __GLX_TEXIMAGE_HDR_SIZE;
+ if (image != NULL) {
+ SendLargeImage(gc, compsize, 2, width, height, 1, format,
+ type, image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ {
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ SendLargeNULLImage(gc, compsize, width, height, 1, format,
+ type, image, pc, pixelHeaderPC);
+ }
+ }
+}
+
+void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type,
+ const GLvoid *image)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(width, height, 1, format, type);
+ cmdlen = __GLX_PAD(__GLX_DRAWPIXELS_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_DrawPixels,cmdlen);
+ __GLX_PUT_LONG(0,width);
+ __GLX_PUT_LONG(4,height);
+ __GLX_PUT_LONG(8,format);
+ __GLX_PUT_LONG(12,type);
+ pc += __GLX_DRAWPIXELS_HDR_SIZE;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 2, width, height, 1, format, type,
+ image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_DrawPixels,cmdlen+4);
+ __GLX_PUT_LONG(0,width);
+ __GLX_PUT_LONG(4,height);
+ __GLX_PUT_LONG(8,format);
+ __GLX_PUT_LONG(12,type);
+ pc += __GLX_DRAWPIXELS_HDR_SIZE;
+ SendLargeImage(gc, compsize, 2, width, height, 1, format,
+ type, image, pc, pixelHeaderPC);
+ }
+}
+
+static void __glx_TexSubImage1D2D(GLshort opcode, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLsizei width,
+ GLsizei height, GLenum format, GLenum type,
+ const GLvoid *image, GLint dim)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (image == NULL) {
+ compsize = 0;
+ } else {
+ compsize = __glImageSize(width, height, 1, format, type);
+ }
+
+ cmdlen = __GLX_PAD(__GLX_TEXSUBIMAGE_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode, cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,xoffset);
+ __GLX_PUT_LONG(12,yoffset);
+ __GLX_PUT_LONG(16,width);
+ __GLX_PUT_LONG(20,height);
+ __GLX_PUT_LONG(24,format);
+ __GLX_PUT_LONG(28,type);
+ if (image == NULL) {
+ __GLX_PUT_LONG(32,GL_TRUE);
+ } else {
+ __GLX_PUT_LONG(32,GL_FALSE);
+ }
+ pc += __GLX_TEXSUBIMAGE_HDR_SIZE;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, dim, width, height, 1, format, type, image,
+ pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,xoffset);
+ __GLX_PUT_LONG(12,yoffset);
+ __GLX_PUT_LONG(16,width);
+ __GLX_PUT_LONG(20,height);
+ __GLX_PUT_LONG(24,format);
+ __GLX_PUT_LONG(28,type);
+ if (image == NULL) {
+ __GLX_PUT_LONG(32,GL_TRUE);
+ } else {
+ __GLX_PUT_LONG(32,GL_FALSE);
+ }
+ pc += __GLX_TEXSUBIMAGE_HDR_SIZE;
+ SendLargeImage(gc, compsize, dim, width, height, 1,
+ format, type, image, pc, pixelHeaderPC);
+ }
+}
+
+void glTexSubImage1D(GLenum target, GLint level, GLint xoffset,
+ GLsizei width, GLenum format, GLenum type,
+ const GLvoid *image)
+{
+ __glx_TexSubImage1D2D(X_GLrop_TexSubImage1D, target, level, xoffset,
+ 0, width, 1, format, type, image, 1);
+}
+
+void glTexSubImage2D(GLenum target, GLint level, GLint xoffset,
+ GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid *image)
+{
+ __glx_TexSubImage1D2D(X_GLrop_TexSubImage2D, target, level, xoffset,
+ yoffset, width, height, format, type, image, 2);
+}
+
+void glColorTable(GLenum target, GLenum internalformat, GLsizei width,
+ GLenum format, GLenum type, const GLvoid *table)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_PROXY_COLOR_TABLE:
+ case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ compsize = 0;
+ break;
+ default:
+ compsize = __glImageSize(width, 1, 1, format, type);
+ break;
+ }
+ cmdlen = __GLX_PAD(__GLX_COLOR_TABLE_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) {
+ return;
+ }
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_ColorTable, (short)cmdlen);
+ __GLX_PUT_LONG(0, (long)target);
+ __GLX_PUT_LONG(4, (long)internalformat);
+ __GLX_PUT_LONG(8, width);
+ __GLX_PUT_LONG(12, (long)format);
+ __GLX_PUT_LONG(16, (long)type);
+ pc += __GLX_COLOR_TABLE_HDR_SIZE;
+ if (compsize > 0 && table != NULL) {
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type, table, pc,
+ pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0, GL_FALSE);
+ __GLX_PUT_CHAR(1, GL_FALSE);
+ __GLX_PUT_CHAR(2, 0);
+ __GLX_PUT_CHAR(3, 0);
+ __GLX_PUT_LONG(4, 0);
+ __GLX_PUT_LONG(8, 0);
+ __GLX_PUT_LONG(12, 0);
+ __GLX_PUT_LONG(16, 1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_ColorTable, cmdlen+4);
+ __GLX_PUT_LONG(0, (long)target);
+ __GLX_PUT_LONG(4, (long)internalformat);
+ __GLX_PUT_LONG(8, width);
+ __GLX_PUT_LONG(12, (long)format);
+ __GLX_PUT_LONG(16, (long)type);
+ pc += __GLX_COLOR_TABLE_HDR_SIZE;
+ SendLargeImage(gc, compsize, 1, width, 1, 1, format,
+ type, table, pc, pixelHeaderPC);
+ }
+}
+
+void glColorSubTable(GLenum target, GLsizei start, GLsizei count,
+ GLenum format, GLenum type, const GLvoid *table)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(count, 1, 1, format, type);
+ cmdlen = __GLX_PAD(__GLX_COLOR_SUBTABLE_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) {
+ return;
+ }
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_ColorSubTable, (short)cmdlen);
+ __GLX_PUT_LONG(0, (long)target);
+ __GLX_PUT_LONG(4, start);
+ __GLX_PUT_LONG(8, count);
+ __GLX_PUT_LONG(12, (long)format);
+ __GLX_PUT_LONG(16, (long)type);
+ pc += __GLX_COLOR_SUBTABLE_HDR_SIZE;
+ if (compsize > 0 && table != NULL) {
+ (*gc->fillImage)(gc, 1, start+count, 1, 1, format, type, table, pc,
+ pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0, GL_FALSE);
+ __GLX_PUT_CHAR(1, GL_FALSE);
+ __GLX_PUT_CHAR(2, 0);
+ __GLX_PUT_CHAR(3, 0);
+ __GLX_PUT_LONG(4, 0);
+ __GLX_PUT_LONG(8, 0);
+ __GLX_PUT_LONG(12, 0);
+ __GLX_PUT_LONG(16, 1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_ColorSubTable, cmdlen+4);
+ __GLX_PUT_LONG(0, (long)target);
+ __GLX_PUT_LONG(4, start);
+ __GLX_PUT_LONG(8, count);
+ __GLX_PUT_LONG(12, (long)format);
+ __GLX_PUT_LONG(16, (long)type);
+ pc += __GLX_COLOR_SUBTABLE_HDR_SIZE;
+ SendLargeImage(gc, compsize, 1, start+count, 1, 1, format,
+ type, table, pc, pixelHeaderPC);
+ }
+}
+
+static void __glx_ConvolutionFilter1D2D(GLshort opcode, GLint dim,
+ GLenum target,
+ GLenum internalformat,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid *image)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(width, height, 1, format, type);
+ cmdlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode, cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,internalformat);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,height);
+ __GLX_PUT_LONG(16,format);
+ __GLX_PUT_LONG(20,type);
+ pc += __GLX_CONV_FILT_HDR_SIZE;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, dim, width, height, 1, format, type,
+ image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,internalformat);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,height);
+ __GLX_PUT_LONG(16,format);
+ __GLX_PUT_LONG(20,type);
+ pc += __GLX_CONV_FILT_HDR_SIZE;
+ SendLargeImage(gc, compsize, dim, width, height, 1, format,
+ type, image, pc, pixelHeaderPC);
+ }
+}
+
+void glConvolutionFilter1D(GLenum target, GLenum internalformat,
+ GLsizei width, GLenum format,
+ GLenum type, const GLvoid *image)
+{
+ __glx_ConvolutionFilter1D2D(X_GLrop_ConvolutionFilter1D, 1, target,
+ internalformat, width, 1, format, type,
+ image);
+}
+
+void glConvolutionFilter2D(GLenum target, GLenum internalformat,
+ GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *image)
+{
+ __glx_ConvolutionFilter1D2D(X_GLrop_ConvolutionFilter2D, 2, target,
+ internalformat, width, height, format, type,
+ image);
+}
+
+void glSeparableFilter2D(GLenum target, GLenum internalformat,
+ GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *row,
+ const GLvoid *column)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(width, 1, 1, format, type);
+ compsize2 = __glImageSize(height, 1, 1, format, type);
+ totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
+ hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE);
+ image1len = __GLX_PAD(compsize);
+ image2len = __GLX_PAD(compsize2);
+ cmdlen = totalhdrlen + image1len + image2len;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,internalformat);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,height);
+ __GLX_PUT_LONG(16,format);
+ __GLX_PUT_LONG(20,type);
+ pc += hdrlen;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type,
+ row, pc, pixelHeaderPC);
+ pc += image1len;
+ }
+ if (compsize2 > 0) {
+ (*gc->fillImage)(gc, 1, height, 1, 1, format, type,
+ column, pc, NULL);
+ pc += image2len;
+ }
+ if ((compsize == 0) && (compsize2 == 0)) {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,1);
+ }
+ __GLX_END(0);
+ } else {
+ GLint bufsize;
+
+ bufsize = image1len + image2len;
+
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,internalformat);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,height);
+ __GLX_PUT_LONG(16,format);
+ __GLX_PUT_LONG(20,type);
+ pc += hdrlen;
+
+ if (!gc->fastImageUnpack) {
+ /* Allocate a temporary holding buffer */
+ GLubyte *buf = (GLubyte *) Xmalloc(bufsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type, row, buf, pixelHeaderPC);
+
+ (*gc->fillImage)(gc, 1, height, 1, 1, format, type, column,
+ buf + image1len, pixelHeaderPC);
+
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, (GLint)(pc - gc->pc), buf, bufsize);
+ /* Free buffer */
+ Xfree((char*) buf);
+ } else {
+ /* Just send the data straight as is */
+ __glXSendLargeCommand(gc, gc->pc, (GLint)(pc - gc->pc), pc, bufsize);
+ }
+ }
+}
+
+void glTexImage3D(GLenum target, GLint level, GLint internalformat,
+ GLsizei width, GLsizei height, GLsizei depth, GLint border,
+ GLenum format, GLenum type, const GLvoid *image)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ((target == GL_PROXY_TEXTURE_3D) || (image == NULL)) {
+ compsize = 0;
+ } else {
+ compsize = __glImageSize(width, height, depth, format, type);
+ }
+ cmdlen = __GLX_PAD(__GLX_TEXIMAGE_3D_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(X_GLrop_TexImage3D,cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,internalformat);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_PUT_LONG(20,depth);
+ __GLX_PUT_LONG(24,0); /* size4d */
+ __GLX_PUT_LONG(28,border);
+ __GLX_PUT_LONG(32,format);
+ __GLX_PUT_LONG(36,type);
+ if (image == NULL) {
+ __GLX_PUT_LONG(40,GL_TRUE);
+ } else {
+ __GLX_PUT_LONG(40,GL_FALSE);
+ }
+ pc += __GLX_TEXIMAGE_3D_HDR_SIZE;
+ if (compsize > 0 && image != NULL) {
+ (*gc->fillImage)(gc, 3, width, height, depth, format, type,
+ image, pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,0);
+ __GLX_PUT_LONG(20,0);
+ __GLX_PUT_LONG(24,0);
+ __GLX_PUT_LONG(28,0);
+ __GLX_PUT_LONG(32,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(X_GLrop_TexImage3D,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,internalformat);
+ __GLX_PUT_LONG(12,width);
+ __GLX_PUT_LONG(16,height);
+ __GLX_PUT_LONG(20,depth);
+ __GLX_PUT_LONG(24,0); /* size4d */
+ __GLX_PUT_LONG(28,border);
+ __GLX_PUT_LONG(32,format);
+ __GLX_PUT_LONG(36,type);
+ if (image == NULL) {
+ __GLX_PUT_LONG(40,GL_TRUE);
+ } else {
+ __GLX_PUT_LONG(40,GL_FALSE);
+ }
+ pc += __GLX_TEXIMAGE_3D_HDR_SIZE;
+ SendLargeImage(gc, compsize, 3, width, height, depth, format,
+ type, image, pc, pixelHeaderPC);
+ }
+}
+
+void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+ GLint zoffset, GLsizei width, GLsizei height,
+ GLsizei depth, GLenum format, GLenum type,
+ const GLvoid *image)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (image == NULL) {
+ compsize = 0;
+ } else {
+ compsize = __glImageSize(width, height, depth, format, type);
+ }
+ cmdlen = __GLX_PAD(__GLX_TEXSUBIMAGE_3D_CMD_HDR_SIZE + compsize);
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(X_GLrop_TexSubImage3D,cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,xoffset);
+ __GLX_PUT_LONG(12,yoffset);
+ __GLX_PUT_LONG(16,zoffset);
+ __GLX_PUT_LONG(20,0); /* woffset */
+ __GLX_PUT_LONG(24,width);
+ __GLX_PUT_LONG(28,height);
+ __GLX_PUT_LONG(32,depth);
+ __GLX_PUT_LONG(36,0); /* size4d */
+ __GLX_PUT_LONG(40,format);
+ __GLX_PUT_LONG(44,type);
+ if (image == NULL) {
+ __GLX_PUT_LONG(48,GL_TRUE);
+ } else {
+ __GLX_PUT_LONG(48,GL_FALSE);
+ }
+ pc += __GLX_TEXSUBIMAGE_3D_HDR_SIZE;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 3, width, height, depth, format, type, image,
+ pc, pixelHeaderPC);
+ } else {
+ /* Setup default store modes */
+ GLubyte *pc = pixelHeaderPC;
+ __GLX_PUT_CHAR(0,GL_FALSE);
+ __GLX_PUT_CHAR(1,GL_FALSE);
+ __GLX_PUT_CHAR(2,0);
+ __GLX_PUT_CHAR(3,0);
+ __GLX_PUT_LONG(4,0);
+ __GLX_PUT_LONG(8,0);
+ __GLX_PUT_LONG(12,0);
+ __GLX_PUT_LONG(16,0);
+ __GLX_PUT_LONG(20,0);
+ __GLX_PUT_LONG(24,0);
+ __GLX_PUT_LONG(28,0);
+ __GLX_PUT_LONG(32,1);
+ }
+ __GLX_END(__GLX_PAD(compsize));
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(X_GLrop_TexSubImage3D,
+ cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,level);
+ __GLX_PUT_LONG(8,xoffset);
+ __GLX_PUT_LONG(12,yoffset);
+ __GLX_PUT_LONG(16,zoffset);
+ __GLX_PUT_LONG(20,0); /* woffset */
+ __GLX_PUT_LONG(24,width);
+ __GLX_PUT_LONG(28,height);
+ __GLX_PUT_LONG(32,depth);
+ __GLX_PUT_LONG(36,0); /* size4d */
+ __GLX_PUT_LONG(40,format);
+ __GLX_PUT_LONG(44,type);
+ if (image == NULL) {
+ __GLX_PUT_LONG(48,GL_TRUE);
+ } else {
+ __GLX_PUT_LONG(48,GL_FALSE);
+ }
+ pc += __GLX_TEXSUBIMAGE_3D_HDR_SIZE;
+ SendLargeImage(gc, compsize, 3, width, height, depth, format, type,
+ image, pc, pixelHeaderPC);
+ }
+}
diff --git a/src/glx/x11/single2.c b/src/glx/x11/single2.c
new file mode 100644
index 0000000000..693c28df8f
--- /dev/null
+++ b/src/glx/x11/single2.c
@@ -0,0 +1,1097 @@
+/* $XFree86: xc/lib/GL/glx/single2.c,v 1.10 2004/02/11 19:48:16 dawes Exp $ */
+/*
+** 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.1 (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-2000 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.
+**
+*/
+
+#define NEED_GL_FUNCS_WRAPPED
+#include <stdio.h>
+#include "glxclient.h"
+#include "packsingle.h"
+#include "glxextensions.h"
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixf(GLfloat m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLfloat tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixb(GLboolean m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLboolean tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixd(GLdouble m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLdouble tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixi(GLint m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLint tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+GLenum glGetError(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLuint retval = GL_NO_ERROR;
+ xGLXGetErrorReply reply;
+
+ if (gc->error) {
+ /* Use internal error first */
+ retval = gc->error;
+ gc->error = GL_NO_ERROR;
+ return retval;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetError,0);
+ __GLX_SINGLE_READ_XREPLY();
+ retval = reply.error;
+ __GLX_SINGLE_END();
+
+ return retval;
+}
+
+void glGetClipPlane(GLenum plane, GLdouble *equation)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetClipPlane,4);
+ __GLX_SINGLE_PUT_LONG(0,plane);
+ __GLX_SINGLE_READ_XREPLY();
+ if (reply.length == 8) {
+ __GLX_SINGLE_GET_DOUBLE_ARRAY(equation,4);
+ }
+ __GLX_SINGLE_END();
+}
+
+#define CASE_ARRAY_ENABLE(enum_name,array,dest,gl_type) \
+ case GL_ ## enum_name ## _ARRAY: \
+ *dest = (gl_type) (IS_ARRAY_ENABLED(state, array)); break
+#define CASE_ARRAY_SIZE(enum_name,array,dest,gl_type) \
+ case GL_ ## enum_name ## _ARRAY_SIZE: \
+ *dest = (gl_type) state->vertArray.arrays[array ## _ARRAY].size ; break
+#define CASE_ARRAY_TYPE(enum_name,array,dest,gl_type) \
+ case GL_ ## enum_name ## _ARRAY_TYPE: \
+ *dest = (gl_type) state->vertArray.arrays[array ## _ARRAY].type ; break
+#define CASE_ARRAY_STRIDE(enum_name,array,dest,gl_type) \
+ case GL_ ## enum_name ## _ARRAY_STRIDE: \
+ *dest = (gl_type) state->vertArray.arrays[array ## _ARRAY].stride ; break
+
+#define CASE_ARRAY_ALL(enum_name,array,dest,gl_type) \
+ CASE_ARRAY_ENABLE(enum_name,array,dest,gl_type); \
+ CASE_ARRAY_STRIDE(enum_name,array,dest,gl_type); \
+ CASE_ARRAY_TYPE(enum_name,array,dest,gl_type); \
+ CASE_ARRAY_SIZE(enum_name,array,dest,gl_type)
+
+void glGetBooleanv(GLenum val, GLboolean *b)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) {
+ val = GL_MODELVIEW_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) {
+ val = GL_PROJECTION_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) {
+ val = GL_TEXTURE_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) {
+ val = GL_COLOR_MATRIX;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ /*
+ ** For all the queries listed here, we use the locally stored
+ ** values rather than the one returned by the server. Note that
+ ** we still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+ switch (val) {
+ case GL_PACK_ROW_LENGTH:
+ *b = (GLboolean)state->storePack.rowLength;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ *b = (GLboolean)state->storePack.imageHeight;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ *b = (GLboolean)state->storePack.skipRows;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ *b = (GLboolean)state->storePack.skipPixels;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ *b = (GLboolean)state->storePack.skipImages;
+ break;
+ case GL_PACK_ALIGNMENT:
+ *b = (GLboolean)state->storePack.alignment;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ *b = (GLboolean)state->storePack.swapEndian;
+ break;
+ case GL_PACK_LSB_FIRST:
+ *b = (GLboolean)state->storePack.lsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ *b = (GLboolean)state->storeUnpack.rowLength;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ *b = (GLboolean)state->storeUnpack.imageHeight;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ *b = (GLboolean)state->storeUnpack.skipRows;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ *b = (GLboolean)state->storeUnpack.skipPixels;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ *b = (GLboolean)state->storeUnpack.skipImages;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ *b = (GLboolean)state->storeUnpack.alignment;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ *b = (GLboolean)state->storeUnpack.swapEndian;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ *b = (GLboolean)state->storeUnpack.lsbFirst;
+ break;
+
+ CASE_ARRAY_ALL(VERTEX, vertex, b, GLboolean);
+
+ CASE_ARRAY_ENABLE(NORMAL, normal, b, GLboolean);
+ CASE_ARRAY_TYPE(NORMAL, normal, b, GLboolean);
+ CASE_ARRAY_STRIDE(NORMAL, normal, b, GLboolean);
+
+ CASE_ARRAY_ALL(COLOR, color, b, GLboolean);
+
+ CASE_ARRAY_ENABLE(INDEX, index, b, GLboolean);
+ CASE_ARRAY_TYPE(INDEX, index, b, GLboolean);
+ CASE_ARRAY_STRIDE(INDEX, index, b, GLboolean);
+
+ case GL_TEXTURE_COORD_ARRAY:
+ *b = (GLboolean)IS_TEXARRAY_ENABLED(state, state->vertArray.activeTexture);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ *b = (GLboolean)state->vertArray.texCoord[state->vertArray.activeTexture].size;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ *b = (GLboolean)state->vertArray.texCoord[state->vertArray.activeTexture].type;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ *b = (GLboolean)state->vertArray.texCoord[state->vertArray.activeTexture].stride;
+ break;
+
+ CASE_ARRAY_ENABLE(EDGE_FLAG, edgeFlag, b, GLboolean);
+ CASE_ARRAY_STRIDE(EDGE_FLAG, edgeFlag, b, GLboolean);
+
+ CASE_ARRAY_ALL(SECONDARY_COLOR, secondaryColor, b, GLboolean);
+
+ CASE_ARRAY_ENABLE(FOG_COORD, fogCoord, b, GLboolean);
+ CASE_ARRAY_TYPE(FOG_COORD, fogCoord, b, GLboolean);
+ CASE_ARRAY_STRIDE(FOG_COORD, fogCoord, b, GLboolean);
+
+ case GL_MAX_ELEMENTS_VERTICES:
+ *b = (GLboolean)state->vertArray.maxElementsVertices;
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ *b = (GLboolean)state->vertArray.maxElementsIndices;
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ *b = (GLboolean)__GL_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ *b = (GLboolean)(state->vertArray.activeTexture + GL_TEXTURE0_ARB);
+ break;
+ default:
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_CHAR(b);
+ } else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(b,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixb(b);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetDoublev(GLenum val, GLdouble *d)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) {
+ val = GL_MODELVIEW_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) {
+ val = GL_PROJECTION_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) {
+ val = GL_TEXTURE_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) {
+ val = GL_COLOR_MATRIX;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ /*
+ ** For all the queries listed here, we use the locally stored
+ ** values rather than the one returned by the server. Note that
+ ** we still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+ switch (val) {
+ case GL_PACK_ROW_LENGTH:
+ *d = (GLdouble)state->storePack.rowLength;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ *d = (GLdouble)state->storePack.imageHeight;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ *d = (GLdouble)state->storePack.skipRows;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ *d = (GLdouble)state->storePack.skipPixels;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ *d = (GLdouble)state->storePack.skipImages;
+ break;
+ case GL_PACK_ALIGNMENT:
+ *d = (GLdouble)state->storePack.alignment;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ *d = (GLdouble)state->storePack.swapEndian;
+ break;
+ case GL_PACK_LSB_FIRST:
+ *d = (GLdouble)state->storePack.lsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ *d = (GLdouble)state->storeUnpack.rowLength;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ *d = (GLdouble)state->storeUnpack.imageHeight;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ *d = (GLdouble)state->storeUnpack.skipRows;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ *d = (GLdouble)state->storeUnpack.skipPixels;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ *d = (GLdouble)state->storeUnpack.skipImages;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ *d = (GLdouble)state->storeUnpack.alignment;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ *d = (GLdouble)state->storeUnpack.swapEndian;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ *d = (GLdouble)state->storeUnpack.lsbFirst;
+ break;
+
+ CASE_ARRAY_ALL(VERTEX, vertex, d, GLdouble);
+
+ CASE_ARRAY_ENABLE(NORMAL, normal, d, GLdouble);
+ CASE_ARRAY_TYPE(NORMAL, normal, d, GLdouble);
+ CASE_ARRAY_STRIDE(NORMAL, normal, d, GLdouble);
+
+ CASE_ARRAY_ALL(COLOR, color, d, GLdouble);
+
+ CASE_ARRAY_ENABLE(INDEX, index, d, GLdouble);
+ CASE_ARRAY_TYPE(INDEX, index, d, GLdouble);
+ CASE_ARRAY_STRIDE(INDEX, index, d, GLdouble);
+
+ case GL_TEXTURE_COORD_ARRAY:
+ *d = (GLdouble) IS_TEXARRAY_ENABLED(state, state->vertArray.activeTexture);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ *d = (GLdouble)state->vertArray.texCoord[state->vertArray.activeTexture].size;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ *d = (GLdouble)state->vertArray.texCoord[state->vertArray.activeTexture].type;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ *d = (GLdouble)state->vertArray.texCoord[state->vertArray.activeTexture].stride;
+ break;
+
+ CASE_ARRAY_ENABLE(EDGE_FLAG, edgeFlag, d, GLdouble);
+ CASE_ARRAY_STRIDE(EDGE_FLAG, edgeFlag, d, GLdouble);
+
+ CASE_ARRAY_ALL(SECONDARY_COLOR, secondaryColor, d, GLdouble);
+
+ CASE_ARRAY_ENABLE(FOG_COORD, fogCoord, d, GLdouble);
+ CASE_ARRAY_TYPE(FOG_COORD, fogCoord, d, GLdouble);
+ CASE_ARRAY_STRIDE(FOG_COORD, fogCoord, d, GLdouble);
+
+ case GL_MAX_ELEMENTS_VERTICES:
+ *d = (GLdouble)state->vertArray.maxElementsVertices;
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ *d = (GLdouble)state->vertArray.maxElementsIndices;
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ *d = (GLdouble)__GL_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ *d = (GLdouble)(state->vertArray.activeTexture + GL_TEXTURE0_ARB);
+ break;
+ default:
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_DOUBLE(d);
+ } else {
+ __GLX_SINGLE_GET_DOUBLE_ARRAY(d,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixd(d);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetFloatv(GLenum val, GLfloat *f)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) {
+ val = GL_MODELVIEW_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) {
+ val = GL_PROJECTION_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) {
+ val = GL_TEXTURE_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) {
+ val = GL_COLOR_MATRIX;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ /*
+ ** For all the queries listed here, we use the locally stored
+ ** values rather than the one returned by the server. Note that
+ ** we still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+ switch (val) {
+ case GL_PACK_ROW_LENGTH:
+ *f = (GLfloat)state->storePack.rowLength;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ *f = (GLfloat)state->storePack.imageHeight;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ *f = (GLfloat)state->storePack.skipRows;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ *f = (GLfloat)state->storePack.skipPixels;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ *f = (GLfloat)state->storePack.skipImages;
+ break;
+ case GL_PACK_ALIGNMENT:
+ *f = (GLfloat)state->storePack.alignment;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ *f = (GLfloat)state->storePack.swapEndian;
+ break;
+ case GL_PACK_LSB_FIRST:
+ *f = (GLfloat)state->storePack.lsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ *f = (GLfloat)state->storeUnpack.rowLength;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ *f = (GLfloat)state->storeUnpack.imageHeight;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ *f = (GLfloat)state->storeUnpack.skipRows;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ *f = (GLfloat)state->storeUnpack.skipPixels;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ *f = (GLfloat)state->storeUnpack.skipImages;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ *f = (GLfloat)state->storeUnpack.alignment;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ *f = (GLfloat)state->storeUnpack.swapEndian;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ *f = (GLfloat)state->storeUnpack.lsbFirst;
+ break;
+
+ CASE_ARRAY_ALL(VERTEX, vertex, f, GLfloat);
+
+ CASE_ARRAY_ENABLE(NORMAL, normal, f, GLfloat);
+ CASE_ARRAY_TYPE(NORMAL, normal, f, GLfloat);
+ CASE_ARRAY_STRIDE(NORMAL, normal, f, GLfloat);
+
+ CASE_ARRAY_ALL(COLOR, color, f, GLfloat);
+
+ CASE_ARRAY_ENABLE(INDEX, index, f, GLfloat);
+ CASE_ARRAY_TYPE(INDEX, index, f, GLfloat);
+ CASE_ARRAY_STRIDE(INDEX, index, f, GLfloat);
+
+ case GL_TEXTURE_COORD_ARRAY:
+ *f = (GLfloat) IS_TEXARRAY_ENABLED(state, state->vertArray.activeTexture);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ *f = (GLfloat)state->vertArray.texCoord[state->vertArray.activeTexture].size;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ *f = (GLfloat)state->vertArray.texCoord[state->vertArray.activeTexture].type;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ *f = (GLfloat)state->vertArray.texCoord[state->vertArray.activeTexture].stride;
+ break;
+
+ CASE_ARRAY_ENABLE(EDGE_FLAG, edgeFlag, f, GLfloat);
+ CASE_ARRAY_STRIDE(EDGE_FLAG, edgeFlag, f, GLfloat);
+
+ CASE_ARRAY_ALL(SECONDARY_COLOR, secondaryColor, f, GLfloat);
+
+ CASE_ARRAY_ENABLE(FOG_COORD, fogCoord, f, GLfloat);
+ CASE_ARRAY_TYPE(FOG_COORD, fogCoord, f, GLfloat);
+ CASE_ARRAY_STRIDE(FOG_COORD, fogCoord, f, GLfloat);
+
+ case GL_MAX_ELEMENTS_VERTICES:
+ *f = (GLfloat)state->vertArray.maxElementsVertices;
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ *f = (GLfloat)state->vertArray.maxElementsIndices;
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ *f = (GLfloat)__GL_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ *f = (GLfloat)(state->vertArray.activeTexture + GL_TEXTURE0_ARB);
+ break;
+ default:
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(f);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(f,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixf(f);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetIntegerv(GLenum val, GLint *i)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) {
+ val = GL_MODELVIEW_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) {
+ val = GL_PROJECTION_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) {
+ val = GL_TEXTURE_MATRIX;
+ }
+ else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) {
+ val = GL_COLOR_MATRIX;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ /*
+ ** For all the queries listed here, we use the locally stored
+ ** values rather than the one returned by the server. Note that
+ ** we still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+ switch (val) {
+ case GL_PACK_ROW_LENGTH:
+ *i = (GLint)state->storePack.rowLength;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ *i = (GLint)state->storePack.imageHeight;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ *i = (GLint)state->storePack.skipRows;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ *i = (GLint)state->storePack.skipPixels;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ *i = (GLint)state->storePack.skipImages;
+ break;
+ case GL_PACK_ALIGNMENT:
+ *i = (GLint)state->storePack.alignment;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ *i = (GLint)state->storePack.swapEndian;
+ break;
+ case GL_PACK_LSB_FIRST:
+ *i = (GLint)state->storePack.lsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ *i = (GLint)state->storeUnpack.rowLength;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ *i = (GLint)state->storeUnpack.imageHeight;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ *i = (GLint)state->storeUnpack.skipRows;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ *i = (GLint)state->storeUnpack.skipPixels;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ *i = (GLint)state->storeUnpack.skipImages;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ *i = (GLint)state->storeUnpack.alignment;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ *i = (GLint)state->storeUnpack.swapEndian;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ *i = (GLint)state->storeUnpack.lsbFirst;
+ break;
+
+ CASE_ARRAY_ALL(VERTEX, vertex, i, GLint);
+
+ CASE_ARRAY_ENABLE(NORMAL, normal, i, GLint);
+ CASE_ARRAY_TYPE(NORMAL, normal, i, GLint);
+ CASE_ARRAY_STRIDE(NORMAL, normal, i, GLint);
+
+ CASE_ARRAY_ALL(COLOR, color, i, GLint);
+
+ CASE_ARRAY_ENABLE(INDEX, index, i, GLint);
+ CASE_ARRAY_TYPE(INDEX, index, i, GLint);
+ CASE_ARRAY_STRIDE(INDEX, index, i, GLint);
+
+ case GL_TEXTURE_COORD_ARRAY:
+ *i = (GLint) IS_TEXARRAY_ENABLED(state, state->vertArray.activeTexture);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ *i = (GLint)state->vertArray.texCoord[state->vertArray.activeTexture].size;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ *i = (GLint)state->vertArray.texCoord[state->vertArray.activeTexture].type;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ *i = (GLint)state->vertArray.texCoord[state->vertArray.activeTexture].stride;
+ break;
+
+ CASE_ARRAY_ENABLE(EDGE_FLAG, edgeFlag, i, GLint);
+ CASE_ARRAY_STRIDE(EDGE_FLAG, edgeFlag, i, GLint);
+
+ CASE_ARRAY_ALL(SECONDARY_COLOR, secondaryColor, i, GLint);
+
+ CASE_ARRAY_ENABLE(FOG_COORD, fogCoord, i, GLint);
+ CASE_ARRAY_TYPE(FOG_COORD, fogCoord, i, GLint);
+ CASE_ARRAY_STRIDE(FOG_COORD, fogCoord, i, GLint);
+
+ case GL_MAX_ELEMENTS_VERTICES:
+ *i = (GLint)state->vertArray.maxElementsVertices;
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ *i = (GLint)state->vertArray.maxElementsIndices;
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ *i = (GLint)__GL_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ *i = (GLint)(state->vertArray.activeTexture + GL_TEXTURE0_ARB);
+ break;
+ default:
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(i);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(i,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixi(i);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+/*
+** Send all pending commands to server.
+*/
+void glFlush(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_Flush,0);
+ __GLX_SINGLE_END();
+
+ /* And finally flush the X protocol data */
+ XFlush(dpy);
+}
+
+void glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer,8);
+ __GLX_SINGLE_PUT_LONG(0,size);
+ __GLX_SINGLE_PUT_LONG(4,type);
+ __GLX_SINGLE_END();
+
+ gc->feedbackBuf = buffer;
+}
+
+void glSelectBuffer(GLsizei numnames, GLuint *buffer)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer,4);
+ __GLX_SINGLE_PUT_LONG(0,numnames);
+ __GLX_SINGLE_END();
+
+ gc->selectBuf = buffer;
+}
+
+GLint glRenderMode(GLenum mode)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLint retval = 0;
+ xGLXRenderModeReply reply;
+
+ if (!dpy) return -1;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_RenderMode,4);
+ __GLX_SINGLE_PUT_LONG(0,mode);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval,GLint);
+
+ if (reply.newMode != mode) {
+ /*
+ ** Switch to new mode did not take effect, therefore an error
+ ** occured. When an error happens the server won't send us any
+ ** other data.
+ */
+ } else {
+ /* Read the feedback or selection data */
+ if (gc->renderMode == GL_FEEDBACK) {
+ __GLX_SINGLE_GET_SIZE(compsize);
+ __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
+ } else
+ if (gc->renderMode == GL_SELECT) {
+ __GLX_SINGLE_GET_SIZE(compsize);
+ __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
+ }
+ gc->renderMode = mode;
+ }
+ __GLX_SINGLE_END();
+
+ return retval;
+}
+
+void glFinish(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_Finish,0);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_END();
+}
+
+
+/**
+ * Extract the major and minor version numbers from a version string.
+ */
+static void
+version_from_string( const char * ver,
+ int * major_version, int * minor_version )
+{
+ const char * end;
+ long major;
+ long minor;
+
+ major = strtol( ver, (char **) & end, 10 );
+ minor = strtol( end + 1, NULL, 10 );
+ *major_version = major;
+ *minor_version = minor;
+}
+
+
+const GLubyte *glGetString(GLenum name)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+ GLubyte *s = NULL;
+
+ if (!dpy) return 0;
+
+ /*
+ ** Return the cached copy if the string has already been fetched
+ */
+ switch(name) {
+ case GL_VENDOR:
+ if (gc->vendor) return gc->vendor;
+ break;
+ case GL_RENDERER:
+ if (gc->renderer) return gc->renderer;
+ break;
+ case GL_VERSION:
+ if (gc->version) return gc->version;
+ break;
+ case GL_EXTENSIONS:
+ if (gc->extensions) return gc->extensions;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return 0;
+ }
+
+ /*
+ ** Get requested string from server
+ */
+
+ (void) __glXFlushRenderBuffer( gc, gc->pc );
+ s = (GLubyte *) __glXGetStringFromServer( dpy, gc->majorOpcode,
+ X_GLsop_GetString, gc->currentContextTag,
+ name );
+ if (!s) {
+ /* Throw data on the floor */
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ /*
+ ** Update local cache
+ */
+ switch(name) {
+ case GL_VENDOR:
+ gc->vendor = s;
+ break;
+
+ case GL_RENDERER:
+ gc->renderer = s;
+ break;
+
+ case GL_VERSION: {
+ int client_major;
+ int client_minor;
+
+ version_from_string( (char *) s,
+ & gc->server_major, & gc->server_minor );
+ __glXGetGLVersion( & client_major, & client_minor );
+
+ if ( (gc->server_major < client_major)
+ || ((gc->server_major == client_major)
+ && (gc->server_minor <= client_minor)) ) {
+ gc->version = s;
+ }
+ else {
+ /* Allow 7 bytes for the client-side GL version. This allows
+ * for upto version 999.999. I'm not holding my breath for
+ * that one! The extra 4 is for the ' ()\0' that will be
+ * added.
+ */
+ const size_t size = 7 + strlen( (char *) s ) + 4;
+
+ gc->version = Xmalloc( size );
+ if ( gc->version == NULL ) {
+ /* If we couldn't allocate memory for the new string,
+ * make a best-effort and just copy the client-side version
+ * to the string and use that. It probably doesn't
+ * matter what is done here. If there not memory available
+ * for a short string, the system is probably going to die
+ * soon anyway.
+ */
+ snprintf( (char *) s, strlen( (char *) s ) + 1, "%u.%u",
+ client_major, client_minor );
+ gc->version = s;
+ }
+ else {
+ snprintf( (char *)gc->version, size, "%u.%u (%s)",
+ client_major, client_minor, s );
+ Xfree( s );
+ s = gc->version;
+ }
+ }
+ break;
+ }
+
+ case GL_EXTENSIONS: {
+ int major = 1;
+ int minor = 0;
+
+ /* This code is currently disabled. I was reminded that some
+ * vendors intentionally exclude some extensions from their
+ * extension string that are part of the core version they
+ * advertise. In particular, on Nvidia drivers this means that
+ * the functionality is supported by the driver, but is not
+ * hardware accelerated. For example, a TNT will show core
+ * version 1.5, but most of the post-1.2 functionality is a
+ * software fallback.
+ *
+ * I don't want to break applications that rely on this odd
+ * behavior. At the same time, the code is written and tested,
+ * so I didn't want to throw it away. Therefore, the code is here
+ * but disabled. In the future, we may wish to and an environment
+ * variable to enable it.
+ */
+
+#if 0
+ /* Call glGetString just to make sure that gc->server_major and
+ * gc->server_minor are set. This version may be higher than we
+ * can completely support, but it may imply support for some
+ * extensions that we can support.
+ *
+ * For example, at the time of this writing, the client-side
+ * library only supports upto core GL version 1.2. However, cubic
+ * textures, multitexture, multisampling, and some other 1.3
+ * features are supported. If the server reports back version
+ * 1.3, but does not report all of those extensions, we will
+ * enable them.
+ */
+ (void *) glGetString( GL_VERSION );
+ major = gc->server_major,
+ minor = gc->server_minor;
+#endif
+
+ __glXCalculateUsableGLExtensions( gc, (char *) s, major, minor );
+ XFree( s );
+ s = gc->extensions;
+ break;
+ }
+ }
+ }
+ return s;
+}
+
+GLboolean glIsEnabled(GLenum cap)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+ GLboolean retval = 0;
+
+ if (!dpy) return 0;
+
+ switch(cap) {
+ case GL_VERTEX_ARRAY:
+ return IS_ARRAY_ENABLED(state, vertex);
+ case GL_NORMAL_ARRAY:
+ return IS_ARRAY_ENABLED(state, normal);
+ case GL_COLOR_ARRAY:
+ return IS_ARRAY_ENABLED(state, color);
+ case GL_INDEX_ARRAY:
+ return IS_ARRAY_ENABLED(state, index);
+ case GL_TEXTURE_COORD_ARRAY:
+ return IS_TEXARRAY_ENABLED(state, state->vertArray.activeTexture);
+ case GL_EDGE_FLAG_ARRAY:
+ return IS_ARRAY_ENABLED(state, edgeFlag);
+ case GL_SECONDARY_COLOR_ARRAY:
+ return IS_ARRAY_ENABLED(state, secondaryColor);
+ case GL_FOG_COORD_ARRAY:
+ return IS_ARRAY_ENABLED(state, fogCoord);
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled,4);
+ __GLX_SINGLE_PUT_LONG(0,cap);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
+ __GLX_SINGLE_END();
+ return retval;
+}
+
+void glGetPointerv(GLenum pname, void **params)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ switch(pname) {
+ case GL_VERTEX_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ vertex_ARRAY ].ptr;
+ return;
+ case GL_NORMAL_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ normal_ARRAY ].ptr;
+ return;
+ case GL_COLOR_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ color_ARRAY ].ptr;
+ return;
+ case GL_INDEX_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ index_ARRAY ].ptr;
+ return;
+ case GL_TEXTURE_COORD_ARRAY_POINTER:
+ *params = (void *)state->vertArray.texCoord[state->vertArray.activeTexture].ptr;
+ return;
+ case GL_EDGE_FLAG_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ edgeFlag_ARRAY ].ptr;
+ return;
+ case GL_SECONDARY_COLOR_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ secondaryColor_ARRAY ].ptr;
+ return;
+ case GL_FOG_COORD_ARRAY_POINTER:
+ *params = (void *)state->vertArray.arrays[ fogCoord_ARRAY ].ptr;
+ return;
+ case GL_FEEDBACK_BUFFER_POINTER:
+ *params = (void *)gc->feedbackBuf;
+ return;
+ case GL_SELECTION_BUFFER_POINTER:
+ *params = (void *)gc->selectBuf;
+ return;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+}
+
diff --git a/src/glx/x11/singlepix.c b/src/glx/x11/singlepix.c
new file mode 100644
index 0000000000..8b1737e4f6
--- /dev/null
+++ b/src/glx/x11/singlepix.c
@@ -0,0 +1,415 @@
+/* $XFree86: xc/lib/GL/glx/singlepix.c,v 1.3 2001/03/21 16:04:39 dawes Exp $ */
+/*
+** 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.1 (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-2000 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 "packsingle.h"
+
+void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid *pixels)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXReadPixelsReply reply;
+ GLubyte *buf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_ReadPixels,__GLX_PAD(26));
+ __GLX_SINGLE_PUT_LONG(0,x);
+ __GLX_SINGLE_PUT_LONG(4,y);
+ __GLX_SINGLE_PUT_LONG(8,width);
+ __GLX_SINGLE_PUT_LONG(12,height);
+ __GLX_SINGLE_PUT_LONG(16,format);
+ __GLX_SINGLE_PUT_LONG(20,type);
+ __GLX_SINGLE_PUT_CHAR(24,state->storePack.swapEndian);
+ __GLX_SINGLE_PUT_CHAR(25,GL_FALSE);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ /* Allocate a holding buffer to transform the data from */
+ buf = (GLubyte*) Xmalloc(compsize);
+ if (!buf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ /*
+ ** Fetch data into holding buffer. Apply pixel store pack modes
+ ** to put data back into client memory
+ */
+ __GLX_SINGLE_GET_CHAR_ARRAY(buf,compsize);
+ __glEmptyImage(gc, 2, width, height, 1, format, type, buf, pixels);
+ Xfree((char*) buf);
+ }
+ } else {
+ /*
+ ** GL error occurred; don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
+ GLvoid *texels)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetTexImageReply reply;
+ GLubyte *buf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetTexImage,__GLX_PAD(17));
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,level);
+ __GLX_SINGLE_PUT_LONG(8,format);
+ __GLX_SINGLE_PUT_LONG(12,type);
+ __GLX_SINGLE_PUT_CHAR(16,state->storePack.swapEndian);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ /* Allocate a holding buffer to transform the data from */
+ buf = (GLubyte*) Xmalloc(compsize);
+ if (!buf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ GLint width, height, depth;
+
+ /*
+ ** Fetch data into holding buffer. Apply pixel store pack modes
+ ** to put data back into client memory
+ */
+ width = reply.width;
+ height = reply.height;
+ depth = reply.depth;
+ __GLX_SINGLE_GET_CHAR_ARRAY(buf,compsize);
+ __glEmptyImage(gc, 2, width, height, depth, format, type, buf,
+ texels);
+ Xfree((char*) buf);
+ }
+ } else {
+ /*
+ ** GL error occured, don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetPolygonStipple(GLubyte *mask)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+ GLubyte buf[128];
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetPolygonStipple,__GLX_PAD(1));
+ __GLX_SINGLE_PUT_CHAR(0,GL_FALSE);
+ __GLX_SINGLE_READ_XREPLY();
+ if (reply.length == 32) {
+ __GLX_SINGLE_GET_CHAR_ARRAY(buf,128);
+ __glEmptyImage(gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, buf, mask);
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid *table)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetColorTableReply reply;
+ GLubyte *buf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetColorTable,__GLX_PAD(13));
+ __GLX_SINGLE_PUT_LONG(0,(long)target);
+ __GLX_SINGLE_PUT_LONG(4,(long)format);
+ __GLX_SINGLE_PUT_LONG(8,(long)type);
+ __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = (long)reply.length << 2;
+
+ if (compsize != 0) {
+ /* Allocate a holding buffer to transform the data from */
+ buf = (GLubyte*)Xmalloc(compsize);
+ if (!buf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ GLint width;
+
+ /*
+ ** Fetch data into holding buffer. Apply pixel store pack modes
+ ** to put data back into client memory
+ */
+ width = (int)reply.width;
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),(long)compsize);
+ __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, table);
+ Xfree((char*) buf);
+ }
+ } else {
+ /*
+ ** GL error occured, don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetConvolutionFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *image)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetConvolutionFilterReply reply;
+ GLubyte *buf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetConvolutionFilter, __GLX_PAD(13));
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,format);
+ __GLX_SINGLE_PUT_LONG(8,type);
+ __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ /* Allocate a holding buffer to transform the data from */
+ buf = (GLubyte*) Xmalloc(compsize);
+ if (!buf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ GLint width, height;
+
+ /*
+ ** Fetch data into holding buffer. Apply pixel store pack modes
+ ** to put data back into client memory
+ */
+ width = reply.width;
+ height = reply.height;
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),compsize);
+ __glEmptyImage(gc, 2, width, height, 1, format, type, buf, image);
+ Xfree((char*) buf);
+ }
+ } else {
+ /*
+ ** GL error occured, don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *row, GLvoid *column, GLvoid *span)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetSeparableFilterReply reply;
+ GLubyte *rowBuf, *colBuf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,format);
+ __GLX_SINGLE_PUT_LONG(8,type);
+ __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ GLint width, height;
+ GLint widthsize, heightsize;
+
+ width = reply.width;
+ height = reply.height;
+
+ widthsize = __glImageSize(width,1,1,format, type);
+ heightsize = __glImageSize(height,1,1,format, type);
+
+ /* Allocate a holding buffer to transform the data from */
+ rowBuf = (GLubyte*) Xmalloc(widthsize);
+ if (!rowBuf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ } else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf),widthsize);
+ __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
+ Xfree((char*) rowBuf);
+ }
+ colBuf = (GLubyte*) Xmalloc(heightsize);
+ if (!colBuf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize - __GLX_PAD(widthsize));
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ } else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf),heightsize);
+ __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
+ Xfree((char*) colBuf);
+ }
+ } else {
+ /*
+ ** don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+
+}
+
+void glGetHistogram(GLenum target, GLboolean reset, GLenum format,
+ GLenum type, GLvoid *values)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetHistogramReply reply;
+ GLubyte *buf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetHistogram,__GLX_PAD(14));
+ __GLX_SINGLE_PUT_LONG(0,(long)target);
+ __GLX_SINGLE_PUT_LONG(4,(long)format);
+ __GLX_SINGLE_PUT_LONG(8,(long)type);
+ __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
+ __GLX_SINGLE_PUT_CHAR(13,reset);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = (long)reply.length << 2;
+
+ if (compsize != 0) {
+ /* Allocate a holding buffer to transform the data from */
+ buf = (GLubyte*)Xmalloc(compsize);
+ if (!buf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ GLint width;
+
+ /*
+ ** Fetch data into holding buffer. Apply pixel store pack modes
+ ** to put data back into client memory
+ */
+ width = (int)reply.width;
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),(long)compsize);
+ __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, values);
+ Xfree((char*) buf);
+ }
+ } else {
+ /*
+ ** GL error occured, don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+}
+
+void glGetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type,
+ GLvoid *values)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetMinmaxReply reply;
+ GLubyte *buf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetMinmax,__GLX_PAD(14));
+ __GLX_SINGLE_PUT_LONG(0,(long)target);
+ __GLX_SINGLE_PUT_LONG(4,(long)format);
+ __GLX_SINGLE_PUT_LONG(8,(long)type);
+ __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
+ __GLX_SINGLE_PUT_CHAR(13,reset);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = (long)reply.length << 2;
+
+ if (compsize != 0) {
+ /* Allocate a holding buffer to transform the data from */
+ buf = (GLubyte*)Xmalloc(compsize);
+ if (!buf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ /*
+ ** Fetch data into holding buffer. Apply pixel store pack modes
+ ** to put data back into client memory
+ */
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),(long)compsize);
+ __glEmptyImage(gc, 1, 2, 1, 1, format, type, buf, values);
+ Xfree((char*) buf);
+ }
+ } else {
+ /*
+ ** GL error occured, don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+}
diff --git a/src/glx/x11/size.h b/src/glx/x11/size.h
new file mode 100644
index 0000000000..e04696af19
--- /dev/null
+++ b/src/glx/x11/size.h
@@ -0,0 +1,72 @@
+/* $XFree86: xc/lib/GL/glx/size.h,v 1.4 2003/09/28 20:15:04 alanh Exp $ */
+#ifndef _size_h_
+#define _size_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.1 (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-2000 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.
+**
+*/
+
+/*
+** These are _size functions that are needed to pack the arguments
+** into the protocol
+*/
+extern GLint __glBitmap_size(GLsizei w, GLsizei h);
+extern GLint __glCallLists_size(GLsizei n, GLenum type);
+extern GLint __glColorTableParameterfv_size(GLenum pname);
+extern GLint __glColorTableParameteriv_size(GLenum pname);
+extern GLint __glConvolutionParameterfv_size(GLenum pname);
+extern GLint __glConvolutionParameteriv_size(GLenum pname);
+extern GLint __glDrawPixels_size(GLenum format, GLenum type, GLsizei w,GLsizei h);
+extern GLint __glFogfv_size(GLenum pname);
+extern GLint __glFogiv_size(GLenum pname);
+extern GLint __glLightModelfv_size(GLenum pname);
+extern GLint __glLightModeliv_size(GLenum pname);
+extern GLint __glLightfv_size(GLenum pname);
+extern GLint __glLightiv_size(GLenum pname);
+extern GLint __glMaterialfv_size(GLenum pname);
+extern GLint __glMaterialiv_size(GLenum pname);
+extern GLint __glTexEnvfv_size(GLenum e);
+extern GLint __glTexEnviv_size(GLenum e);
+extern GLint __glTexGendv_size(GLenum e);
+extern GLint __glTexGenfv_size(GLenum e);
+extern GLint __glTexGeniv_size(GLenum pname);
+extern GLint __glTexImage1D_size(GLenum format, GLenum type, GLsizei w);
+extern GLint __glTexImage2D_size(GLenum format, GLenum type, GLsizei w, GLsizei h);
+extern GLint __glTexImage3D_size(GLenum format, GLenum type, GLsizei w, GLsizei h, GLsizei d);
+extern GLint __glTexParameterfv_size(GLenum e);
+extern GLint __glTexParameteriv_size(GLenum e);
+extern GLint __glPointParameterfvARB_size(GLenum e);
+extern GLint __glPointParameteriv_size(GLenum e);
+
+#endif /* _size_h_ */
diff --git a/src/glx/x11/vertarr.c b/src/glx/x11/vertarr.c
new file mode 100644
index 0000000000..3f8cfcfde3
--- /dev/null
+++ b/src/glx/x11/vertarr.c
@@ -0,0 +1,1152 @@
+/* $XFree86: xc/lib/GL/glx/vertarr.c,v 1.4 2001/03/25 05:32:00 tsi Exp $ */
+/*
+** 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.1 (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-2000 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.
+**
+*/
+
+#define NEED_GL_FUNCS_WRAPPED
+#include <assert.h>
+#include "glxclient.h"
+#include "packrender.h"
+#include <string.h>
+#include <limits.h> /* INT_MAX */
+
+/* macros for setting function pointers */
+#define __GL_VERTEX_FUNC(NAME, let) \
+ case GL_##NAME: \
+ if (size == 2) \
+ vertexPointer->proc = (void (*)(const void *))glVertex2##let##v; \
+ else if (size == 3) \
+ vertexPointer->proc = (void (*)(const void *))glVertex3##let##v; \
+ else if (size == 4) \
+ vertexPointer->proc = (void (*)(const void *))glVertex4##let##v; \
+ break
+
+#define __GL_NORMAL_FUNC(NAME, let) \
+ case GL_##NAME: \
+ normalPointer->proc = (void (*)(const void *))glNormal3##let##v; \
+ break
+
+#define __GL_COLOR_FUNC(NAME, let) \
+ case GL_##NAME: \
+ if (size == 3) \
+ colorPointer->proc = (void (*)(const void *))glColor3##let##v; \
+ else if (size == 4)\
+ colorPointer->proc = (void (*)(const void *))glColor4##let##v; \
+ break
+
+#define __GL_SEC_COLOR_FUNC(NAME, let) \
+ case GL_##NAME: \
+ seccolorPointer->proc = (void (*)(const void *))glSecondaryColor3##let##v; \
+
+#define __GL_FOG_FUNC(NAME, let) \
+ case GL_##NAME: \
+ fogPointer->proc = (void (*)(const void *))glFogCoord##let##v; \
+
+#define __GL_INDEX_FUNC(NAME, let) \
+ case GL_##NAME: \
+ indexPointer->proc = (void (*)(const void *))glIndex##let##v; \
+ break
+
+#define __GL_TEXTURE_FUNC(NAME, let) \
+ case GL_##NAME: \
+ if (size == 1) { \
+ texCoordPointer->proc = (void (*)(const void *))glTexCoord1##let##v; \
+ texCoordPointer->mtex_proc = (void (*)(GLenum, const void *))glMultiTexCoord1##let##vARB; \
+ } else if (size == 2) { \
+ texCoordPointer->proc = (void (*)(const void *))glTexCoord2##let##v; \
+ texCoordPointer->mtex_proc = (void (*)(GLenum, const void *))glMultiTexCoord2##let##vARB; \
+ } else if (size == 3) { \
+ texCoordPointer->proc = (void (*)(const void *))glTexCoord3##let##v; \
+ texCoordPointer->mtex_proc = (void (*)(GLenum, const void *))glMultiTexCoord2##let##vARB; \
+ } else if (size == 4) { \
+ texCoordPointer->proc = (void (*)(const void *))glTexCoord4##let##v; \
+ texCoordPointer->mtex_proc = (void (*)(GLenum, const void *))glMultiTexCoord4##let##vARB; \
+ } break
+
+/**
+ * Table of sizes, in bytes, of a GL types. All of the type enums are be in
+ * the range 0x1400 - 0x140F. That includes types added by extensions (i.e.,
+ * \c GL_HALF_FLOAT_NV). This elements of this table correspond to the
+ * type enums masked with 0x0f.
+ *
+ * \notes
+ * \c GL_HAVE_FLOAT_NV is not included. Neither are \c GL_2_BYTES,
+ * \c GL_3_BYTES, or \c GL_4_BYTES.
+ */
+static const GLuint __glXTypeSize_table[16] = {
+ 1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0
+};
+
+#define __glXTypeSize(e) ((((e) & ~0x0f) != 0x1400) \
+ ? 0 : __glXTypeSize_table[ (e) & 0x0f ])
+
+
+/**
+ * Initialize vertex array state for a GLX context.
+ *
+ * \param gc GLX context whose vertex array state is to be initialized.
+ *
+ * \todo
+ * Someone is going to have to check the spec. This function takes greate
+ * care to initialize the \c size and \c type fields to "correct" values
+ * for each array. I'm not sure this is necessary. I think it should be
+ * acceptable to just \c memset the whole \c arrays and \c texCoord arrays
+ * to zero and be done with it. The spec may say something to the contrary,
+ * however.
+ */
+void __glXInitVertexArrayState(__GLXcontext *gc)
+{
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertArrayState *va = &state->vertArray;
+ GLint i;
+
+ va->enables = 0;
+ va->texture_enables = 0;
+
+ for ( i = 0 ; i < __GLX_MAX_ARRAYS ; i++ ) {
+ va->arrays[ i ].proc = NULL;
+ va->arrays[ i ].skip = 0;
+ va->arrays[ i ].ptr = 0;
+ va->arrays[ i ].size = 1;
+ va->arrays[ i ].type = GL_FLOAT;
+ va->arrays[ i ].stride = 0;
+ }
+
+ va->arrays[ edgeFlag_ARRAY ].type = GL_UNSIGNED_BYTE;;
+
+ va->arrays[ secondaryColor_ARRAY ].size = 3;
+ va->arrays[ color_ARRAY ].size = 4;
+ va->arrays[ normal_ARRAY ].size = 3;
+ va->arrays[ vertex_ARRAY ].size = 4;
+
+ for ( i = 0 ; i < __GLX_MAX_TEXTURE_UNITS ; i++ ) {
+ va->texCoord[ i ].proc = NULL;
+ va->texCoord[ i ].skip = 0;
+ va->texCoord[ i ].ptr = 0;
+ va->texCoord[ i ].size = 4;
+ va->texCoord[ i ].type = GL_FLOAT;
+ va->texCoord[ i ].stride = 0;
+ }
+
+ va->maxElementsVertices = INT_MAX;
+ va->maxElementsIndices = INT_MAX;
+}
+
+/*****************************************************************************/
+
+void glVertexPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *vertexPointer = &state->vertArray.arrays[ vertex_ARRAY ];
+
+ /* Check arguments */
+ if (size < 2 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_VERTEX_FUNC(SHORT, s);
+ __GL_VERTEX_FUNC(INT, i);
+ __GL_VERTEX_FUNC(FLOAT, f);
+ __GL_VERTEX_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ vertexPointer->size = size;
+ vertexPointer->type = type;
+ vertexPointer->stride = stride;
+ vertexPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ vertexPointer->skip = __glXTypeSize(type) * size;
+ } else {
+ vertexPointer->skip = stride;
+ }
+}
+
+void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *normalPointer = &state->vertArray.arrays[ normal_ARRAY ];
+
+ /* Check arguments */
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_NORMAL_FUNC(BYTE, b);
+ __GL_NORMAL_FUNC(SHORT, s);
+ __GL_NORMAL_FUNC(INT, i);
+ __GL_NORMAL_FUNC(FLOAT, f);
+ __GL_NORMAL_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ normalPointer->type = type;
+ normalPointer->stride = stride;
+ normalPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ normalPointer->skip = 3 * __glXTypeSize(type);
+ } else {
+ normalPointer->skip = stride;
+ }
+}
+
+void glColorPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *colorPointer = &state->vertArray.arrays[ color_ARRAY ];
+
+ /* Check arguments */
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_COLOR_FUNC(BYTE, b);
+ __GL_COLOR_FUNC(UNSIGNED_BYTE, ub);
+ __GL_COLOR_FUNC(SHORT, s);
+ __GL_COLOR_FUNC(UNSIGNED_SHORT, us);
+ __GL_COLOR_FUNC(INT, i);
+ __GL_COLOR_FUNC(UNSIGNED_INT, ui);
+ __GL_COLOR_FUNC(FLOAT, f);
+ __GL_COLOR_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ colorPointer->size = size;
+ colorPointer->type = type;
+ colorPointer->stride = stride;
+ colorPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ colorPointer->skip = size * __glXTypeSize(type);
+ } else {
+ colorPointer->skip = stride;
+ }
+}
+
+void glIndexPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *indexPointer = &state->vertArray.arrays[ index_ARRAY ];
+
+ /* Check arguments */
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_INDEX_FUNC(UNSIGNED_BYTE, ub);
+ __GL_INDEX_FUNC(SHORT, s);
+ __GL_INDEX_FUNC(INT, i);
+ __GL_INDEX_FUNC(FLOAT, f);
+ __GL_INDEX_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ indexPointer->type = type;
+ indexPointer->stride = stride;
+ indexPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ indexPointer->skip = __glXTypeSize(type);
+ } else {
+ indexPointer->skip = stride;
+ }
+}
+
+void glTexCoordPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *texCoordPointer =
+ &state->vertArray.texCoord[state->vertArray.activeTexture];
+
+ /* Check arguments */
+ if (size < 1 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_TEXTURE_FUNC(SHORT, s);
+ __GL_TEXTURE_FUNC(INT, i);
+ __GL_TEXTURE_FUNC(FLOAT, f);
+ __GL_TEXTURE_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ texCoordPointer->size = size;
+ texCoordPointer->type = type;
+ texCoordPointer->stride = stride;
+ texCoordPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ texCoordPointer->skip = __glXTypeSize(type) * size;
+ } else {
+ texCoordPointer->skip = stride;
+ }
+}
+
+void glEdgeFlagPointer(GLsizei stride, const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *edgeFlagPointer = &state->vertArray.arrays[ edgeFlag_ARRAY ];
+
+ /* Check arguments */
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ edgeFlagPointer->proc = (void (*)(const void *))glEdgeFlagv;
+
+ edgeFlagPointer->stride = stride;
+ edgeFlagPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ edgeFlagPointer->skip = sizeof(GLboolean);
+ } else {
+ edgeFlagPointer->skip = stride;
+ }
+
+}
+
+void glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *seccolorPointer = &state->vertArray.arrays[ secondaryColor_ARRAY ];
+
+ /* Check arguments */
+ if ( (stride < 0) || (size != 3) ) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_SEC_COLOR_FUNC(BYTE, b);
+ __GL_SEC_COLOR_FUNC(UNSIGNED_BYTE, ub);
+ __GL_SEC_COLOR_FUNC(SHORT, s);
+ __GL_SEC_COLOR_FUNC(UNSIGNED_SHORT, us);
+ __GL_SEC_COLOR_FUNC(INT, i);
+ __GL_SEC_COLOR_FUNC(UNSIGNED_INT, ui);
+ __GL_SEC_COLOR_FUNC(FLOAT, f);
+ __GL_SEC_COLOR_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ seccolorPointer->size = size;
+ seccolorPointer->type = type;
+ seccolorPointer->stride = stride;
+ seccolorPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ seccolorPointer->skip = size * __glXTypeSize(type);
+ } else {
+ seccolorPointer->skip = stride;
+ }
+}
+
+void glFogCoordPointer(GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertexArrayPointerState *fogPointer = &state->vertArray.arrays[ fogCoord_ARRAY ];
+
+ /* Check arguments */
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Choose appropriate api proc */
+ switch(type) {
+ __GL_FOG_FUNC(FLOAT, f);
+ __GL_FOG_FUNC(DOUBLE, d);
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ fogPointer->size = 1;
+ fogPointer->type = type;
+ fogPointer->stride = stride;
+ fogPointer->ptr = pointer;
+
+ /* Set internal state */
+ if (stride == 0) {
+ fogPointer->skip = __glXTypeSize(type);
+ } else {
+ fogPointer->skip = stride;
+ }
+}
+
+void glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ GLboolean tEnable = GL_FALSE, cEnable = GL_FALSE, nEnable = GL_FALSE;
+ GLenum tType = GL_FLOAT, nType = GL_FLOAT, vType = GL_FLOAT;
+ GLenum cType = GL_FALSE;
+ GLint tSize = 0, cSize = 0, nSize = 3, vSize;
+ int cOffset = 0, nOffset = 0, vOffset = 0;
+ GLint trueStride, size;
+
+ switch (format) {
+ case GL_V2F:
+ vSize = 2;
+ size = __glXTypeSize(vType) * vSize;
+ break;
+ case GL_V3F:
+ vSize = 3;
+ size = __glXTypeSize(vType) * vSize;
+ break;
+ case GL_C4UB_V2F:
+ cEnable = GL_TRUE;
+ cSize = 4;
+ cType = GL_UNSIGNED_BYTE;
+ vSize = 2;
+ vOffset = __glXTypeSize(cType) * cSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_C4UB_V3F:
+ cEnable = GL_TRUE;
+ cSize = 4;
+ cType = GL_UNSIGNED_BYTE;
+ vSize = 3;
+ vOffset = __glXTypeSize(vType) * cSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_C3F_V3F:
+ cEnable = GL_TRUE;
+ cSize = 3;
+ cType = GL_FLOAT;
+ vSize = 3;
+ vOffset = __glXTypeSize(cType) * cSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_N3F_V3F:
+ nEnable = GL_TRUE;
+ vSize = 3;
+ vOffset = __glXTypeSize(nType) * nSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_C4F_N3F_V3F:
+ cEnable = GL_TRUE;
+ cSize = 4;
+ cType = GL_FLOAT;
+ nEnable = GL_TRUE;
+ nOffset = __glXTypeSize(cType) * cSize;
+ vSize = 3;
+ vOffset = nOffset + __glXTypeSize(nType) * nSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T2F_V3F:
+ tEnable = GL_TRUE;
+ tSize = 2;
+ vSize = 3;
+ vOffset = __glXTypeSize(tType) * tSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T4F_V4F:
+ tEnable = GL_TRUE;
+ tSize = 4;
+ vSize = 4;
+ vOffset = __glXTypeSize(tType) * tSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T2F_C4UB_V3F:
+ tEnable = GL_TRUE;
+ tSize = 2;
+ cEnable = GL_TRUE;
+ cSize = 4;
+ cType = GL_UNSIGNED_BYTE;
+ cOffset = __glXTypeSize(tType) * tSize;
+ vSize = 3;
+ vOffset = cOffset + __glXTypeSize(cType) * cSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T2F_C3F_V3F:
+ tEnable = GL_TRUE;
+ tSize = 2;
+ cEnable = GL_TRUE;
+ cSize = 3;
+ cType = GL_FLOAT;
+ cOffset = __glXTypeSize(tType) * tSize;
+ vSize = 3;
+ vOffset = cOffset + __glXTypeSize(cType) * cSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T2F_N3F_V3F:
+ tEnable = GL_TRUE;
+ tSize = 2;
+ nEnable = GL_TRUE;
+ nOffset = __glXTypeSize(tType) * tSize;
+ vSize = 3;
+ vOffset = nOffset + __glXTypeSize(nType) * nSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T2F_C4F_N3F_V3F:
+ tEnable = GL_TRUE;
+ tSize = 2;
+ cEnable = GL_TRUE;
+ cSize = 4;
+ cType = GL_FLOAT;
+ cOffset = __glXTypeSize(tType) * tSize;
+ nEnable = GL_TRUE;
+ nOffset = cOffset + __glXTypeSize(cType) * cSize;
+ vSize = 3;
+ vOffset = nOffset + __glXTypeSize(nType) * nSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ case GL_T4F_C4F_N3F_V4F:
+ tEnable = GL_TRUE;
+ tSize = 4;
+ cEnable = GL_TRUE;
+ cSize = 4;
+ cType = GL_FLOAT;
+ cOffset = __glXTypeSize(tType) * tSize;
+ nEnable = GL_TRUE;
+ nOffset = cOffset + __glXTypeSize(cType) * cSize;
+ vSize = 4;
+ vOffset = nOffset + __glXTypeSize(nType) * nSize;
+ size = vOffset + __glXTypeSize(vType) * vSize;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ trueStride = (stride == 0) ? size : stride;
+
+ state->vertArray.enables = 0;
+ state->vertArray.texture_enables = 0;
+ if (tEnable) {
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(tSize, tType, trueStride, (const char *)pointer);
+ }
+ if (cEnable) {
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorPointer(cSize, cType, trueStride, (const char *)pointer+cOffset);
+ }
+ if (nEnable) {
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(nType, trueStride, (const char *)pointer+nOffset);
+ }
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(vSize, vType, trueStride, (const char *)pointer+vOffset);
+}
+
+/*****************************************************************************/
+
+void glArrayElement(GLint i)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertArrayState *va = &state->vertArray;
+ GLint j;
+
+
+ if (IS_TEXARRAY_ENABLED(state, 0)) {
+ (*va->texCoord[0].proc)(va->texCoord[0].ptr+i*va->texCoord[0].skip);
+ }
+
+ /* Multitexturing is handled specially because the protocol
+ * requires an extra parameter.
+ */
+ for (j=1; j<__GLX_MAX_TEXTURE_UNITS; ++j) {
+ if (IS_TEXARRAY_ENABLED(state, j)) {
+ (*va->texCoord[j].mtex_proc)(GL_TEXTURE0 + j, va->texCoord[j].ptr+i*va->texCoord[j].skip);
+ }
+ }
+
+ for ( j = 0 ; j < __GLX_MAX_ARRAYS ; j++ ) {
+ if (IS_ARRAY_ENABLED_BY_INDEX(state, j)) {
+ (*va->arrays[ j ].proc)(va->arrays[ j ].ptr+i*va->arrays[ j ].skip);
+ }
+ }
+}
+
+
+struct array_info {
+ __GLXdispatchDrawArraysComponentHeader ai;
+ GLsizei bytes;
+ const GLubyte *ptr;
+ GLsizei skip;
+};
+
+
+/**
+ * Initialize a \c array_info structure for each array that is enabled in
+ * \c state. Determine how many arrays are enabled, and store the result
+ * in \c num_arrays. Determine how big each vertex is, and store the result
+ * in \c total_vertex_size.
+ *
+ * \returns The size of the final request. This is the size, in bytes, of
+ * the DrawArrays header, the ARRAY_INFO structures, and all the vertex data.
+ * This value \b assumes a \c X_GLXRender command is used. The true size
+ * will be 4 bytes larger if a \c X_GLXRenderLarge command is used.
+ */
+static GLuint
+prep_arrays(const __GLXattribute * const state, struct array_info * arrays,
+ GLint count,
+ GLsizei *num_arrays, GLsizei *total_vertex_size)
+{
+ GLsizei na = 0;
+ GLsizei vs = 0;
+
+#define ASSIGN_ARRAY_INFO(state, enum_name, arr) \
+ do { \
+ arrays[ na ].ai.datatype = state->vertArray. arr .type ; \
+ arrays[ na ].ai.numVals = state->vertArray. arr .size ; \
+ arrays[ na ].ai.component = GL_ ## enum_name ## _ARRAY; \
+\
+ arrays[ na ].bytes = state->vertArray. arr .size \
+ * __glXTypeSize( state->vertArray. arr .type ); \
+ arrays[ na ].ptr = state->vertArray. arr .ptr; \
+ arrays[ na ].skip = state->vertArray. arr .skip; \
+\
+ vs += __GLX_PAD(arrays[ na ].bytes); \
+ na++; \
+ } while( 0 )
+
+#define ADD_ARRAY_IF_ENABLED(state, enum_name, arr) \
+ do { if ( IS_ARRAY_ENABLED(state, arr) ) { \
+ ASSIGN_ARRAY_INFO(state, enum_name, arrays[ arr ## _ARRAY ] ); \
+ } } while( 0 )
+
+ ADD_ARRAY_IF_ENABLED(state, VERTEX, vertex);
+ ADD_ARRAY_IF_ENABLED(state, NORMAL, normal);
+ ADD_ARRAY_IF_ENABLED(state, COLOR, color);
+ ADD_ARRAY_IF_ENABLED(state, SECONDARY_COLOR, secondaryColor);
+ ADD_ARRAY_IF_ENABLED(state, FOG_COORD, fogCoord);
+ ADD_ARRAY_IF_ENABLED(state, EDGE_FLAG, edgeFlag);
+ ADD_ARRAY_IF_ENABLED(state, INDEX, index);
+
+ /* The standard DrawArrays protocol *only* supports a single array of
+ * texture coordinates.
+ */
+ if ( IS_TEXARRAY_ENABLED(state, 0) ) {
+ ASSIGN_ARRAY_INFO(state, TEXTURE_COORD, texCoord[0]);
+ }
+
+ *num_arrays = na;
+ *total_vertex_size = vs;
+
+ return __GLX_PAD((__GLX_COMPONENT_HDR_SIZE * na)
+ + (vs * count)
+ + __GLX_DRAWARRAYS_CMD_HDR_SIZE);
+}
+
+
+/**
+ * Emits the vertex data for the DrawArrays GLX protocol.
+ */
+static GLsizei
+emit_vertex(GLubyte * data, const struct array_info * arrays,
+ GLsizei num_arrays, GLint element, GLsizei offset)
+{
+ GLint i;
+
+ for ( i = 0 ; i < num_arrays ; i++ ) {
+ (void) memcpy( data + offset,
+ arrays[i].ptr + (arrays[i].skip * element),
+ arrays[i].bytes );
+ offset += __GLX_PAD(arrays[i].bytes);
+ }
+
+ return offset;
+}
+
+
+static void
+emit_header(GLubyte * pc, const struct array_info * arrays,
+ GLsizei num_arrays, GLsizei count, GLenum mode)
+{
+ __GLXdispatchDrawArraysComponentHeader *arrayInfo;
+ GLsizei i;
+
+ __GLX_PUT_LONG(0, count);
+ __GLX_PUT_LONG(4, num_arrays);
+ __GLX_PUT_LONG(8, mode);
+
+ arrayInfo = (__GLXdispatchDrawArraysComponentHeader *)
+ (pc + __GLX_DRAWARRAYS_HDR_SIZE);
+
+
+ /* Write the ARRAY_INFO data.
+ */
+
+ for ( i = 0 ; i < num_arrays ; i++ ) {
+ arrayInfo[i] = arrays[i].ai;
+ }
+}
+
+
+/**
+ * Emit GLX DrawArrays protocol using a GLXRender packet.
+ */
+static void
+emit_Render_DrawArrays(__GLXcontext * gc, const struct array_info * arrays,
+ GLsizei first, GLsizei count, GLsizei num_arrays, GLenum mode,
+ GLsizei cmdlen, GLsizei total_vertex_size)
+{
+ GLubyte * pc = gc->pc;
+ GLsizei offset;
+ GLsizei i;
+
+ __GLX_BEGIN_VARIABLE(X_GLrop_DrawArrays, cmdlen);
+ emit_header(pc + 4, arrays, num_arrays, count, mode);
+
+
+ /* Write the actual array data.
+ */
+
+ offset = __GLX_DRAWARRAYS_CMD_HDR_SIZE
+ + (num_arrays * __GLX_COMPONENT_HDR_SIZE);
+ for ( i = 0 ; i < count ; i++ ) {
+ offset = emit_vertex(pc, arrays, num_arrays, i + first, offset);
+ }
+
+ __GLX_END(cmdlen);
+}
+
+
+/**
+ * Emit GLX DrawArrays protocol using a GLXRenderLarge packet.
+ */
+static void
+emit_RenderLarge_DrawArrays(__GLXcontext * gc, const struct array_info * arrays,
+ GLsizei first, GLsizei count, GLsizei num_arrays, GLenum mode,
+ GLsizei cmdlen, GLsizei total_vertex_size)
+{
+ GLubyte * pc = gc->pc;
+ GLsizei offset;
+ GLsizei i;
+ GLint maxSize;
+ GLint totalRequests;
+ GLint requestNumber;
+ GLsizei elements_per_request;
+
+
+ /* Calculate the maximum amount of data can be stuffed into a single
+ * packet. sz_xGLXRenderReq is added because bufSize is the maximum
+ * packet size minus sz_xGLXRenderReq.
+ *
+ * The important value here is elements_per_request. This is the number
+ * of complete array elements that will fit in a single buffer. There
+ * may be some wasted space at the end of the buffer, but splitting
+ * elements across buffer boundries would be painful.
+ */
+
+ maxSize = (gc->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
+
+ elements_per_request = maxSize / total_vertex_size;
+
+ totalRequests = ((count + (elements_per_request - 1))
+ / elements_per_request) + 1;
+
+
+ /* Fill in the header data and send it away.
+ */
+
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_DrawArrays, cmdlen+4);
+ emit_header(pc + 8, arrays, num_arrays, count, mode);
+
+ gc->pc = pc + (__GLX_DRAWARRAYS_CMD_HDR_SIZE + 4)
+ + (__GLX_COMPONENT_HDR_SIZE * num_arrays);
+ __glXSendLargeChunk(gc, 1, totalRequests, gc->buf, gc->pc - gc->buf);
+
+
+ /* Write the actual array data.
+ */
+ offset = 0;
+ requestNumber = 2;
+ for ( i = 0 ; i < count ; i++ ) {
+ if ( i == elements_per_request ) {
+ __glXSendLargeChunk(gc, requestNumber, totalRequests,
+ gc->buf, offset);
+ requestNumber++;
+ offset = 0;
+
+ count -= i;
+ first += i;
+ i = 0;
+ }
+
+ offset = emit_vertex(gc->buf, arrays, num_arrays, i + first, offset);
+ }
+
+ /* If the buffer isn't empty, emit the last, partial request.
+ */
+ if ( offset != 0 ) {
+ assert(requestNumber == totalRequests);
+ __glXSendLargeChunk(gc, requestNumber, totalRequests, gc->buf, offset);
+ }
+
+ gc->pc = gc->buf;
+}
+
+
+/**
+ * Emit DrawArrays protocol. This function acts as a switch betteen
+ * \c emit_Render_DrawArrays and \c emit_RenderLarge_DrawArrays depending
+ * on how much array data is to be sent.
+ */
+static void
+emit_DrawArraysEXT(const __GLXattribute * const state,
+ GLint first, GLsizei count, GLenum mode)
+{
+ struct array_info arrays[32];
+ GLsizei num_arrays;
+ GLsizei total_vertex_size;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ GLuint cmdlen;
+
+
+ /* Determine how big the final request will be. This depends on a number
+ * of factors. It depends on how many array elemets there are (which is
+ * the passed-in 'count'), how many arrays are enabled, how many elements
+ * are in each array entry, and what the types are for each array.
+ */
+
+ cmdlen = prep_arrays(state, arrays, count, & num_arrays,
+ & total_vertex_size);
+
+
+ /* If the data payload and the protocol header is too large for a Render
+ * command, use a RenderLarge command.
+ */
+ if (cmdlen > gc->maxSmallRenderCommandSize) {
+ emit_RenderLarge_DrawArrays(gc, arrays, first, count, num_arrays,
+ mode, cmdlen, total_vertex_size);
+ }
+ else {
+ emit_Render_DrawArrays(gc, arrays, first, count, num_arrays,
+ mode, cmdlen, total_vertex_size);
+ }
+}
+
+
+/**
+ * Emit a DrawArrays call using the old "protocol." This isn't really
+ * DrawArrays protocol at all. It just simulates DrawArrays by using
+ * immediate-mode vertex calls. Very, very slow for large arrays, but works
+ * with every GLX server.
+ */
+static void
+emit_DrawArrays_old(const __GLXattribute * const state,
+ GLint first, GLsizei count, GLenum mode)
+{
+ const __GLXvertArrayState *va = &state->vertArray;
+ const GLubyte *vaPtr[__GLX_MAX_ARRAYS];
+ const GLubyte *tcaPtr[__GLX_MAX_TEXTURE_UNITS];
+ GLint i, j;
+
+ /*
+ ** Set up pointers for quick array traversal.
+ */
+
+ (void) memset( vaPtr, 0, sizeof(vaPtr) );
+ (void) memset( tcaPtr, 0, sizeof(tcaPtr) );
+
+ for ( j = 0 ; j < __GLX_MAX_ARRAYS ; j++ ) {
+ if (IS_ARRAY_ENABLED_BY_INDEX(state, j)) {
+ vaPtr[ j ] = va->arrays[ j ].ptr + first * va->arrays[ j ].skip;
+ }
+ }
+
+ for ( j = 0 ; j < __GLX_MAX_TEXTURE_UNITS ; j++ ) {
+ if (IS_TEXARRAY_ENABLED(state, j))
+ tcaPtr[ j ] = va->texCoord[ j ].ptr + first * va->texCoord[ j ].skip;
+ }
+
+ glBegin(mode);
+ for (i = 0; i < count; i++) {
+ if (IS_TEXARRAY_ENABLED(state, 0)) {
+ (*va->texCoord[0].proc)(tcaPtr[0]);
+ tcaPtr[0] += va->texCoord[0].skip;
+ }
+
+ /* Multitexturing is handled specially because the protocol
+ * requires an extra parameter.
+ */
+ for (j=1; j<__GLX_MAX_TEXTURE_UNITS; ++j) {
+ if (IS_TEXARRAY_ENABLED(state, j)) {
+ (*va->texCoord[j].mtex_proc)(GL_TEXTURE0 + j, tcaPtr[j]);
+ tcaPtr[j] += va->texCoord[j].skip;
+ }
+ }
+
+ for ( j = 0 ; j < __GLX_MAX_ARRAYS ; j++ ) {
+ if (IS_ARRAY_ENABLED_BY_INDEX(state, j)) {
+ (*va->arrays[ j ].proc)(vaPtr[ j ]);
+ vaPtr[ j ] += va->arrays[ j ].skip;
+ }
+ }
+ }
+ glEnd();
+}
+
+
+/**
+ * Validate that the \c mode and \c count parameters to \c glDrawArrays or
+ * \c glDrawElements are valid. If the arguments are not valid, then an
+ * error code is set in the GLX context.
+ *
+ * \returns \c GL_TRUE if the arguments are valide, \c GL_FALSE if they are
+ * not.
+ */
+static GLboolean
+glx_validate_array_args(__GLXcontext *gc, GLenum mode, GLsizei count)
+{
+ switch(mode) {
+ case GL_POINTS:
+ case GL_LINE_STRIP:
+ case GL_LINE_LOOP:
+ case GL_LINES:
+ case GL_TRIANGLE_STRIP:
+ case GL_TRIANGLE_FAN:
+ case GL_TRIANGLES:
+ case GL_QUAD_STRIP:
+ case GL_QUADS:
+ case GL_POLYGON:
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return GL_FALSE;
+ }
+
+ if (count < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+void glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+
+
+ if ( ! glx_validate_array_args(gc, mode, count) ) {
+ return;
+ }
+
+ /* The "true" DrawArrays protocol does not support generic attributes,
+ * multiple vertex arrays, or multiple texture coordinate arrays.
+ */
+ if ( state->NoDrawArraysProtocol
+ || (state->vertArray.texture_enables > 1) ) {
+ emit_DrawArrays_old(state, first, count, mode);
+ }
+ else {
+ emit_DrawArraysEXT(state, first, count, mode);
+ }
+}
+
+
+/**
+ * \todo Modify this to use the "true" DrawArrays protocol if possible. This
+ * would probably require refactoring out parts of \c emit_DrawArraysEXT into
+ * more general functions that could be used in either place.
+ */
+void glDrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXvertArrayState *va = &state->vertArray;
+ const GLubyte *iPtr1 = NULL;
+ const GLushort *iPtr2 = NULL;
+ const GLuint *iPtr3 = NULL;
+ GLint i, j, offset = 0;
+
+ if ( ! glx_validate_array_args(gc, mode, count) ) {
+ return;
+ }
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ iPtr1 = (const GLubyte *)indices;
+ break;
+ case GL_UNSIGNED_SHORT:
+ iPtr2 = (const GLushort *)indices;
+ break;
+ case GL_UNSIGNED_INT:
+ iPtr3 = (const GLuint *)indices;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ glBegin(mode);
+ for (i = 0; i < count; i++) {
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ offset = (GLint)(*iPtr1++);
+ break;
+ case GL_UNSIGNED_SHORT:
+ offset = (GLint)(*iPtr2++);
+ break;
+ case GL_UNSIGNED_INT:
+ offset = (GLint)(*iPtr3++);
+ break;
+ }
+
+ if (IS_TEXARRAY_ENABLED(state, 0)) {
+ (*va->texCoord[0].proc)(va->texCoord[0].ptr+
+ (offset*va->texCoord[0].skip));
+ }
+
+ /* Multitexturing is handled specially because the protocol
+ * requires an extra parameter.
+ */
+ for (j=1; j<__GLX_MAX_TEXTURE_UNITS; ++j) {
+ if (IS_TEXARRAY_ENABLED(state, j)) {
+ (*va->texCoord[j].mtex_proc)(GL_TEXTURE0 + j,
+ va->texCoord[j].ptr+
+ (offset*va->texCoord[j].skip));
+ }
+ }
+
+ for ( j = 0 ; j < __GLX_MAX_ARRAYS ; j++ ) {
+ if (IS_ARRAY_ENABLED_BY_INDEX(state, j)) {
+ (*va->arrays[ j ].proc)(va->arrays[ j ].ptr
+ +(offset*va->arrays[ j ].skip));
+ }
+ }
+ }
+ glEnd();
+}
+
+void glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+
+ if (end < start) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ glDrawElements(mode,count,type,indices);
+}
+
+void glMultiDrawArrays(GLenum mode, GLint *first, GLsizei *count,
+ GLsizei primcount)
+{
+ GLsizei i;
+
+ for(i=0; i<primcount; i++) {
+ if ( count[i] > 0 ) {
+ glDrawArrays( mode, first[i], count[i] );
+ }
+ }
+}
+
+void glMultiDrawElements(GLenum mode, const GLsizei *count,
+ GLenum type, const GLvoid ** indices,
+ GLsizei primcount)
+{
+ GLsizei i;
+
+ for(i=0; i<primcount; i++) {
+ if ( count[i] > 0 ) {
+ glDrawElements( mode, count[i], type, indices[i] );
+ }
+ }
+}
+
+void glClientActiveTextureARB(GLenum texture)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ GLint unit = (GLint) texture - GL_TEXTURE0;
+
+ if (unit < 0 || __GLX_MAX_TEXTURE_UNITS <= unit) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ state->vertArray.activeTexture = unit;
+}
diff --git a/src/glx/x11/xf86dri.h b/src/glx/x11/xf86dri.h
new file mode 100644
index 0000000000..0a2bb24971
--- /dev/null
+++ b/src/glx/x11/xf86dri.h
@@ -0,0 +1,122 @@
+/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 xf86dri.h
+ * Protocol numbers and function prototypes for DRI X protocol.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+#ifndef _XF86DRI_H_
+#define _XF86DRI_H_
+
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+#define X_XF86DRIQueryVersion 0
+#define X_XF86DRIQueryDirectRenderingCapable 1
+#define X_XF86DRIOpenConnection 2
+#define X_XF86DRICloseConnection 3
+#define X_XF86DRIGetClientDriverName 4
+#define X_XF86DRICreateContext 5
+#define X_XF86DRIDestroyContext 6
+#define X_XF86DRICreateDrawable 7
+#define X_XF86DRIDestroyDrawable 8
+#define X_XF86DRIGetDrawableInfo 9
+#define X_XF86DRIGetDeviceInfo 10
+#define X_XF86DRIAuthConnection 11
+#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
+#define X_XF86DRICloseFullScreen 13 /* Deprecated */
+
+#define XF86DRINumberEvents 0
+
+#define XF86DRIClientNotLocal 0
+#define XF86DRIOperationNotSupported 1
+#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
+
+#ifndef _XF86DRI_SERVER_
+
+#include <GL/internal/dri_interface.h>
+
+_XFUNCPROTOBEGIN
+
+Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+
+Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion );
+
+Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
+ Bool *isCapable );
+
+Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
+ char **busIDString );
+
+Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+
+Bool XF86DRICloseConnection( Display *dpy, int screen );
+
+Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
+ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion, char **clientDriverName );
+
+Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+extern GLboolean XF86DRIDestroyContext( __DRInativeDisplay *dpy, int screen,
+ __DRIid context_id );
+
+extern GLboolean XF86DRICreateDrawable( __DRInativeDisplay *dpy, int screen,
+ __DRIid drawable, drm_drawable_t *hHWDrawable );
+
+extern GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay *dpy, int screen,
+ __DRIid drawable);
+
+Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
+ unsigned int *index, unsigned int *stamp,
+ int *X, int *Y, int *W, int *H,
+ int *numClipRects, drm_clip_rect_t ** pClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
+
+Bool XF86DRIGetDeviceInfo( Display *dpy, int screen,
+ drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
+ int *fbStride, int *devPrivateSize, void **pDevPrivate );
+
+_XFUNCPROTOEND
+
+#endif /* _XF86DRI_SERVER_ */
+
+#endif /* _XF86DRI_H_ */
+
diff --git a/src/glx/x11/xf86dristr.h b/src/glx/x11/xf86dristr.h
new file mode 100644
index 0000000000..ac05b183b3
--- /dev/null
+++ b/src/glx/x11/xf86dristr.h
@@ -0,0 +1,343 @@
+/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.10 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+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 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Fiath <faith@valinux.com>
+ *
+ */
+
+#ifndef _XF86DRISTR_H_
+#define _XF86DRISTR_H_
+
+#include "xf86dri.h"
+
+#define XF86DRINAME "XFree86-DRI"
+
+/* The DRI version number. This was originally set to be the same of the
+ * XFree86 version number. However, this version is really indepedent of
+ * the XFree86 version.
+ *
+ * Version History:
+ * 4.0.0: Original
+ * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
+ * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
+ */
+#define XF86DRI_MAJOR_VERSION 4
+#define XF86DRI_MINOR_VERSION 1
+#define XF86DRI_PATCH_VERSION 0
+
+typedef struct _XF86DRIQueryVersion {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
+} xXF86DRIQueryVersionReq;
+#define sz_xXF86DRIQueryVersionReq 4
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIQueryVersionReply;
+#define sz_xXF86DRIQueryVersionReply 32
+
+typedef struct _XF86DRIQueryDirectRenderingCapable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIQueryDirectRenderingCapableReq;
+#define sz_xXF86DRIQueryDirectRenderingCapableReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
+} xXF86DRIQueryDirectRenderingCapableReply;
+#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
+
+typedef struct _XF86DRIOpenConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIOpenConnectionReq;
+#define sz_xXF86DRIOpenConnectionReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hSAREALow B32;
+ CARD32 hSAREAHigh B32;
+ CARD32 busIdStringLength B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+} xXF86DRIOpenConnectionReply;
+#define sz_xXF86DRIOpenConnectionReply 32
+
+typedef struct _XF86DRIAuthConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
+} xXF86DRIAuthConnectionReq;
+#define sz_xXF86DRIAuthConnectionReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIAuthConnectionReply;
+#define zx_xXF86DRIAuthConnectionReply 32
+
+typedef struct _XF86DRICloseConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRICloseConnectionReq;
+#define sz_xXF86DRICloseConnectionReq 8
+
+typedef struct _XF86DRIGetClientDriverName {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetClientDriverName */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIGetClientDriverNameReq;
+#define sz_xXF86DRIGetClientDriverNameReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 ddxDriverMajorVersion B32;
+ CARD32 ddxDriverMinorVersion B32;
+ CARD32 ddxDriverPatchVersion B32;
+ CARD32 clientDriverNameLength B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIGetClientDriverNameReply;
+#define sz_xXF86DRIGetClientDriverNameReply 32
+
+typedef struct _XF86DRICreateContext {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 visual B32;
+ CARD32 context B32;
+} xXF86DRICreateContextReq;
+#define sz_xXF86DRICreateContextReq 16
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWContext B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRICreateContextReply;
+#define sz_xXF86DRICreateContextReply 32
+
+typedef struct _XF86DRIDestroyContext {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 context B32;
+} xXF86DRIDestroyContextReq;
+#define sz_xXF86DRIDestroyContextReq 12
+
+typedef struct _XF86DRICreateDrawable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRICreateDrawableReq;
+#define sz_xXF86DRICreateDrawableReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWDrawable B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRICreateDrawableReply;
+#define sz_xXF86DRICreateDrawableReply 32
+
+typedef struct _XF86DRIDestroyDrawable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIDestroyDrawableReq;
+#define sz_xXF86DRIDestroyDrawableReq 12
+
+typedef struct _XF86DRIGetDrawableInfo {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDrawableInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIGetDrawableInfoReq;
+#define sz_xXF86DRIGetDrawableInfoReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 drawableTableIndex B32;
+ CARD32 drawableTableStamp B32;
+ INT16 drawableX B16;
+ INT16 drawableY B16;
+ INT16 drawableWidth B16;
+ INT16 drawableHeight B16;
+ CARD32 numClipRects B32;
+ INT16 backX B16;
+ INT16 backY B16;
+ CARD32 numBackClipRects B32;
+} xXF86DRIGetDrawableInfoReply;
+
+#define sz_xXF86DRIGetDrawableInfoReply 36
+
+
+typedef struct _XF86DRIGetDeviceInfo {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDeviceInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIGetDeviceInfoReq;
+#define sz_xXF86DRIGetDeviceInfoReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hFrameBufferLow B32;
+ CARD32 hFrameBufferHigh B32;
+ CARD32 framebufferOrigin B32;
+ CARD32 framebufferSize B32;
+ CARD32 framebufferStride B32;
+ CARD32 devPrivateSize B32;
+} xXF86DRIGetDeviceInfoReply;
+#define sz_xXF86DRIGetDeviceInfoReply 32
+
+typedef struct _XF86DRIOpenFullScreen {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIOpenFullScreenReq;
+#define sz_xXF86DRIOpenFullScreenReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 isFullScreen B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIOpenFullScreenReply;
+#define sz_xXF86DRIOpenFullScreenReply 32
+
+typedef struct _XF86DRICloseFullScreen {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRICloseFullScreenReq;
+#define sz_xXF86DRICloseFullScreenReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+} xXF86DRICloseFullScreenReply;
+#define sz_xXF86DRICloseFullScreenReply 32
+
+
+#endif /* _XF86DRISTR_H_ */
diff --git a/src/glx/x11/xfont.c b/src/glx/x11/xfont.c
new file mode 100644
index 0000000000..5f23a79622
--- /dev/null
+++ b/src/glx/x11/xfont.c
@@ -0,0 +1,377 @@
+/* $XFree86: xc/lib/GL/glx/xfont.c,v 1.6 2001/05/02 15:06:02 dawes Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.1
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ */
+
+
+/* xfonts.c -- glXUseXFont() for Mesa written by
+ * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
+ */
+
+/*
+ This was take from Mesa and modified to work in the real GLX structure.
+ It provides a fully client side implementation of glXUseXFont and is
+ called by that routine when direct rendering is enabled.
+*/
+
+
+#include "glxclient.h"
+
+/* Some debugging info. */
+
+#ifdef DEBUG
+#undef _R
+#undef _G
+#undef _B
+#include <ctype.h>
+
+int debug_xfonts = 0;
+
+static void
+dump_char_struct (XCharStruct *ch, char *prefix)
+{
+ printf ("%slbearing = %d, rbearing = %d, width = %d\n",
+ prefix, ch->lbearing, ch->rbearing, ch->width);
+ printf ("%sascent = %d, descent = %d, attributes = %u\n",
+ prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
+}
+
+static void
+dump_font_struct (XFontStruct *font)
+{
+ printf ("ascent = %d, descent = %d\n", font->ascent, font->descent);
+ printf ("char_or_byte2 = (%u,%u)\n",
+ font->min_char_or_byte2, font->max_char_or_byte2);
+ printf ("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
+ printf ("all_chars_exist = %s\n", font->all_chars_exist ? "True" :
+"False");
+ printf ("default_char = %c (\\%03o)\n",
+ (char) (isprint (font->default_char) ? font->default_char : ' '),
+ font->default_char);
+ dump_char_struct (&font->min_bounds, "min> ");
+ dump_char_struct (&font->max_bounds, "max> ");
+#if 0
+ for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++)
+ {
+ char prefix[8];
+ sprintf (prefix, "%d> ", c);
+ dump_char_struct (&font->per_char[c], prefix);
+ }
+#endif
+}
+
+static void
+dump_bitmap (unsigned int width, unsigned int height, GLubyte *bitmap)
+{
+ unsigned int x, y;
+
+ printf (" ");
+ for (x = 0; x < 8*width; x++)
+ printf ("%o", 7 - (x % 8));
+ putchar ('\n');
+ for (y = 0; y < height; y++)
+ {
+ printf ("%3o:", y);
+ for (x = 0; x < 8*width; x++)
+ putchar ((bitmap[width*(height - y - 1) + x/8] & (1 << (7 - (x %
+8))))
+ ? '*' : '.');
+ printf (" ");
+ for (x = 0; x < width; x++)
+ printf ("0x%02x, ", bitmap[width*(height - y - 1) + x]);
+ putchar ('\n');
+ }
+}
+#endif /* DEBUG */
+
+
+/* Implementation. */
+
+/* Fill a BITMAP with a character C from thew current font
+ in the graphics context GC. WIDTH is the width in bytes
+ and HEIGHT is the height in bits.
+
+ Note that the generated bitmaps must be used with
+
+ glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+
+ Possible optimizations:
+
+ * use only one reusable pixmap with the maximum dimensions.
+ * draw the entire font into a single pixmap (careful with
+ proportional fonts!).
+*/
+
+
+/*
+ * Generate OpenGL-compatible bitmap.
+ */
+static void
+fill_bitmap (Display *dpy, Window win, GC gc,
+ unsigned int width, unsigned int height,
+ int x0, int y0, unsigned int c, GLubyte *bitmap)
+{
+ XImage *image;
+ unsigned int x, y;
+ Pixmap pixmap;
+ XChar2b char2b;
+
+ pixmap = XCreatePixmap (dpy, win, 8*width, height, 1);
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle (dpy, pixmap, gc, 0, 0, 8*width, height);
+ XSetForeground(dpy, gc, 1);
+
+ char2b.byte1 = (c >> 8) & 0xff;
+ char2b.byte2 = (c & 0xff);
+
+ XDrawString16 (dpy, pixmap, gc, x0, y0, &char2b, 1);
+
+ image = XGetImage (dpy, pixmap, 0, 0, 8*width, height, 1, XYPixmap);
+ if (image) {
+ /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
+ for (y = 0; y < height; y++)
+ for (x = 0; x < 8*width; x++)
+ if (XGetPixel (image, x, y))
+ bitmap[width*(height - y - 1) + x/8] |= (1 << (7 - (x % 8)));
+ XDestroyImage (image);
+ }
+
+ XFreePixmap (dpy, pixmap);
+}
+
+/*
+ * determine if a given glyph is valid and return the
+ * corresponding XCharStruct.
+ */
+static XCharStruct *isvalid(XFontStruct *fs, int which)
+{
+ unsigned int rows,pages;
+ int byte1 = 0, byte2 = 0;
+ int i,valid = 1;
+
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+
+ if (rows == 1) {
+ /* "linear" fonts */
+ if ((fs->min_char_or_byte2 > which) ||
+ (fs->max_char_or_byte2 < which)) valid = 0;
+ } else {
+ /* "matrix" fonts */
+ byte2 = which & 0xff;
+ byte1 = which >> 8;
+ if ((fs->min_char_or_byte2 > byte2) ||
+ (fs->max_char_or_byte2 < byte2) ||
+ (fs->min_byte1 > byte1) ||
+ (fs->max_byte1 < byte1)) valid = 0;
+ }
+
+ if (valid) {
+ if (fs->per_char) {
+ if (rows == 1) {
+ /* "linear" fonts */
+ return(fs->per_char + (which-fs->min_char_or_byte2) );
+ } else {
+ /* "matrix" fonts */
+ i = ((byte1 - fs->min_byte1) * pages) +
+ (byte2 - fs->min_char_or_byte2);
+ return(fs->per_char + i);
+ }
+ } else {
+ return(&fs->min_bounds);
+ }
+ }
+ return(NULL);
+}
+
+
+void DRI_glXUseXFont( Font font, int first, int count, int listbase )
+{
+ GLXContext CC;
+ Display *dpy;
+ Window win;
+ Pixmap pixmap;
+ GC gc;
+ XGCValues values;
+ unsigned long valuemask;
+ XFontStruct *fs;
+
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+
+ unsigned int max_width, max_height, max_bm_width, max_bm_height;
+ GLubyte *bm;
+
+ int i;
+
+ CC = __glXGetCurrentContext();
+ dpy = CC->currentDpy;
+ win = CC->currentDrawable;
+
+ fs = XQueryFont (dpy, font);
+ if (!fs)
+ {
+ __glXSetError(CC, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Allocate a bitmap that can fit all characters. */
+ max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
+ max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ max_bm_width = (max_width + 7) / 8;
+ max_bm_height = max_height;
+
+ bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof
+(GLubyte));
+ if (!bm) {
+ XFreeFontInfo( NULL, fs, 1 );
+ __glXSetError(CC, GL_OUT_OF_MEMORY);
+ return;
+ }
+
+#if 0
+ /* get the page info */
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+ firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
+ lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ unsigned int first_char, last_char, pages, rows;
+#endif
+
+ /* Save the current packing mode for bitmaps. */
+ glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
+ glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
+ glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
+ glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
+ glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
+ glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
+
+ /* Enforce a standard packing mode which is compatible with
+ fill_bitmap() from above. This is actually the default mode,
+ except for the (non)alignment. */
+ glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+
+ pixmap = XCreatePixmap (dpy, win, 10, 10, 1);
+ values.foreground = BlackPixel (dpy, DefaultScreen (dpy));
+ values.background = WhitePixel (dpy, DefaultScreen (dpy));
+ values.font = fs->fid;
+ valuemask = GCForeground | GCBackground | GCFont;
+ gc = XCreateGC (dpy, pixmap, valuemask, &values);
+ XFreePixmap (dpy, pixmap);
+
+#ifdef DEBUG
+ if (debug_xfonts)
+ dump_font_struct (fs);
+#endif
+
+ for (i = 0; i < count; i++)
+ {
+ unsigned int width, height, bm_width, bm_height;
+ GLfloat x0, y0, dx, dy;
+ XCharStruct *ch;
+ int x, y;
+ unsigned int c = first + i;
+ int list = listbase + i;
+ int valid;
+
+ /* check on index validity and get the bounds */
+ ch = isvalid(fs, c);
+ if (!ch) {
+ ch = &fs->max_bounds;
+ valid = 0;
+ } else {
+ valid = 1;
+ }
+
+#ifdef DEBUG
+ if (debug_xfonts) {
+ char s[7];
+ sprintf (s, isprint (c) ? "%c> " : "\\%03o> ", c);
+ dump_char_struct (ch, s);
+ }
+#endif
+
+ /* glBitmap()' parameters:
+ straight from the glXUseXFont(3) manpage. */
+ width = ch->rbearing - ch->lbearing;
+ height = ch->ascent + ch->descent;
+ x0 = - ch->lbearing;
+ y0 = ch->descent - 1;
+ dx = ch->width;
+ dy = 0;
+
+ /* X11's starting point. */
+ x = - ch->lbearing;
+ y = ch->ascent;
+
+ /* Round the width to a multiple of eight. We will use this also
+ for the pixmap for capturing the X11 font. This is slightly
+ inefficient, but it makes the OpenGL part real easy. */
+ bm_width = (width + 7) / 8;
+ bm_height = height;
+
+ glNewList (list, GL_COMPILE);
+ if (valid && (bm_width > 0) && (bm_height > 0)) {
+
+ memset (bm, '\0', bm_width * bm_height);
+ fill_bitmap (dpy, win, gc, bm_width, bm_height, x, y, c, bm);
+
+ glBitmap (width, height, x0, y0, dx, dy, bm);
+#ifdef DEBUG
+ if (debug_xfonts) {
+ printf ("width/height = %u/%u\n", width, height);
+ printf ("bm_width/bm_height = %u/%u\n", bm_width,
+bm_height);
+ dump_bitmap (bm_width, bm_height, bm);
+ }
+#endif
+ } else {
+ glBitmap (0, 0, 0.0, 0.0, dx, dy, NULL);
+ }
+ glEndList ();
+ }
+
+ Xfree(bm);
+ XFreeFontInfo( NULL, fs, 1 );
+ XFreeGC (dpy, gc);
+
+ /* Restore saved packing modes. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+}
+
+/* The End. */