17117f1b4Smrg/*
27117f1b4Smrg * Mesa 3-D graphics library
37117f1b4Smrg *
4c1f859d4Smrg * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
57117f1b4Smrg *
67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
77117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
87117f1b4Smrg * to deal in the Software without restriction, including without limitation
97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
117117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
127117f1b4Smrg *
137117f1b4Smrg * The above copyright notice and this permission notice shall be included
147117f1b4Smrg * in all copies or substantial portions of the Software.
157117f1b4Smrg *
167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
237117f1b4Smrg */
247117f1b4Smrg
257117f1b4Smrg
267117f1b4Smrg/*
27af69d88dSmrg * This is the GLX API dispatcher.  It uses a dispatch table but that's
28af69d88dSmrg * not really needed anymore since the table always points to the "fake"
29af69d88dSmrg * GLX functions.
307117f1b4Smrg */
317117f1b4Smrg
327117f1b4Smrg
337117f1b4Smrg#include <assert.h>
347117f1b4Smrg#include <stdlib.h>
357117f1b4Smrg#include <stdio.h>
367117f1b4Smrg#include <string.h>
37c1f859d4Smrg#include "main/glheader.h"
38c1f859d4Smrg#include "glapi/glapi.h"
397117f1b4Smrg#include "glxapi.h"
407117f1b4Smrg
417117f1b4Smrg
427117f1b4Smrgextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
437117f1b4Smrg
447117f1b4Smrg
457117f1b4Smrgstruct display_dispatch {
467117f1b4Smrg   Display *Dpy;
477117f1b4Smrg   struct _glxapi_table *Table;
487117f1b4Smrg   struct display_dispatch *Next;
497117f1b4Smrg};
507117f1b4Smrg
51cdc920a0Smrg
52cdc920a0Smrg/**
53cdc920a0Smrg * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
54cdc920a0Smrg * libglapi.a.  We need to define them here.
55cdc920a0Smrg */
56cdc920a0Smrg#ifdef GLX_INDIRECT_RENDERING
57cdc920a0Smrg
58cdc920a0Smrg#include "glapi/glapitable.h"
59cdc920a0Smrg
60cdc920a0Smrg#define KEYWORD1 PUBLIC
61cdc920a0Smrg
62cdc920a0Smrg#define NAME(func)  gl##func
63cdc920a0Smrg
64cdc920a0Smrg#define DISPATCH(FUNC, ARGS, MESSAGE)		\
653464ebd5Sriastradh   GET_DISPATCH()->FUNC ARGS
66cdc920a0Smrg
67cdc920a0Smrg#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) 	\
683464ebd5Sriastradh   return GET_DISPATCH()->FUNC ARGS
69cdc920a0Smrg
70cdc920a0Smrg/* skip normal ones */
71cdc920a0Smrg#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
727ec681f3Smrg#include "glapitemp.h"
73cdc920a0Smrg
74cdc920a0Smrg#endif /* GLX_INDIRECT_RENDERING */
75cdc920a0Smrg
76cdc920a0Smrg
777117f1b4Smrgstatic struct display_dispatch *DispatchList = NULL;
787117f1b4Smrg
797117f1b4Smrg
807117f1b4Smrg/* Display -> Dispatch caching */
817117f1b4Smrgstatic Display *prevDisplay = NULL;
827117f1b4Smrgstatic struct _glxapi_table *prevTable = NULL;
837117f1b4Smrg
847117f1b4Smrg
857117f1b4Smrgstatic struct _glxapi_table *
867117f1b4Smrgget_dispatch(Display *dpy)
877117f1b4Smrg{
887117f1b4Smrg   if (!dpy)
897117f1b4Smrg      return NULL;
907117f1b4Smrg
917117f1b4Smrg   /* search list of display/dispatch pairs for this display */
927117f1b4Smrg   {
937117f1b4Smrg      const struct display_dispatch *d = DispatchList;
947117f1b4Smrg      while (d) {
957117f1b4Smrg         if (d->Dpy == dpy) {
967117f1b4Smrg            prevDisplay = dpy;
977117f1b4Smrg            prevTable = d->Table;
987117f1b4Smrg            return d->Table;  /* done! */
997117f1b4Smrg         }
1007117f1b4Smrg         d = d->Next;
1017117f1b4Smrg      }
1027117f1b4Smrg   }
1037117f1b4Smrg
104af69d88dSmrg   /* Setup the dispatch table */
1057117f1b4Smrg   {
1067117f1b4Smrg      struct _glxapi_table *t = _mesa_GetGLXDispatchTable();
1077117f1b4Smrg
1087117f1b4Smrg      if (t) {
1097117f1b4Smrg         struct display_dispatch *d;
110af69d88dSmrg         d = malloc(sizeof(struct display_dispatch));
1117117f1b4Smrg         if (d) {
1127117f1b4Smrg            d->Dpy = dpy;
1137117f1b4Smrg            d->Table = t;
1147117f1b4Smrg            /* insert at head of list */
1157117f1b4Smrg            d->Next = DispatchList;
1167117f1b4Smrg            DispatchList = d;
1177117f1b4Smrg            /* update cache */
1187117f1b4Smrg            prevDisplay = dpy;
1197117f1b4Smrg            prevTable = t;
1207117f1b4Smrg            return t;
1217117f1b4Smrg         }
1227117f1b4Smrg      }
1237117f1b4Smrg   }
1247117f1b4Smrg
1257117f1b4Smrg   return NULL;
1267117f1b4Smrg}
1277117f1b4Smrg
1287117f1b4Smrg
129af69d88dSmrg/* Don't use the GET_DISPATCH macro */
1307117f1b4Smrg#undef GET_DISPATCH
1317117f1b4Smrg
1327117f1b4Smrg#define GET_DISPATCH(DPY, TABLE)	\
1337117f1b4Smrg   if (DPY == prevDisplay) {		\
1347117f1b4Smrg      TABLE = prevTable;		\
1357117f1b4Smrg   }					\
1367117f1b4Smrg   else if (!DPY) {			\
1377117f1b4Smrg      TABLE = NULL;			\
1387117f1b4Smrg   }					\
1397117f1b4Smrg   else {				\
1407117f1b4Smrg      TABLE = get_dispatch(DPY);	\
1417117f1b4Smrg   }
1427117f1b4Smrg
1437117f1b4Smrg
1447117f1b4Smrg/*
1457117f1b4Smrg * GLX API entrypoints
1467117f1b4Smrg */
1477117f1b4Smrg
1487117f1b4Smrg/*** GLX_VERSION_1_0 ***/
1497117f1b4Smrg
1507117f1b4SmrgXVisualInfo PUBLIC *
1517117f1b4SmrgglXChooseVisual(Display *dpy, int screen, int *list)
1527117f1b4Smrg{
1537117f1b4Smrg   struct _glxapi_table *t;
1547117f1b4Smrg   GET_DISPATCH(dpy, t);
1557117f1b4Smrg   if (!t)
1567117f1b4Smrg      return NULL;
15701e04c3fSmrg   return t->ChooseVisual(dpy, screen, list);
1587117f1b4Smrg}
1597117f1b4Smrg
1607117f1b4Smrg
1617117f1b4Smrgvoid PUBLIC
1627117f1b4SmrgglXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
1637117f1b4Smrg{
1647117f1b4Smrg   struct _glxapi_table *t;
1657117f1b4Smrg   GET_DISPATCH(dpy, t);
1667117f1b4Smrg   if (!t)
1677117f1b4Smrg      return;
16801e04c3fSmrg   t->CopyContext(dpy, src, dst, mask);
1697117f1b4Smrg}
1707117f1b4Smrg
1717117f1b4Smrg
1727117f1b4SmrgGLXContext PUBLIC
1737117f1b4SmrgglXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
1747117f1b4Smrg{
1757117f1b4Smrg   struct _glxapi_table *t;
1767117f1b4Smrg   GET_DISPATCH(dpy, t);
1777117f1b4Smrg   if (!t)
1787117f1b4Smrg      return 0;
17901e04c3fSmrg   return t->CreateContext(dpy, visinfo, shareList, direct);
1807117f1b4Smrg}
1817117f1b4Smrg
1827117f1b4Smrg
1837117f1b4SmrgGLXPixmap PUBLIC
1847117f1b4SmrgglXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
1857117f1b4Smrg{
1867117f1b4Smrg   struct _glxapi_table *t;
1877117f1b4Smrg   GET_DISPATCH(dpy, t);
1887117f1b4Smrg   if (!t)
1897117f1b4Smrg      return 0;
19001e04c3fSmrg   return t->CreateGLXPixmap(dpy, visinfo, pixmap);
1917117f1b4Smrg}
1927117f1b4Smrg
1937117f1b4Smrg
1947117f1b4Smrgvoid PUBLIC
1957117f1b4SmrgglXDestroyContext(Display *dpy, GLXContext ctx)
1967117f1b4Smrg{
1977117f1b4Smrg   struct _glxapi_table *t;
1987117f1b4Smrg   GET_DISPATCH(dpy, t);
1997117f1b4Smrg   if (!t)
2007117f1b4Smrg      return;
20101e04c3fSmrg   t->DestroyContext(dpy, ctx);
2027117f1b4Smrg}
2037117f1b4Smrg
2047117f1b4Smrg
2057117f1b4Smrgvoid PUBLIC
2067117f1b4SmrgglXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
2077117f1b4Smrg{
2087117f1b4Smrg   struct _glxapi_table *t;
2097117f1b4Smrg   GET_DISPATCH(dpy, t);
2107117f1b4Smrg   if (!t)
2117117f1b4Smrg      return;
21201e04c3fSmrg   t->DestroyGLXPixmap(dpy, pixmap);
2137117f1b4Smrg}
2147117f1b4Smrg
2157117f1b4Smrg
2167117f1b4Smrgint PUBLIC
2177117f1b4SmrgglXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
2187117f1b4Smrg{
2197117f1b4Smrg   struct _glxapi_table *t;
2207117f1b4Smrg   GET_DISPATCH(dpy, t);
2217117f1b4Smrg   if (!t)
2227117f1b4Smrg      return GLX_NO_EXTENSION;
22301e04c3fSmrg   return t->GetConfig(dpy, visinfo, attrib, value);
2247117f1b4Smrg}
2257117f1b4Smrg
2267117f1b4Smrg
227af69d88dSmrg/* declare here to avoid including xmesa.h */
228af69d88dSmrgextern void *XMesaGetCurrentContext(void);
229af69d88dSmrg
2307117f1b4SmrgGLXContext PUBLIC
2317117f1b4SmrgglXGetCurrentContext(void)
2327117f1b4Smrg{
233af69d88dSmrg   return (GLXContext) XMesaGetCurrentContext();
2347117f1b4Smrg}
2357117f1b4Smrg
2367117f1b4Smrg
2377117f1b4SmrgGLXDrawable PUBLIC
2387117f1b4SmrgglXGetCurrentDrawable(void)
2397117f1b4Smrg{
2407117f1b4Smrg   __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
2417117f1b4Smrg   return gc ? gc->currentDrawable : 0;
2427117f1b4Smrg}
2437117f1b4Smrg
2447117f1b4Smrg
2457117f1b4SmrgBool PUBLIC
2467117f1b4SmrgglXIsDirect(Display *dpy, GLXContext ctx)
2477117f1b4Smrg{
2487117f1b4Smrg   struct _glxapi_table *t;
2497117f1b4Smrg   GET_DISPATCH(dpy, t);
2507117f1b4Smrg   if (!t)
2517117f1b4Smrg      return False;
25201e04c3fSmrg   return t->IsDirect(dpy, ctx);
2537117f1b4Smrg}
2547117f1b4Smrg
2557117f1b4Smrg
2567117f1b4SmrgBool PUBLIC
2577117f1b4SmrgglXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
2587117f1b4Smrg{
2597117f1b4Smrg   Bool b;
2607117f1b4Smrg   struct _glxapi_table *t;
2617117f1b4Smrg   GET_DISPATCH(dpy, t);
2627117f1b4Smrg   if (!t) {
2637117f1b4Smrg      return False;
2647117f1b4Smrg   }
26501e04c3fSmrg   b = t->MakeCurrent(dpy, drawable, ctx);
2667117f1b4Smrg   return b;
2677117f1b4Smrg}
2687117f1b4Smrg
2697117f1b4Smrg
2707117f1b4SmrgBool PUBLIC
2717117f1b4SmrgglXQueryExtension(Display *dpy, int *errorb, int *event)
2727117f1b4Smrg{
2737117f1b4Smrg   struct _glxapi_table *t;
2747117f1b4Smrg   GET_DISPATCH(dpy, t);
2757117f1b4Smrg   if (!t)
2767117f1b4Smrg      return False;
27701e04c3fSmrg   return t->QueryExtension(dpy, errorb, event);
2787117f1b4Smrg}
2797117f1b4Smrg
2807117f1b4Smrg
2817117f1b4SmrgBool PUBLIC
2827117f1b4SmrgglXQueryVersion(Display *dpy, int *maj, int *min)
2837117f1b4Smrg{
2847117f1b4Smrg   struct _glxapi_table *t;
2857117f1b4Smrg   GET_DISPATCH(dpy, t);
2867117f1b4Smrg   if (!t)
2877117f1b4Smrg      return False;
28801e04c3fSmrg   return t->QueryVersion(dpy, maj, min);
2897117f1b4Smrg}
2907117f1b4Smrg
2917117f1b4Smrg
2927117f1b4Smrgvoid PUBLIC
2937117f1b4SmrgglXSwapBuffers(Display *dpy, GLXDrawable drawable)
2947117f1b4Smrg{
2957117f1b4Smrg   struct _glxapi_table *t;
2967117f1b4Smrg   GET_DISPATCH(dpy, t);
2977117f1b4Smrg   if (!t)
2987117f1b4Smrg      return;
29901e04c3fSmrg   t->SwapBuffers(dpy, drawable);
3007117f1b4Smrg}
3017117f1b4Smrg
3027117f1b4Smrg
3037117f1b4Smrgvoid PUBLIC
3047117f1b4SmrgglXUseXFont(Font font, int first, int count, int listBase)
3057117f1b4Smrg{
3067117f1b4Smrg   struct _glxapi_table *t;
3077117f1b4Smrg   Display *dpy = glXGetCurrentDisplay();
3087117f1b4Smrg   GET_DISPATCH(dpy, t);
3097117f1b4Smrg   if (!t)
3107117f1b4Smrg      return;
31101e04c3fSmrg   t->UseXFont(font, first, count, listBase);
3127117f1b4Smrg}
3137117f1b4Smrg
3147117f1b4Smrg
3157117f1b4Smrgvoid PUBLIC
3167117f1b4SmrgglXWaitGL(void)
3177117f1b4Smrg{
3187117f1b4Smrg   struct _glxapi_table *t;
3197117f1b4Smrg   Display *dpy = glXGetCurrentDisplay();
3207117f1b4Smrg   GET_DISPATCH(dpy, t);
3217117f1b4Smrg   if (!t)
3227117f1b4Smrg      return;
32301e04c3fSmrg   t->WaitGL();
3247117f1b4Smrg}
3257117f1b4Smrg
3267117f1b4Smrg
3277117f1b4Smrgvoid PUBLIC
3287117f1b4SmrgglXWaitX(void)
3297117f1b4Smrg{
3307117f1b4Smrg   struct _glxapi_table *t;
3317117f1b4Smrg   Display *dpy = glXGetCurrentDisplay();
3327117f1b4Smrg   GET_DISPATCH(dpy, t);
3337117f1b4Smrg   if (!t)
3347117f1b4Smrg      return;
33501e04c3fSmrg   t->WaitX();
3367117f1b4Smrg}
3377117f1b4Smrg
3387117f1b4Smrg
3397117f1b4Smrg
3407117f1b4Smrg/*** GLX_VERSION_1_1 ***/
3417117f1b4Smrg
3427117f1b4Smrgconst char PUBLIC *
3437117f1b4SmrgglXGetClientString(Display *dpy, int name)
3447117f1b4Smrg{
3457117f1b4Smrg   struct _glxapi_table *t;
3467117f1b4Smrg   GET_DISPATCH(dpy, t);
3477117f1b4Smrg   if (!t)
3487117f1b4Smrg      return NULL;
34901e04c3fSmrg   return t->GetClientString(dpy, name);
3507117f1b4Smrg}
3517117f1b4Smrg
3527117f1b4Smrg
3537117f1b4Smrgconst char PUBLIC *
3547117f1b4SmrgglXQueryExtensionsString(Display *dpy, int screen)
3557117f1b4Smrg{
3567117f1b4Smrg   struct _glxapi_table *t;
3577117f1b4Smrg   GET_DISPATCH(dpy, t);
3587117f1b4Smrg   if (!t)
3597117f1b4Smrg      return NULL;
36001e04c3fSmrg   return t->QueryExtensionsString(dpy, screen);
3617117f1b4Smrg}
3627117f1b4Smrg
3637117f1b4Smrg
3647117f1b4Smrgconst char PUBLIC *
3657117f1b4SmrgglXQueryServerString(Display *dpy, int screen, int name)
3667117f1b4Smrg{
3677117f1b4Smrg   struct _glxapi_table *t;
3687117f1b4Smrg   GET_DISPATCH(dpy, t);
3697117f1b4Smrg   if (!t)
3707117f1b4Smrg      return NULL;
37101e04c3fSmrg   return t->QueryServerString(dpy, screen, name);
3727117f1b4Smrg}
3737117f1b4Smrg
3747117f1b4Smrg
3757117f1b4Smrg/*** GLX_VERSION_1_2 ***/
3767117f1b4Smrg
37701e04c3fSmrg/* declare here to avoid including xmesa.h */
37801e04c3fSmrgextern Display *XMesaGetCurrentDisplay(void);
37901e04c3fSmrg
3807117f1b4SmrgDisplay PUBLIC *
3817117f1b4SmrgglXGetCurrentDisplay(void)
3827117f1b4Smrg{
38301e04c3fSmrg   return XMesaGetCurrentDisplay();
3847117f1b4Smrg}
3857117f1b4Smrg
3867117f1b4Smrg
3877117f1b4Smrg
3887117f1b4Smrg/*** GLX_VERSION_1_3 ***/
3897117f1b4Smrg
3907117f1b4SmrgGLXFBConfig PUBLIC *
3917117f1b4SmrgglXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
3927117f1b4Smrg{
3937117f1b4Smrg   struct _glxapi_table *t;
3947117f1b4Smrg   GET_DISPATCH(dpy, t);
3957117f1b4Smrg   if (!t)
3967117f1b4Smrg      return 0;
39701e04c3fSmrg   return t->ChooseFBConfig(dpy, screen, attribList, nitems);
3987117f1b4Smrg}
3997117f1b4Smrg
4007117f1b4Smrg
4017117f1b4SmrgGLXContext PUBLIC
4027117f1b4SmrgglXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
4037117f1b4Smrg{
4047117f1b4Smrg   struct _glxapi_table *t;
4057117f1b4Smrg   GET_DISPATCH(dpy, t);
4067117f1b4Smrg   if (!t)
4077117f1b4Smrg      return 0;
40801e04c3fSmrg   return t->CreateNewContext(dpy, config, renderType, shareList, direct);
4097117f1b4Smrg}
4107117f1b4Smrg
4117117f1b4Smrg
4127117f1b4SmrgGLXPbuffer PUBLIC
4137117f1b4SmrgglXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
4147117f1b4Smrg{
4157117f1b4Smrg   struct _glxapi_table *t;
4167117f1b4Smrg   GET_DISPATCH(dpy, t);
4177117f1b4Smrg   if (!t)
4187117f1b4Smrg      return 0;
41901e04c3fSmrg   return t->CreatePbuffer(dpy, config, attribList);
4207117f1b4Smrg}
4217117f1b4Smrg
4227117f1b4Smrg
4237117f1b4SmrgGLXPixmap PUBLIC
4247117f1b4SmrgglXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
4257117f1b4Smrg{
4267117f1b4Smrg   struct _glxapi_table *t;
4277117f1b4Smrg   GET_DISPATCH(dpy, t);
4287117f1b4Smrg   if (!t)
4297117f1b4Smrg      return 0;
43001e04c3fSmrg   return t->CreatePixmap(dpy, config, pixmap, attribList);
4317117f1b4Smrg}
4327117f1b4Smrg
4337117f1b4Smrg
4347117f1b4SmrgGLXWindow PUBLIC
4357117f1b4SmrgglXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
4367117f1b4Smrg{
4377117f1b4Smrg   struct _glxapi_table *t;
4387117f1b4Smrg   GET_DISPATCH(dpy, t);
4397117f1b4Smrg   if (!t)
4407117f1b4Smrg      return 0;
44101e04c3fSmrg   return t->CreateWindow(dpy, config, win, attribList);
4427117f1b4Smrg}
4437117f1b4Smrg
4447117f1b4Smrg
4457117f1b4Smrgvoid PUBLIC
4467117f1b4SmrgglXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
4477117f1b4Smrg{
4487117f1b4Smrg   struct _glxapi_table *t;
4497117f1b4Smrg   GET_DISPATCH(dpy, t);
4507117f1b4Smrg   if (!t)
4517117f1b4Smrg      return;
45201e04c3fSmrg   t->DestroyPbuffer(dpy, pbuf);
4537117f1b4Smrg}
4547117f1b4Smrg
4557117f1b4Smrg
4567117f1b4Smrgvoid PUBLIC
4577117f1b4SmrgglXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
4587117f1b4Smrg{
4597117f1b4Smrg   struct _glxapi_table *t;
4607117f1b4Smrg   GET_DISPATCH(dpy, t);
4617117f1b4Smrg   if (!t)
4627117f1b4Smrg      return;
46301e04c3fSmrg   t->DestroyPixmap(dpy, pixmap);
4647117f1b4Smrg}
4657117f1b4Smrg
4667117f1b4Smrg
4677117f1b4Smrgvoid PUBLIC
4687117f1b4SmrgglXDestroyWindow(Display *dpy, GLXWindow window)
4697117f1b4Smrg{
4707117f1b4Smrg   struct _glxapi_table *t;
4717117f1b4Smrg   GET_DISPATCH(dpy, t);
4727117f1b4Smrg   if (!t)
4737117f1b4Smrg      return;
47401e04c3fSmrg   t->DestroyWindow(dpy, window);
4757117f1b4Smrg}
4767117f1b4Smrg
4777117f1b4Smrg
4787117f1b4SmrgGLXDrawable PUBLIC
4797117f1b4SmrgglXGetCurrentReadDrawable(void)
4807117f1b4Smrg{
4817117f1b4Smrg   __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
4827117f1b4Smrg   return gc ? gc->currentReadable : 0;
4837117f1b4Smrg}
4847117f1b4Smrg
4857117f1b4Smrg
4867117f1b4Smrgint PUBLIC
4877117f1b4SmrgglXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
4887117f1b4Smrg{
4897117f1b4Smrg   struct _glxapi_table *t;
4907117f1b4Smrg   GET_DISPATCH(dpy, t);
4917117f1b4Smrg   if (!t)
4927117f1b4Smrg      return GLX_NO_EXTENSION;
49301e04c3fSmrg   return t->GetFBConfigAttrib(dpy, config, attribute, value);
4947117f1b4Smrg}
4957117f1b4Smrg
4967117f1b4Smrg
4977117f1b4SmrgGLXFBConfig PUBLIC *
4987117f1b4SmrgglXGetFBConfigs(Display *dpy, int screen, int *nelements)
4997117f1b4Smrg{
5007117f1b4Smrg   struct _glxapi_table *t;
5017117f1b4Smrg   GET_DISPATCH(dpy, t);
5027117f1b4Smrg   if (!t)
5037117f1b4Smrg      return 0;
50401e04c3fSmrg   return t->GetFBConfigs(dpy, screen, nelements);
5057117f1b4Smrg}
5067117f1b4Smrg
5077117f1b4Smrgvoid PUBLIC
5087117f1b4SmrgglXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
5097117f1b4Smrg{
5107117f1b4Smrg   struct _glxapi_table *t;
5117117f1b4Smrg   GET_DISPATCH(dpy, t);
5127117f1b4Smrg   if (!t)
5137117f1b4Smrg      return;
51401e04c3fSmrg   t->GetSelectedEvent(dpy, drawable, mask);
5157117f1b4Smrg}
5167117f1b4Smrg
5177117f1b4Smrg
5187117f1b4SmrgXVisualInfo PUBLIC *
5197117f1b4SmrgglXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
5207117f1b4Smrg{
5217117f1b4Smrg   struct _glxapi_table *t;
5227117f1b4Smrg   GET_DISPATCH(dpy, t);
5237117f1b4Smrg   if (!t)
5247117f1b4Smrg      return NULL;
52501e04c3fSmrg   return t->GetVisualFromFBConfig(dpy, config);
5267117f1b4Smrg}
5277117f1b4Smrg
5287117f1b4Smrg
5297117f1b4SmrgBool PUBLIC
5307117f1b4SmrgglXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
5317117f1b4Smrg{
5327117f1b4Smrg   Bool b;
5337117f1b4Smrg   struct _glxapi_table *t;
5347117f1b4Smrg   GET_DISPATCH(dpy, t);
5357117f1b4Smrg   if (!t)
5367117f1b4Smrg      return False;
53701e04c3fSmrg   b = t->MakeContextCurrent(dpy, draw, read, ctx);
5387117f1b4Smrg   return b;
5397117f1b4Smrg}
5407117f1b4Smrg
5417117f1b4Smrg
5427117f1b4Smrgint PUBLIC
5437117f1b4SmrgglXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
5447117f1b4Smrg{
5457117f1b4Smrg   struct _glxapi_table *t;
5467117f1b4Smrg   GET_DISPATCH(dpy, t);
5477117f1b4Smrg   assert(t);
5487117f1b4Smrg   if (!t)
5497117f1b4Smrg      return 0; /* XXX correct? */
55001e04c3fSmrg   return t->QueryContext(dpy, ctx, attribute, value);
5517117f1b4Smrg}
5527117f1b4Smrg
5537117f1b4Smrg
5547117f1b4Smrgvoid PUBLIC
5557117f1b4SmrgglXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
5567117f1b4Smrg{
5577117f1b4Smrg   struct _glxapi_table *t;
5587117f1b4Smrg   GET_DISPATCH(dpy, t);
5597117f1b4Smrg   if (!t)
5607117f1b4Smrg      return;
56101e04c3fSmrg   t->QueryDrawable(dpy, draw, attribute, value);
5627117f1b4Smrg}
5637117f1b4Smrg
5647117f1b4Smrg
5657117f1b4Smrgvoid PUBLIC
5667117f1b4SmrgglXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
5677117f1b4Smrg{
5687117f1b4Smrg   struct _glxapi_table *t;
5697117f1b4Smrg   GET_DISPATCH(dpy, t);
5707117f1b4Smrg   if (!t)
5717117f1b4Smrg      return;
57201e04c3fSmrg   t->SelectEvent(dpy, drawable, mask);
5737117f1b4Smrg}
5747117f1b4Smrg
5757117f1b4Smrg
5767117f1b4Smrg
5777117f1b4Smrg/*** GLX_SGI_swap_control ***/
5787117f1b4Smrg
5797117f1b4Smrgint PUBLIC
5807117f1b4SmrgglXSwapIntervalSGI(int interval)
5817117f1b4Smrg{
5827117f1b4Smrg   struct _glxapi_table *t;
5837117f1b4Smrg   Display *dpy = glXGetCurrentDisplay();
5847117f1b4Smrg   GET_DISPATCH(dpy, t);
5857117f1b4Smrg   if (!t)
5867117f1b4Smrg      return 0;
58701e04c3fSmrg   return t->SwapIntervalSGI(interval);
5887117f1b4Smrg}
5897117f1b4Smrg
5907117f1b4Smrg
5917117f1b4Smrg
5927117f1b4Smrg/*** GLX_SGI_video_sync ***/
5937117f1b4Smrg
5947117f1b4Smrgint PUBLIC
5957117f1b4SmrgglXGetVideoSyncSGI(unsigned int *count)
5967117f1b4Smrg{
5977117f1b4Smrg   struct _glxapi_table *t;
5987117f1b4Smrg   Display *dpy = glXGetCurrentDisplay();
5997117f1b4Smrg   GET_DISPATCH(dpy, t);
6007117f1b4Smrg   if (!t || !glXGetCurrentContext())
6017117f1b4Smrg      return GLX_BAD_CONTEXT;
60201e04c3fSmrg   return t->GetVideoSyncSGI(count);
6037117f1b4Smrg}
6047117f1b4Smrg
6057117f1b4Smrgint PUBLIC
6067117f1b4SmrgglXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
6077117f1b4Smrg{
6087117f1b4Smrg   struct _glxapi_table *t;
6097117f1b4Smrg   Display *dpy = glXGetCurrentDisplay();
6107117f1b4Smrg   GET_DISPATCH(dpy, t);
6117117f1b4Smrg   if (!t || !glXGetCurrentContext())
6127117f1b4Smrg      return GLX_BAD_CONTEXT;
61301e04c3fSmrg   return t->WaitVideoSyncSGI(divisor, remainder, count);
6147117f1b4Smrg}
6157117f1b4Smrg
6167117f1b4Smrg
6177117f1b4Smrg
6187117f1b4Smrg/*** GLX_SGI_make_current_read ***/
6197117f1b4Smrg
6207117f1b4SmrgBool PUBLIC
6217117f1b4SmrgglXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
6227117f1b4Smrg{
6237117f1b4Smrg   struct _glxapi_table *t;
6247117f1b4Smrg   GET_DISPATCH(dpy, t);
6257117f1b4Smrg   if (!t)
6267117f1b4Smrg      return False;
62701e04c3fSmrg   return t->MakeCurrentReadSGI(dpy, draw, read, ctx);
6287117f1b4Smrg}
6297117f1b4Smrg
6307117f1b4SmrgGLXDrawable PUBLIC
6317117f1b4SmrgglXGetCurrentReadDrawableSGI(void)
6327117f1b4Smrg{
6337117f1b4Smrg   return glXGetCurrentReadDrawable();
6347117f1b4Smrg}
6357117f1b4Smrg
6367117f1b4Smrg
6377117f1b4Smrg#if defined(_VL_H)
6387117f1b4Smrg
6397117f1b4SmrgGLXVideoSourceSGIX PUBLIC
6407117f1b4SmrgglXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
6417117f1b4Smrg{
6427117f1b4Smrg   struct _glxapi_table *t;
6437117f1b4Smrg   GET_DISPATCH(dpy, t);
6447117f1b4Smrg   if (!t)
6457117f1b4Smrg      return 0;
64601e04c3fSmrg   return t->CreateGLXVideoSourceSGIX(dpy, screen, server, path, nodeClass, drainNode);
6477117f1b4Smrg}
6487117f1b4Smrg
6497117f1b4Smrgvoid PUBLIC
6507117f1b4SmrgglXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
6517117f1b4Smrg{
6527117f1b4Smrg   struct _glxapi_table *t;
6537117f1b4Smrg   GET_DISPATCH(dpy, t);
6547117f1b4Smrg   if (!t)
6557117f1b4Smrg      return 0;
65601e04c3fSmrg   return t->DestroyGLXVideoSourceSGIX(dpy, src);
6577117f1b4Smrg}
6587117f1b4Smrg
6597117f1b4Smrg#endif
6607117f1b4Smrg
6617117f1b4Smrg
6627117f1b4Smrg/*** GLX_EXT_import_context ***/
6637117f1b4Smrg
6647117f1b4Smrgvoid PUBLIC
6657117f1b4SmrgglXFreeContextEXT(Display *dpy, GLXContext context)
6667117f1b4Smrg{
6677117f1b4Smrg   struct _glxapi_table *t;
6687117f1b4Smrg   GET_DISPATCH(dpy, t);
6697117f1b4Smrg   if (!t)
6707117f1b4Smrg      return;
67101e04c3fSmrg   t->FreeContextEXT(dpy, context);
6727117f1b4Smrg}
6737117f1b4Smrg
6747117f1b4SmrgGLXContextID PUBLIC
6757117f1b4SmrgglXGetContextIDEXT(const GLXContext context)
6767117f1b4Smrg{
6777117f1b4Smrg   return ((__GLXcontext *) context)->xid;
6787117f1b4Smrg}
6797117f1b4Smrg
6807117f1b4SmrgDisplay PUBLIC *
6817117f1b4SmrgglXGetCurrentDisplayEXT(void)
6827117f1b4Smrg{
6837117f1b4Smrg   return glXGetCurrentDisplay();
6847117f1b4Smrg}
6857117f1b4Smrg
6867117f1b4SmrgGLXContext PUBLIC
6877117f1b4SmrgglXImportContextEXT(Display *dpy, GLXContextID contextID)
6887117f1b4Smrg{
6897117f1b4Smrg   struct _glxapi_table *t;
6907117f1b4Smrg   GET_DISPATCH(dpy, t);
6917117f1b4Smrg   if (!t)
6927117f1b4Smrg      return 0;
69301e04c3fSmrg   return t->ImportContextEXT(dpy, contextID);
6947117f1b4Smrg}
6957117f1b4Smrg
6967117f1b4Smrgint PUBLIC
6977117f1b4SmrgglXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
6987117f1b4Smrg{
6997117f1b4Smrg   struct _glxapi_table *t;
7007117f1b4Smrg   GET_DISPATCH(dpy, t);
7017117f1b4Smrg   if (!t)
7027117f1b4Smrg      return 0;  /* XXX ok? */
70301e04c3fSmrg   return t->QueryContextInfoEXT(dpy, context, attribute, value);
7047117f1b4Smrg}
7057117f1b4Smrg
7067117f1b4Smrg
7077117f1b4Smrg
7087117f1b4Smrg/*** GLX_SGIX_fbconfig ***/
7097117f1b4Smrg
7107117f1b4Smrgint PUBLIC
7117117f1b4SmrgglXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
7127117f1b4Smrg{
7137117f1b4Smrg   struct _glxapi_table *t;
7147117f1b4Smrg   GET_DISPATCH(dpy, t);
7157117f1b4Smrg   if (!t)
7167117f1b4Smrg      return 0;
71701e04c3fSmrg   return t->GetFBConfigAttribSGIX(dpy, config, attribute, value);
7187117f1b4Smrg}
7197117f1b4Smrg
7207117f1b4SmrgGLXFBConfigSGIX PUBLIC *
7217117f1b4SmrgglXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
7227117f1b4Smrg{
7237117f1b4Smrg   struct _glxapi_table *t;
7247117f1b4Smrg   GET_DISPATCH(dpy, t);
7257117f1b4Smrg   if (!t)
7267117f1b4Smrg      return 0;
72701e04c3fSmrg   return t->ChooseFBConfigSGIX(dpy, screen, attrib_list, nelements);
7287117f1b4Smrg}
7297117f1b4Smrg
7307117f1b4SmrgGLXPixmap PUBLIC
7317117f1b4SmrgglXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
7327117f1b4Smrg{
7337117f1b4Smrg   struct _glxapi_table *t;
7347117f1b4Smrg   GET_DISPATCH(dpy, t);
7357117f1b4Smrg   if (!t)
7367117f1b4Smrg      return 0;
73701e04c3fSmrg   return t->CreateGLXPixmapWithConfigSGIX(dpy, config, pixmap);
7387117f1b4Smrg}
7397117f1b4Smrg
7407117f1b4SmrgGLXContext PUBLIC
7417117f1b4SmrgglXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
7427117f1b4Smrg{
7437117f1b4Smrg   struct _glxapi_table *t;
7447117f1b4Smrg   GET_DISPATCH(dpy, t);
7457117f1b4Smrg   if (!t)
7467117f1b4Smrg      return 0;
74701e04c3fSmrg   return t->CreateContextWithConfigSGIX(dpy, config, render_type, share_list, direct);
7487117f1b4Smrg}
7497117f1b4Smrg
7507117f1b4SmrgXVisualInfo PUBLIC *
7517117f1b4SmrgglXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
7527117f1b4Smrg{
7537117f1b4Smrg   struct _glxapi_table *t;
7547117f1b4Smrg   GET_DISPATCH(dpy, t);
7557117f1b4Smrg   if (!t)
7567117f1b4Smrg      return 0;
75701e04c3fSmrg   return t->GetVisualFromFBConfigSGIX(dpy, config);
7587117f1b4Smrg}
7597117f1b4Smrg
7607117f1b4SmrgGLXFBConfigSGIX PUBLIC
7617117f1b4SmrgglXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
7627117f1b4Smrg{
7637117f1b4Smrg   struct _glxapi_table *t;
7647117f1b4Smrg   GET_DISPATCH(dpy, t);
7657117f1b4Smrg   if (!t)
7667117f1b4Smrg      return 0;
76701e04c3fSmrg   return t->GetFBConfigFromVisualSGIX(dpy, vis);
7687117f1b4Smrg}
7697117f1b4Smrg
7707117f1b4Smrg
7717117f1b4Smrg
7727117f1b4Smrg/*** GLX_SGIX_pbuffer ***/
7737117f1b4Smrg
7747117f1b4SmrgGLXPbufferSGIX PUBLIC
7757117f1b4SmrgglXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
7767117f1b4Smrg{
7777117f1b4Smrg   struct _glxapi_table *t;
7787117f1b4Smrg   GET_DISPATCH(dpy, t);
7797117f1b4Smrg   if (!t)
7807117f1b4Smrg      return 0;
78101e04c3fSmrg   return t->CreateGLXPbufferSGIX(dpy, config, width, height, attrib_list);
7827117f1b4Smrg}
7837117f1b4Smrg
7847117f1b4Smrgvoid PUBLIC
7857117f1b4SmrgglXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
7867117f1b4Smrg{
7877117f1b4Smrg   struct _glxapi_table *t;
7887117f1b4Smrg   GET_DISPATCH(dpy, t);
7897117f1b4Smrg   if (!t)
7907117f1b4Smrg      return;
79101e04c3fSmrg   t->DestroyGLXPbufferSGIX(dpy, pbuf);
7927117f1b4Smrg}
7937117f1b4Smrg
7947ec681f3Smrgvoid PUBLIC
7957117f1b4SmrgglXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
7967117f1b4Smrg{
7977117f1b4Smrg   struct _glxapi_table *t;
7987117f1b4Smrg   GET_DISPATCH(dpy, t);
7997117f1b4Smrg   if (!t)
8007ec681f3Smrg      return;
8017ec681f3Smrg   t->QueryGLXPbufferSGIX(dpy, pbuf, attribute, value);
8027117f1b4Smrg}
8037117f1b4Smrg
8047117f1b4Smrgvoid PUBLIC
8057117f1b4SmrgglXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
8067117f1b4Smrg{
8077117f1b4Smrg   struct _glxapi_table *t;
8087117f1b4Smrg   GET_DISPATCH(dpy, t);
8097117f1b4Smrg   if (!t)
8107117f1b4Smrg      return;
81101e04c3fSmrg   t->SelectEventSGIX(dpy, drawable, mask);
8127117f1b4Smrg}
8137117f1b4Smrg
8147117f1b4Smrgvoid PUBLIC
8157117f1b4SmrgglXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
8167117f1b4Smrg{
8177117f1b4Smrg   struct _glxapi_table *t;
8187117f1b4Smrg   GET_DISPATCH(dpy, t);
8197117f1b4Smrg   if (!t)
8207117f1b4Smrg      return;
82101e04c3fSmrg   t->GetSelectedEventSGIX(dpy, drawable, mask);
8227117f1b4Smrg}
8237117f1b4Smrg
8247117f1b4Smrg
8257117f1b4Smrg
8267117f1b4Smrg/*** GLX_SGI_cushion ***/
8277117f1b4Smrg
8287117f1b4Smrgvoid PUBLIC
8297117f1b4SmrgglXCushionSGI(Display *dpy, Window win, float cushion)
8307117f1b4Smrg{
8317117f1b4Smrg   struct _glxapi_table *t;
8327117f1b4Smrg   GET_DISPATCH(dpy, t);
8337117f1b4Smrg   if (!t)
8347117f1b4Smrg      return;
83501e04c3fSmrg   t->CushionSGI(dpy, win, cushion);
8367117f1b4Smrg}
8377117f1b4Smrg
8387117f1b4Smrg
8397117f1b4Smrg
8407117f1b4Smrg/*** GLX_SGIX_video_resize ***/
8417117f1b4Smrg
8427117f1b4Smrgint PUBLIC
8437117f1b4SmrgglXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
8447117f1b4Smrg{
8457117f1b4Smrg   struct _glxapi_table *t;
8467117f1b4Smrg   GET_DISPATCH(dpy, t);
8477117f1b4Smrg   if (!t)
8487117f1b4Smrg      return 0;
84901e04c3fSmrg   return t->BindChannelToWindowSGIX(dpy, screen, channel, window);
8507117f1b4Smrg}
8517117f1b4Smrg
8527117f1b4Smrgint PUBLIC
8537117f1b4SmrgglXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
8547117f1b4Smrg{
8557117f1b4Smrg   struct _glxapi_table *t;
8567117f1b4Smrg   GET_DISPATCH(dpy, t);
8577117f1b4Smrg   if (!t)
8587117f1b4Smrg      return 0;
85901e04c3fSmrg   return t->ChannelRectSGIX(dpy, screen, channel, x, y, w, h);
8607117f1b4Smrg}
8617117f1b4Smrg
8627117f1b4Smrgint PUBLIC
8637117f1b4SmrgglXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
8647117f1b4Smrg{
8657117f1b4Smrg   struct _glxapi_table *t;
8667117f1b4Smrg   GET_DISPATCH(dpy, t);
8677117f1b4Smrg   if (!t)
8687117f1b4Smrg      return 0;
86901e04c3fSmrg   return t->QueryChannelRectSGIX(dpy, screen, channel, x, y, w, h);
8707117f1b4Smrg}
8717117f1b4Smrg
8727117f1b4Smrgint PUBLIC
8737117f1b4SmrgglXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
8747117f1b4Smrg{
8757117f1b4Smrg   struct _glxapi_table *t;
8767117f1b4Smrg   GET_DISPATCH(dpy, t);
8777117f1b4Smrg   if (!t)
8787117f1b4Smrg      return 0;
87901e04c3fSmrg   return t->QueryChannelDeltasSGIX(dpy, screen, channel, dx, dy, dw, dh);
8807117f1b4Smrg}
8817117f1b4Smrg
8827117f1b4Smrgint PUBLIC
8837117f1b4SmrgglXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
8847117f1b4Smrg{
8857117f1b4Smrg   struct _glxapi_table *t;
8867117f1b4Smrg   GET_DISPATCH(dpy, t);
8877117f1b4Smrg   if (!t)
8887117f1b4Smrg      return 0;
88901e04c3fSmrg   return t->ChannelRectSyncSGIX(dpy, screen, channel, synctype);
8907117f1b4Smrg}
8917117f1b4Smrg
8927117f1b4Smrg
8937117f1b4Smrg
8947117f1b4Smrg#if defined(_DM_BUFFER_H_)
8957117f1b4Smrg
8967117f1b4SmrgBool PUBLIC
8977117f1b4SmrgglXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
8987117f1b4Smrg{
8997117f1b4Smrg   struct _glxapi_table *t;
9007117f1b4Smrg   GET_DISPATCH(dpy, t);
9017117f1b4Smrg   if (!t)
9027117f1b4Smrg      return False;
90301e04c3fSmrg   return t->AssociateDMPbufferSGIX(dpy, pbuffer, params, dmbuffer);
9047117f1b4Smrg}
9057117f1b4Smrg
9067117f1b4Smrg#endif
9077117f1b4Smrg
9087117f1b4Smrg
9097117f1b4Smrg/*** GLX_SUN_get_transparent_index ***/
9107117f1b4Smrg
9117117f1b4SmrgStatus PUBLIC
9127ec681f3SmrgglXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, unsigned long *pTransparent)
9137117f1b4Smrg{
9147117f1b4Smrg   struct _glxapi_table *t;
9157117f1b4Smrg   GET_DISPATCH(dpy, t);
9167117f1b4Smrg   if (!t)
9177117f1b4Smrg      return False;
91801e04c3fSmrg   return t->GetTransparentIndexSUN(dpy, overlay, underlay, pTransparent);
9197117f1b4Smrg}
9207117f1b4Smrg
9217117f1b4Smrg
9227117f1b4Smrg
9237117f1b4Smrg/*** GLX_MESA_copy_sub_buffer ***/
9247117f1b4Smrg
9257117f1b4Smrgvoid PUBLIC
9267117f1b4SmrgglXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
9277117f1b4Smrg{
9287117f1b4Smrg   struct _glxapi_table *t;
9297117f1b4Smrg   GET_DISPATCH(dpy, t);
9307117f1b4Smrg   if (!t)
9317117f1b4Smrg      return;
93201e04c3fSmrg   t->CopySubBufferMESA(dpy, drawable, x, y, width, height);
9337117f1b4Smrg}
9347117f1b4Smrg
9357117f1b4Smrg
9367117f1b4Smrg
9377117f1b4Smrg/*** GLX_MESA_release_buffers ***/
9387117f1b4Smrg
9397117f1b4SmrgBool PUBLIC
9407117f1b4SmrgglXReleaseBuffersMESA(Display *dpy, Window w)
9417117f1b4Smrg{
9427117f1b4Smrg   struct _glxapi_table *t;
9437117f1b4Smrg   GET_DISPATCH(dpy, t);
9447117f1b4Smrg   if (!t)
9457117f1b4Smrg      return False;
94601e04c3fSmrg   return t->ReleaseBuffersMESA(dpy, w);
9477117f1b4Smrg}
9487117f1b4Smrg
9497117f1b4Smrg
9507117f1b4Smrg
9517117f1b4Smrg/*** GLX_MESA_pixmap_colormap ***/
9527117f1b4Smrg
9537117f1b4SmrgGLXPixmap PUBLIC
9547117f1b4SmrgglXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
9557117f1b4Smrg{
9567117f1b4Smrg   struct _glxapi_table *t;
9577117f1b4Smrg   GET_DISPATCH(dpy, t);
9587117f1b4Smrg   if (!t)
9597117f1b4Smrg      return 0;
96001e04c3fSmrg   return t->CreateGLXPixmapMESA(dpy, visinfo, pixmap, cmap);
9617117f1b4Smrg}
9627117f1b4Smrg
9637117f1b4Smrg
9647117f1b4Smrg
965c1f859d4Smrg/*** GLX_EXT_texture_from_pixmap */
966c1f859d4Smrg
967cdc920a0Smrgvoid PUBLIC
968c1f859d4SmrgglXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
969c1f859d4Smrg                   const int *attrib_list)
970c1f859d4Smrg{
971c1f859d4Smrg   struct _glxapi_table *t;
972c1f859d4Smrg   GET_DISPATCH(dpy, t);
973c1f859d4Smrg   if (t)
974c1f859d4Smrg      t->BindTexImageEXT(dpy, drawable, buffer, attrib_list);
975c1f859d4Smrg}
976c1f859d4Smrg
977cdc920a0Smrgvoid PUBLIC
978c1f859d4SmrgglXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
979c1f859d4Smrg{
980c1f859d4Smrg   struct _glxapi_table *t;
981c1f859d4Smrg   GET_DISPATCH(dpy, t);
982c1f859d4Smrg   if (t)
983c1f859d4Smrg      t->ReleaseTexImageEXT(dpy, drawable, buffer);
984c1f859d4Smrg}
985c1f859d4Smrg
9867117f1b4Smrg
9877117f1b4Smrg/**********************************************************************/
9887117f1b4Smrg/* GLX API management functions                                       */
9897117f1b4Smrg/**********************************************************************/
9907117f1b4Smrg
9917117f1b4Smrg
9927117f1b4Smrgconst char *
9937117f1b4Smrg_glxapi_get_version(void)
9947117f1b4Smrg{
9957117f1b4Smrg   return "1.3";
9967117f1b4Smrg}
9977117f1b4Smrg
9987117f1b4Smrg
9997117f1b4Smrg/*
10007117f1b4Smrg * Return array of extension strings.
10017117f1b4Smrg */
10027117f1b4Smrgconst char **
10037117f1b4Smrg_glxapi_get_extensions(void)
10047117f1b4Smrg{
10057117f1b4Smrg   static const char *extensions[] = {
10067117f1b4Smrg      "GLX_EXT_import_context",
10077117f1b4Smrg      "GLX_SGI_video_sync",
10087117f1b4Smrg      "GLX_MESA_copy_sub_buffer",
10097117f1b4Smrg      "GLX_MESA_release_buffers",
10107117f1b4Smrg      "GLX_MESA_pixmap_colormap",
10117117f1b4Smrg      "GLX_SGIX_fbconfig",
10127117f1b4Smrg      "GLX_SGIX_pbuffer",
1013c1f859d4Smrg      "GLX_EXT_texture_from_pixmap",
1014cdc920a0Smrg      "GLX_INTEL_swap_event",
10157117f1b4Smrg      NULL
10167117f1b4Smrg   };
10177117f1b4Smrg   return extensions;
10187117f1b4Smrg}
10197117f1b4Smrg
10207117f1b4Smrg
10217117f1b4Smrg/*
10227117f1b4Smrg * Return size of the GLX dispatch table, in entries, not bytes.
10237117f1b4Smrg */
10247117f1b4SmrgGLuint
10257117f1b4Smrg_glxapi_get_dispatch_table_size(void)
10267117f1b4Smrg{
10277117f1b4Smrg   return sizeof(struct _glxapi_table) / sizeof(void *);
10287117f1b4Smrg}
10297117f1b4Smrg
10307117f1b4Smrg
10317117f1b4Smrgstatic int
10327117f1b4Smrggeneric_no_op_func(void)
10337117f1b4Smrg{
10347117f1b4Smrg   return 0;
10357117f1b4Smrg}
10367117f1b4Smrg
10377117f1b4Smrg
10387117f1b4Smrg/*
10397117f1b4Smrg * Initialize all functions in given dispatch table to be no-ops
10407117f1b4Smrg */
10417117f1b4Smrgvoid
10427117f1b4Smrg_glxapi_set_no_op_table(struct _glxapi_table *t)
10437117f1b4Smrg{
10447117f1b4Smrg   typedef int (*nop_func)(void);
10457117f1b4Smrg   nop_func *dispatch = (nop_func *) t;
10467117f1b4Smrg   GLuint n = _glxapi_get_dispatch_table_size();
10477117f1b4Smrg   GLuint i;
10487117f1b4Smrg   for (i = 0; i < n; i++) {
10497117f1b4Smrg      dispatch[i] = generic_no_op_func;
10507117f1b4Smrg   }
10517117f1b4Smrg}
10527117f1b4Smrg
10537117f1b4Smrg
10547117f1b4Smrgstruct name_address_pair {
10557117f1b4Smrg   const char *Name;
10567117f1b4Smrg   __GLXextFuncPtr Address;
10577117f1b4Smrg};
10587117f1b4Smrg
10597117f1b4Smrgstatic struct name_address_pair GLX_functions[] = {
10607117f1b4Smrg   /*** GLX_VERSION_1_0 ***/
10617117f1b4Smrg   { "glXChooseVisual", (__GLXextFuncPtr) glXChooseVisual },
10627117f1b4Smrg   { "glXCopyContext", (__GLXextFuncPtr) glXCopyContext },
10637117f1b4Smrg   { "glXCreateContext", (__GLXextFuncPtr) glXCreateContext },
10647117f1b4Smrg   { "glXCreateGLXPixmap", (__GLXextFuncPtr) glXCreateGLXPixmap },
10657117f1b4Smrg   { "glXDestroyContext", (__GLXextFuncPtr) glXDestroyContext },
10667117f1b4Smrg   { "glXDestroyGLXPixmap", (__GLXextFuncPtr) glXDestroyGLXPixmap },
10677117f1b4Smrg   { "glXGetConfig", (__GLXextFuncPtr) glXGetConfig },
10687117f1b4Smrg   { "glXGetCurrentContext", (__GLXextFuncPtr) glXGetCurrentContext },
10697117f1b4Smrg   { "glXGetCurrentDrawable", (__GLXextFuncPtr) glXGetCurrentDrawable },
10707117f1b4Smrg   { "glXIsDirect", (__GLXextFuncPtr) glXIsDirect },
10717117f1b4Smrg   { "glXMakeCurrent", (__GLXextFuncPtr) glXMakeCurrent },
10727117f1b4Smrg   { "glXQueryExtension", (__GLXextFuncPtr) glXQueryExtension },
10737117f1b4Smrg   { "glXQueryVersion", (__GLXextFuncPtr) glXQueryVersion },
10747117f1b4Smrg   { "glXSwapBuffers", (__GLXextFuncPtr) glXSwapBuffers },
10757117f1b4Smrg   { "glXUseXFont", (__GLXextFuncPtr) glXUseXFont },
10767117f1b4Smrg   { "glXWaitGL", (__GLXextFuncPtr) glXWaitGL },
10777117f1b4Smrg   { "glXWaitX", (__GLXextFuncPtr) glXWaitX },
10787117f1b4Smrg
10797117f1b4Smrg   /*** GLX_VERSION_1_1 ***/
10807117f1b4Smrg   { "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },
10817117f1b4Smrg   { "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },
10827117f1b4Smrg   { "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },
10837117f1b4Smrg
10847117f1b4Smrg   /*** GLX_VERSION_1_2 ***/
10857117f1b4Smrg   { "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },
10867117f1b4Smrg
10877117f1b4Smrg   /*** GLX_VERSION_1_3 ***/
10887117f1b4Smrg   { "glXChooseFBConfig", (__GLXextFuncPtr) glXChooseFBConfig },
10897117f1b4Smrg   { "glXCreateNewContext", (__GLXextFuncPtr) glXCreateNewContext },
10907117f1b4Smrg   { "glXCreatePbuffer", (__GLXextFuncPtr) glXCreatePbuffer },
10917117f1b4Smrg   { "glXCreatePixmap", (__GLXextFuncPtr) glXCreatePixmap },
10927117f1b4Smrg   { "glXCreateWindow", (__GLXextFuncPtr) glXCreateWindow },
10937117f1b4Smrg   { "glXDestroyPbuffer", (__GLXextFuncPtr) glXDestroyPbuffer },
10947117f1b4Smrg   { "glXDestroyPixmap", (__GLXextFuncPtr) glXDestroyPixmap },
10957117f1b4Smrg   { "glXDestroyWindow", (__GLXextFuncPtr) glXDestroyWindow },
10967117f1b4Smrg   { "glXGetCurrentReadDrawable", (__GLXextFuncPtr) glXGetCurrentReadDrawable },
10977117f1b4Smrg   { "glXGetFBConfigAttrib", (__GLXextFuncPtr) glXGetFBConfigAttrib },
10987117f1b4Smrg   { "glXGetFBConfigs", (__GLXextFuncPtr) glXGetFBConfigs },
10997117f1b4Smrg   { "glXGetSelectedEvent", (__GLXextFuncPtr) glXGetSelectedEvent },
11007117f1b4Smrg   { "glXGetVisualFromFBConfig", (__GLXextFuncPtr) glXGetVisualFromFBConfig },
11017117f1b4Smrg   { "glXMakeContextCurrent", (__GLXextFuncPtr) glXMakeContextCurrent },
11027117f1b4Smrg   { "glXQueryContext", (__GLXextFuncPtr) glXQueryContext },
11037117f1b4Smrg   { "glXQueryDrawable", (__GLXextFuncPtr) glXQueryDrawable },
11047117f1b4Smrg   { "glXSelectEvent", (__GLXextFuncPtr) glXSelectEvent },
11057117f1b4Smrg
11067117f1b4Smrg   /*** GLX_VERSION_1_4 ***/
11077117f1b4Smrg   { "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },
11087117f1b4Smrg
11097117f1b4Smrg   /*** GLX_SGI_swap_control ***/
11107117f1b4Smrg   { "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },
11117117f1b4Smrg
11127117f1b4Smrg   /*** GLX_SGI_video_sync ***/
11137117f1b4Smrg   { "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },
11147117f1b4Smrg   { "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },
11157117f1b4Smrg
11167117f1b4Smrg   /*** GLX_SGI_make_current_read ***/
11177117f1b4Smrg   { "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },
11187117f1b4Smrg   { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },
11197117f1b4Smrg
11207117f1b4Smrg   /*** GLX_SGIX_video_source ***/
11217117f1b4Smrg#if defined(_VL_H)
11227117f1b4Smrg   { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },
11237117f1b4Smrg   { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },
11247117f1b4Smrg#endif
11257117f1b4Smrg
11267117f1b4Smrg   /*** GLX_EXT_import_context ***/
11277117f1b4Smrg   { "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },
11287117f1b4Smrg   { "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },
11297117f1b4Smrg   { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },
11307117f1b4Smrg   { "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },
11317117f1b4Smrg   { "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },
11327117f1b4Smrg
11337117f1b4Smrg   /*** GLX_SGIX_fbconfig ***/
11347117f1b4Smrg   { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr) glXGetFBConfigAttribSGIX },
11357117f1b4Smrg   { "glXChooseFBConfigSGIX", (__GLXextFuncPtr) glXChooseFBConfigSGIX },
11367117f1b4Smrg   { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr) glXCreateGLXPixmapWithConfigSGIX },
11377117f1b4Smrg   { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr) glXCreateContextWithConfigSGIX },
11387117f1b4Smrg   { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr) glXGetVisualFromFBConfigSGIX },
11397117f1b4Smrg   { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr) glXGetFBConfigFromVisualSGIX },
11407117f1b4Smrg
11417117f1b4Smrg   /*** GLX_SGIX_pbuffer ***/
11427117f1b4Smrg   { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },
11437117f1b4Smrg   { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },
11447117f1b4Smrg   { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },
11457117f1b4Smrg   { "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },
11467117f1b4Smrg   { "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },
11477117f1b4Smrg
11487117f1b4Smrg   /*** GLX_SGI_cushion ***/
11497117f1b4Smrg   { "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },
11507117f1b4Smrg
11517117f1b4Smrg   /*** GLX_SGIX_video_resize ***/
11527117f1b4Smrg   { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },
11537117f1b4Smrg   { "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },
11547117f1b4Smrg   { "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },
11557117f1b4Smrg   { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },
11567117f1b4Smrg   { "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },
11577117f1b4Smrg
11587117f1b4Smrg   /*** GLX_SGIX_dmbuffer **/
11597117f1b4Smrg#if defined(_DM_BUFFER_H_)
11607117f1b4Smrg   { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },
11617117f1b4Smrg#endif
11627117f1b4Smrg
11637117f1b4Smrg   /*** GLX_SUN_get_transparent_index ***/
11647117f1b4Smrg   { "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
11657117f1b4Smrg
11667117f1b4Smrg   /*** GLX_MESA_copy_sub_buffer ***/
11677117f1b4Smrg   { "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
11687117f1b4Smrg
11697117f1b4Smrg   /*** GLX_MESA_pixmap_colormap ***/
11707117f1b4Smrg   { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
11717117f1b4Smrg
11727117f1b4Smrg   /*** GLX_MESA_release_buffers ***/
11737117f1b4Smrg   { "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
11747117f1b4Smrg
11757117f1b4Smrg   /*** GLX_ARB_get_proc_address ***/
11767117f1b4Smrg   { "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
11777117f1b4Smrg
1178c1f859d4Smrg   /*** GLX_EXT_texture_from_pixmap ***/
1179c1f859d4Smrg   { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
1180c1f859d4Smrg   { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
1181c1f859d4Smrg
118201e04c3fSmrg   /*** GLX_ARB_create_context ***/
118301e04c3fSmrg   { "glXCreateContextAttribsARB", (__GLXextFuncPtr) glXCreateContextAttribsARB },
118401e04c3fSmrg
11857117f1b4Smrg   { NULL, NULL }   /* end of list */
11867117f1b4Smrg};
11877117f1b4Smrg
11887117f1b4Smrg
11897117f1b4Smrg
11907117f1b4Smrg/*
11917117f1b4Smrg * Return address of named glX function, or NULL if not found.
11927117f1b4Smrg */
11937117f1b4Smrg__GLXextFuncPtr
11947117f1b4Smrg_glxapi_get_proc_address(const char *funcName)
11957117f1b4Smrg{
11967117f1b4Smrg   GLuint i;
11977117f1b4Smrg   for (i = 0; GLX_functions[i].Name; i++) {
1198c1f859d4Smrg#ifdef MANGLE
1199c1f859d4Smrg      /* skip the "m" prefix on the name */
1200c1f859d4Smrg      if (strcmp(GLX_functions[i].Name, funcName+1) == 0)
1201c1f859d4Smrg#else
12027117f1b4Smrg      if (strcmp(GLX_functions[i].Name, funcName) == 0)
1203c1f859d4Smrg#endif
12047117f1b4Smrg         return GLX_functions[i].Address;
12057117f1b4Smrg   }
12067117f1b4Smrg   return NULL;
12077117f1b4Smrg}
12087117f1b4Smrg
12097117f1b4Smrg
12107117f1b4Smrg
12117117f1b4Smrg/*
12127117f1b4Smrg * This function does not get dispatched through the dispatch table
12137117f1b4Smrg * since it's really a "meta" function.
12147117f1b4Smrg */
1215cdc920a0Smrg__GLXextFuncPtr PUBLIC
12167117f1b4SmrgglXGetProcAddressARB(const GLubyte *procName)
12177117f1b4Smrg{
12187117f1b4Smrg   __GLXextFuncPtr f;
12197117f1b4Smrg
12207117f1b4Smrg   f = _glxapi_get_proc_address((const char *) procName);
12217117f1b4Smrg   if (f) {
12227117f1b4Smrg      return f;
12237117f1b4Smrg   }
12247117f1b4Smrg
12257117f1b4Smrg   f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
12267117f1b4Smrg   return f;
12277117f1b4Smrg}
12287117f1b4Smrg
12297117f1b4Smrg
12307117f1b4Smrg/* GLX 1.4 */
1231cdc920a0Smrgvoid PUBLIC
1232cdc920a0Smrg(*glXGetProcAddress(const GLubyte *procName))()
12337117f1b4Smrg{
12347117f1b4Smrg   return glXGetProcAddressARB(procName);
12357117f1b4Smrg}
123601e04c3fSmrg
123701e04c3fSmrg
123801e04c3fSmrg/**
123901e04c3fSmrg * Added in GLX_ARB_create_context.
124001e04c3fSmrg */
124101e04c3fSmrgGLXContext PUBLIC
124201e04c3fSmrgglXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
124301e04c3fSmrg                           GLXContext share_context, Bool direct,
124401e04c3fSmrg                           const int *attrib_list)
124501e04c3fSmrg{
124601e04c3fSmrg   struct _glxapi_table *t;
124701e04c3fSmrg   GET_DISPATCH(dpy, t);
124801e04c3fSmrg   if (!t)
124901e04c3fSmrg      return 0;
125001e04c3fSmrg   return t->CreateContextAttribs(dpy, config, share_context, direct,
125101e04c3fSmrg                                  attrib_list);
125201e04c3fSmrg}
1253