Home | History | Annotate | Download | only in xlib
      1 /*
      2  * Mesa 3-D graphics library
      3  * Version:  7.6
      4  *
      5  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
      6  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
      7  *
      8  * Permission is hereby granted, free of charge, to any person obtaining a
      9  * copy of this software and associated documentation files (the "Software"),
     10  * to deal in the Software without restriction, including without limitation
     11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     12  * and/or sell copies of the Software, and to permit persons to whom the
     13  * Software is furnished to do so, subject to the following conditions:
     14  *
     15  * The above copyright notice and this permission notice shall be included
     16  * in all copies or substantial portions of the Software.
     17  *
     18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     21  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     22  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     24  */
     25 
     26 
     27 /**
     28  * glXGetProcAddress()
     29  */
     30 
     31 
     32 #define GLX_GLXEXT_PROTOTYPES
     33 
     34 #include <string.h>
     35 #include "GL/glx.h"
     36 #include "glapi/glapi.h"
     37 
     38 
     39 struct name_address_pair {
     40    const char *Name;
     41    __GLXextFuncPtr Address;
     42 };
     43 
     44 
     45 static struct name_address_pair GLX_functions[] = {
     46    /*** GLX_VERSION_1_0 ***/
     47    { "glXChooseVisual", (__GLXextFuncPtr) glXChooseVisual },
     48    { "glXCopyContext", (__GLXextFuncPtr) glXCopyContext },
     49    { "glXCreateContext", (__GLXextFuncPtr) glXCreateContext },
     50    { "glXCreateGLXPixmap", (__GLXextFuncPtr) glXCreateGLXPixmap },
     51    { "glXDestroyContext", (__GLXextFuncPtr) glXDestroyContext },
     52    { "glXDestroyGLXPixmap", (__GLXextFuncPtr) glXDestroyGLXPixmap },
     53    { "glXGetConfig", (__GLXextFuncPtr) glXGetConfig },
     54    { "glXGetCurrentContext", (__GLXextFuncPtr) glXGetCurrentContext },
     55    { "glXGetCurrentDrawable", (__GLXextFuncPtr) glXGetCurrentDrawable },
     56    { "glXIsDirect", (__GLXextFuncPtr) glXIsDirect },
     57    { "glXMakeCurrent", (__GLXextFuncPtr) glXMakeCurrent },
     58    { "glXQueryExtension", (__GLXextFuncPtr) glXQueryExtension },
     59    { "glXQueryVersion", (__GLXextFuncPtr) glXQueryVersion },
     60    { "glXSwapBuffers", (__GLXextFuncPtr) glXSwapBuffers },
     61    { "glXUseXFont", (__GLXextFuncPtr) glXUseXFont },
     62    { "glXWaitGL", (__GLXextFuncPtr) glXWaitGL },
     63    { "glXWaitX", (__GLXextFuncPtr) glXWaitX },
     64 
     65    /*** GLX_VERSION_1_1 ***/
     66    { "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },
     67    { "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },
     68    { "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },
     69 
     70    /*** GLX_VERSION_1_2 ***/
     71    { "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },
     72 
     73    /*** GLX_VERSION_1_3 ***/
     74    { "glXChooseFBConfig", (__GLXextFuncPtr) glXChooseFBConfig },
     75    { "glXCreateNewContext", (__GLXextFuncPtr) glXCreateNewContext },
     76    { "glXCreatePbuffer", (__GLXextFuncPtr) glXCreatePbuffer },
     77    { "glXCreatePixmap", (__GLXextFuncPtr) glXCreatePixmap },
     78    { "glXCreateWindow", (__GLXextFuncPtr) glXCreateWindow },
     79    { "glXDestroyPbuffer", (__GLXextFuncPtr) glXDestroyPbuffer },
     80    { "glXDestroyPixmap", (__GLXextFuncPtr) glXDestroyPixmap },
     81    { "glXDestroyWindow", (__GLXextFuncPtr) glXDestroyWindow },
     82    { "glXGetCurrentReadDrawable", (__GLXextFuncPtr) glXGetCurrentReadDrawable },
     83    { "glXGetFBConfigAttrib", (__GLXextFuncPtr) glXGetFBConfigAttrib },
     84    { "glXGetFBConfigs", (__GLXextFuncPtr) glXGetFBConfigs },
     85    { "glXGetSelectedEvent", (__GLXextFuncPtr) glXGetSelectedEvent },
     86    { "glXGetVisualFromFBConfig", (__GLXextFuncPtr) glXGetVisualFromFBConfig },
     87    { "glXMakeContextCurrent", (__GLXextFuncPtr) glXMakeContextCurrent },
     88    { "glXQueryContext", (__GLXextFuncPtr) glXQueryContext },
     89    { "glXQueryDrawable", (__GLXextFuncPtr) glXQueryDrawable },
     90    { "glXSelectEvent", (__GLXextFuncPtr) glXSelectEvent },
     91 
     92    /*** GLX_VERSION_1_4 ***/
     93    { "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },
     94 
     95    /*** GLX_SGI_swap_control ***/
     96    { "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },
     97 
     98    /*** GLX_SGI_video_sync ***/
     99    { "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },
    100    { "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },
    101 
    102    /*** GLX_SGI_make_current_read ***/
    103    { "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },
    104    { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },
    105 
    106    /*** GLX_SGIX_video_source ***/
    107 #if defined(_VL_H)
    108    { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },
    109    { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },
    110 #endif
    111 
    112    /*** GLX_EXT_import_context ***/
    113    { "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },
    114    { "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },
    115    { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },
    116    { "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },
    117    { "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },
    118 
    119    /*** GLX_SGIX_fbconfig ***/
    120    { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr) glXGetFBConfigAttribSGIX },
    121    { "glXChooseFBConfigSGIX", (__GLXextFuncPtr) glXChooseFBConfigSGIX },
    122    { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr) glXCreateGLXPixmapWithConfigSGIX },
    123    { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr) glXCreateContextWithConfigSGIX },
    124    { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr) glXGetVisualFromFBConfigSGIX },
    125    { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr) glXGetFBConfigFromVisualSGIX },
    126 
    127    /*** GLX_SGIX_pbuffer ***/
    128    { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },
    129    { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },
    130    { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },
    131    { "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },
    132    { "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },
    133 
    134    /*** GLX_SGI_cushion ***/
    135    { "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },
    136 
    137    /*** GLX_SGIX_video_resize ***/
    138    { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },
    139    { "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },
    140    { "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },
    141    { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },
    142    { "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },
    143 
    144    /*** GLX_SGIX_dmbuffer **/
    145 #if defined(_DM_BUFFER_H_)
    146    { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },
    147 #endif
    148 
    149    /*** GLX_SGIX_swap_group ***/
    150    { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr) glXJoinSwapGroupSGIX },
    151 
    152    /*** GLX_SGIX_swap_barrier ***/
    153    { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr) glXBindSwapBarrierSGIX },
    154    { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr) glXQueryMaxSwapBarriersSGIX },
    155 
    156    /*** GLX_SUN_get_transparent_index ***/
    157    { "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
    158 
    159    /*** GLX_MESA_copy_sub_buffer ***/
    160    { "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
    161 
    162    /*** GLX_MESA_pixmap_colormap ***/
    163    { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
    164 
    165    /*** GLX_MESA_release_buffers ***/
    166    { "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
    167 
    168    /*** GLX_ARB_get_proc_address ***/
    169    { "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
    170 
    171    /*** GLX_ARB_create_context ***/
    172    { "glXCreateContextAttribsARB", (__GLXextFuncPtr) glXCreateContextAttribsARB },
    173 
    174    /*** GLX_EXT_texture_from_pixmap ***/
    175    { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
    176    { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
    177 
    178    { NULL, NULL }   /* end of list */
    179 };
    180 
    181 
    182 
    183 /**
    184  * Return address of named glX function, or NULL if not found.
    185  */
    186 static __GLXextFuncPtr
    187 _glxapi_get_proc_address(const char *funcName)
    188 {
    189    GLuint i;
    190    for (i = 0; GLX_functions[i].Name; i++) {
    191       if (strcmp(GLX_functions[i].Name, funcName) == 0)
    192          return GLX_functions[i].Address;
    193    }
    194    return NULL;
    195 }
    196 
    197 
    198 PUBLIC __GLXextFuncPtr
    199 glXGetProcAddressARB(const GLubyte *procName)
    200 {
    201    __GLXextFuncPtr f;
    202 
    203    f = _glxapi_get_proc_address((const char *) procName);
    204    if (f) {
    205       return f;
    206    }
    207 
    208    f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
    209    return f;
    210 }
    211 
    212 
    213 /* GLX 1.4 */
    214 PUBLIC
    215 void (*glXGetProcAddress(const GLubyte *procName))()
    216 {
    217    return glXGetProcAddressARB(procName);
    218 }
    219