1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved.
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software.
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <windows.h>
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define WGL_WGLEXT_PROTOTYPES
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <GL/gl.h>
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <GL/wglext.h>
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "glapi/glapi.h"
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "stw_ext_gallium.h"
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "stw_device.h"
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "stw_icd.h"
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct stw_extension_entry
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   const char *name;
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   PROC proc;
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define STW_EXTENSION_ENTRY(P) { #P, (PROC) P }
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic const struct stw_extension_entry stw_extension_entries[] = {
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_ARB_extensions_string */
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ),
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_ARB_pbuffer */
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglCreatePbufferARB ),
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetPbufferDCARB ),
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglReleasePbufferDCARB ),
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglDestroyPbufferARB ),
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglQueryPbufferARB ),
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_ARB_pixel_format */
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ),
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_EXT_extensions_string */
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_EXT_swap_interval */
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_EXT_gallium ? */
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglGetGalliumScreenMESA ),
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglCreateGalliumContextMESA ),
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* WGL_ARB_create_context */
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   STW_EXTENSION_ENTRY( wglCreateContextAttribsARB ),
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { NULL, NULL }
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgPROC APIENTRY
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgDrvGetProcAddress(
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   LPCSTR lpszProc )
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   const struct stw_extension_entry *entry;
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (!stw_dev)
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      for (entry = stw_extension_entries; entry->name; entry++)
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         if (strcmp( lpszProc, entry->name ) == 0)
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org            return entry->proc;
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (lpszProc[0] == 'g' && lpszProc[1] == 'l')
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return (PROC) _glapi_get_proc_address( lpszProc );
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return NULL;
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
101