Path: blob/21.2-virgl/src/gallium/frontends/glx/xlib/glx_getproc.c
4561 views
/*1* Mesa 3-D graphics library2*3* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.4* Copyright (C) 2009 VMware, Inc. All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* the rights to use, copy, modify, merge, publish, distribute, sublicense,10* and/or sell copies of the Software, and to permit persons to whom the11* Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice shall be included14* in all copies or substantial portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS17* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR20* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,21* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR22* OTHER DEALINGS IN THE SOFTWARE.23*/242526/**27* glXGetProcAddress()28*/293031#define GLX_GLXEXT_PROTOTYPES3233#include <string.h>34#include "pipe/p_compiler.h"35#include "GL/glx.h"36#include "glapi/glapi.h"373839struct name_address_pair {40const char *Name;41__GLXextFuncPtr Address;42};434445static const 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 },6465/*** GLX_VERSION_1_1 ***/66{ "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },67{ "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },68{ "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },6970/*** GLX_VERSION_1_2 ***/71{ "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },7273/*** 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 },9192/*** GLX_VERSION_1_4 ***/93{ "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },9495/*** GLX_SGI_swap_control ***/96{ "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },9798/*** GLX_SGI_video_sync ***/99{ "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },100{ "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },101102/*** GLX_SGI_make_current_read ***/103{ "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },104{ "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },105106/*** GLX_SGIX_video_source ***/107#if defined(_VL_H)108{ "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },109{ "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },110#endif111112/*** GLX_EXT_import_context ***/113{ "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },114{ "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },115{ "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },116{ "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },117{ "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },118119/*** 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 },126127/*** GLX_SGIX_pbuffer ***/128{ "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },129{ "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },130{ "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },131{ "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },132{ "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },133134/*** GLX_SGI_cushion ***/135{ "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },136137/*** GLX_SGIX_video_resize ***/138{ "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },139{ "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },140{ "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },141{ "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },142{ "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },143144/*** GLX_SGIX_dmbuffer **/145#if defined(_DM_BUFFER_H_)146{ "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },147#endif148149/*** GLX_SUN_get_transparent_index ***/150{ "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },151152/*** GLX_MESA_copy_sub_buffer ***/153{ "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },154155/*** GLX_MESA_pixmap_colormap ***/156{ "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },157158/*** GLX_MESA_release_buffers ***/159{ "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },160161/*** GLX_ARB_get_proc_address ***/162{ "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },163164/*** GLX_ARB_create_context ***/165{ "glXCreateContextAttribsARB", (__GLXextFuncPtr) glXCreateContextAttribsARB },166167/*** GLX_EXT_texture_from_pixmap ***/168{ "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },169{ "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },170171{ NULL, NULL } /* end of list */172};173174175176/**177* Return address of named glX function, or NULL if not found.178*/179static __GLXextFuncPtr180_glxapi_get_proc_address(const char *funcName)181{182GLuint i;183for (i = 0; GLX_functions[i].Name; i++) {184if (strcmp(GLX_functions[i].Name, funcName) == 0)185return GLX_functions[i].Address;186}187return NULL;188}189190191PUBLIC __GLXextFuncPtr192glXGetProcAddressARB(const GLubyte *procName)193{194__GLXextFuncPtr f;195196f = _glxapi_get_proc_address((const char *) procName);197if (f) {198return f;199}200201f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);202return f;203}204205206/* GLX 1.4 */207PUBLIC208void (*glXGetProcAddress(const GLubyte *procName))()209{210return glXGetProcAddressARB(procName);211}212213214