Merge branch 'mesa_7_6_branch'
[mesa.git] / src / gallium / state_trackers / wgl / stw_getprocaddress.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * 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
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include <windows.h>
29
30 #define WGL_WGLEXT_PROTOTYPES
31
32 #include <GL/gl.h>
33 #include <GL/wglext.h>
34
35 #include "glapi/glapi.h"
36 #include "stw_ext_gallium.h"
37
38 struct stw_extension_entry
39 {
40 const char *name;
41 PROC proc;
42 };
43
44 #define STW_EXTENSION_ENTRY(P) { #P, (PROC) P }
45
46 static const struct stw_extension_entry stw_extension_entries[] = {
47
48 /* WGL_ARB_extensions_string */
49 STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ),
50
51 /* WGL_ARB_pixel_format */
52 STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ),
53 STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),
54 STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),
55
56 /* WGL_EXT_extensions_string */
57 STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
58
59 /* WGL_EXT_swap_interval */
60 STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),
61 STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),
62
63 /* WGL_EXT_gallium ? */
64 STW_EXTENSION_ENTRY( wglGetGalliumScreenMESA ),
65 STW_EXTENSION_ENTRY( wglCreateGalliumContextMESA ),
66
67 { NULL, NULL }
68 };
69
70 PROC APIENTRY
71 DrvGetProcAddress(
72 LPCSTR lpszProc )
73 {
74 const struct stw_extension_entry *entry;
75
76 if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')
77 for (entry = stw_extension_entries; entry->name; entry++)
78 if (strcmp( lpszProc, entry->name ) == 0)
79 return entry->proc;
80
81 if (lpszProc[0] == 'g' && lpszProc[1] == 'l')
82 return (PROC) _glapi_get_proc_address( lpszProc );
83
84 return NULL;
85 }