Path: blob/21.2-virgl/src/gallium/frontends/wgl/stw_getprocaddress.c
4561 views
/**************************************************************************1*2* Copyright 2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include <windows.h>2829#define WGL_WGLEXT_PROTOTYPES3031#include <GL/gl.h>32#include <GL/wglext.h>3334#include "glapi/glapi.h"35#include "stw_device.h"36#include "gldrv.h"37#include "stw_nopfuncs.h"3839#include "util/u_debug.h"4041struct stw_extension_entry42{43const char *name;44PROC proc;45};4647#define STW_EXTENSION_ENTRY(P) { #P, (PROC) P }4849static const struct stw_extension_entry stw_extension_entries[] = {5051/* WGL_ARB_extensions_string */52STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ),5354/* WGL_ARB_pbuffer */55STW_EXTENSION_ENTRY( wglCreatePbufferARB ),56STW_EXTENSION_ENTRY( wglGetPbufferDCARB ),57STW_EXTENSION_ENTRY( wglReleasePbufferDCARB ),58STW_EXTENSION_ENTRY( wglDestroyPbufferARB ),59STW_EXTENSION_ENTRY( wglQueryPbufferARB ),6061/* WGL_ARB_pixel_format */62STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ),63STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),64STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),6566/* WGL_EXT_extensions_string */67STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),6869/* WGL_EXT_swap_control */70STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),71STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),7273/* WGL_ARB_create_context */74STW_EXTENSION_ENTRY( wglCreateContextAttribsARB ),7576/* WGL_ARB_render_texture */77STW_EXTENSION_ENTRY( wglBindTexImageARB ),78STW_EXTENSION_ENTRY( wglReleaseTexImageARB ),79STW_EXTENSION_ENTRY( wglSetPbufferAttribARB ),8081/* WGL_ARB_make_current_read */82STW_EXTENSION_ENTRY( wglMakeContextCurrentARB ),83STW_EXTENSION_ENTRY( wglGetCurrentReadDCARB ),84{ NULL, NULL }85};8687PROC APIENTRY88DrvGetProcAddress(89LPCSTR lpszProc )90{91const struct stw_extension_entry *entry;92PROC p;9394if (!stw_dev)95return NULL;9697if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')98for (entry = stw_extension_entries; entry->name; entry++)99if (strcmp( lpszProc, entry->name ) == 0)100return entry->proc;101102if (lpszProc[0] == 'g' && lpszProc[1] == 'l') {103p = (PROC) _glapi_get_proc_address(lpszProc);104if (p)105return p;106}107108/* If we get here, we'd normally just return NULL, but since some apps109* (like Viewperf12) crash when they try to use the null pointer, try110* returning a pointer to a no-op function instead.111*/112p = stw_get_nop_function(lpszProc);113if (p) {114debug_printf("wglGetProcAddress(\"%s\") returning no-op function\n",115lpszProc);116return p;117}118119debug_printf("wglGetProcAddress(\"%s\") returning NULL\n", lpszProc);120return NULL;121}122123124